"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __generator = (this && this.__generator) || function (thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; Object.defineProperty(exports, "__esModule", { value: true }); var promise_wx_api_1 = require("../../utils/promise-wx-api"); var app = getApp(); var api = require("../../utils/api.js"); Component({ data: { isPage: false, statusHeight: 0, navigationHeight: 0, selectedTab: "tab0", banner: [], indicatorDots: false, autoplay: true, circular: true, interval: 4000, duration: 500, currentSwiper: 0, loadMoreVisible: false, loadMoreType: "none", dingdan: false, jingcai: true, indexPage: 1, pageSize: 10, qkdat: false, actId: "", volunteerList: [], listLength: 0, getImgUrl: "", ifClickImage: false, showTip: false, inProgressId: "", inProgressTitle: "", selectSubTab: "tab0", hotLine: "", actListName: "", heartRankName: "", actReviewName: "", myActName: "", customerId: "", }, properties: { selectedTab: { type: String, value: "tab0", }, }, lifetimes: { ready: function () { return __awaiter(this, void 0, void 0, function () { var params; var _this = this; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4, app.doAfterLogin()]; case 1: _a.sent(); this.setData({ statusHeight: app.globalData.statusHeight, navigationHeight: app.globalData.navHeight, customerId: app.globalData.customerId, selectedTab: this.data.selectedTab, }); params = { customerId: app.globalData.customerId, }; api.getHeartConfigs(params).then(function (res) { _this.setData({ titleName: res.data.titleName, hotLine: res.data.hotLine, myActName: res.data.myActName, heartRankName: res.data.heartRankName, actReviewName: res.data.actReviewName, actListName: res.data.actListName, }); }); this.refreshData(); return [2]; } }); }); }, }, methods: { onLoad: function () { this.setData({ isPage: true, }); }, refreshData: function () { return __awaiter(this, void 0, void 0, function () { var parms; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4, app.doAfterLogin()]; case 1: _a.sent(); this.getInProgress(); this.setData({ loadMoreVisible: true, loadMoreType: "loading", }); if (this.data.selectedTab == "tab1") { if (this.data.ifClickImage) { this.setData({ ifClickImage: false, }); } else { this.setData({ indexPage: 1, }); this.setData({ volunteerList: [], listLength: 0, }); parms = { pageIndex: this.data.indexPage, pageSize: this.data.pageSize * this.data.indexPage, customerId: app.globalData.customerId, }; this.getVolunteerList(parms); } } else { this.updateActivityList(); } return [2]; } }); }); }, onPullDownRefresh: function () { this.getInProgress(); wx.stopPullDownRefresh(); }, onReachBottom: function () { return __awaiter(this, void 0, void 0, function () { var parms, parms, parms, parms; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4, app.doAfterLogin()]; case 1: _a.sent(); if (this.data.listLength === 0) { this.setData({ loadMoreVisible: true, loadMoreType: "none", }); } else { this.setData({ loadMoreVisible: true, loadMoreType: "loading", }); if (this.data.selectedTab == "tab0") { this.setData({ indexPage: this.data.indexPage + 1, }); parms = { pageIndex: this.data.indexPage, pageSize: this.data.pageSize, actType: 0, selectedTab: this.data.selectedTab, customerId: app.globalData.customerId, }; this.selectComponent("#state-0").getActivityList(parms); } else if (this.data.selectedTab == "tab1") { this.setData({ indexPage: this.data.indexPage + 1, }); parms = { pageIndex: this.data.indexPage, pageSize: this.data.pageSize, customerId: app.globalData.customerId, }; this.getVolunteerList(parms); } else if (this.data.selectedTab == "tab2") { this.setData({ indexPage: this.data.indexPage + 1, }); parms = { pageIndex: this.data.indexPage, pageSize: this.data.pageSize, actType: 1, selectedTab: this.data.selectedTab, customerId: app.globalData.customerId, }; this.selectComponent("#state-2").getActivityList(parms); } else if (this.data.selectedTab == "tab3") { this.setData({ indexPage: this.data.indexPage + 1, }); parms = { pageIndex: this.data.indexPage, pageSize: this.data.pageSize, type: this.data.selectSubTab == "tab0" ? "auditing" : this.data.selectSubTab == "tab1" ? "passed" : this.data.selectSubTab == "tab2" ? "refused" : this.data.selectSubTab == "tab3" ? "canceld" : "auditing", actType: 1, selectedTab: this.data.selectedTab, customerId: app.globalData.customerId, }; this.selectComponent("#state-3").getMyActivityList(parms); } } return [2]; } }); }); }, tabBarChange: function (e) { return __awaiter(this, void 0, void 0, function () { var parms, parms, parms, parms; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4, app.doAfterLogin()]; case 1: _a.sent(); this.setData({ loadMoreVisible: true, loadMoreType: "loading", indexPage: 1, selectedTab: e.currentTarget.dataset.tab, }); if (e.currentTarget.dataset.tab == "tab0") { parms = { pageIndex: this.data.indexPage, pageSize: this.data.pageSize, actType: 0, qkdat: true, selectedTab: e.currentTarget.dataset.tab, customerId: app.globalData.customerId, }; this.selectComponent("#state-0").getActivityList(parms); } else if (e.currentTarget.dataset.tab == "tab2") { this.setData({ volunteerList: [], listLength: 0, }); parms = { pageIndex: this.data.indexPage, pageSize: this.data.pageSize, customerId: app.globalData.customerId, }; this.getVolunteerList(parms); } else if (e.currentTarget.dataset.tab == "tab1") { parms = { pageIndex: this.data.indexPage, pageSize: this.data.pageSize, actType: 1, qkdat: true, selectedTab: e.currentTarget.dataset.tab, customerId: app.globalData.customerId, }; this.selectComponent("#state-2").getActivityList(parms); } else if (e.currentTarget.dataset.tab == "tab3") { this.setData({ selectSubTab: "tab0", }); parms = { pageIndex: this.data.indexPage, pageSize: this.data.pageSize, actType: 1, qkdat: true, type: "auditing", selectedTab: e.currentTarget.dataset.tab, customerId: app.globalData.customerId, }; this.selectComponent("#state-3").getMyActivityList(parms); } this.setData({ selectedTab: e.currentTarget.dataset.tab, }); return [2]; } }); }); }, updateActivityList: function () { if (this.data.selectedTab === "tab0") { var params = { pageIndex: 1, pageSize: this.data.indexPage * this.data.pageSize, customerId: app.globalData.customerId, }; this.selectComponent("#state-0").updateActivityList(params); } else if (this.data.selectedTab === "tab2") { var params = { pageIndex: 1, pageSize: this.data.indexPage * this.data.pageSize, customerId: app.globalData.customerId, }; this.selectComponent("#state-2").updateActivityList(params); } else if (this.data.selectedTab === "tab3") { var params = { pageIndex: 1, pageSize: this.data.indexPage * this.data.pageSize, type: this.data.selectSubTab == "tab0" ? "auditing" : this.data.selectSubTab == "tab1" ? "passed" : this.data.selectSubTab == "tab2" ? "refused" : this.data.selectSubTab == "tab3" ? "canceld" : "auditing", customerId: app.globalData.customerId, }; this.selectComponent("#state-3").updateMyActivityList(params); } this.setData({ actId: "", }); }, getVolunteerList: function (params) { var that = this; api.getVolunteerList(params).then(function (res) { if (res.data.length !== that.data.pageSize) { that.setData({ loadMoreVisible: true, loadMoreType: "none", }); } that.setData({ listLength: res.data.length, volunteerList: that.data.volunteerList.concat(res.data), }); }); }, goback: function () { wx.navigateBack({ delta: 1, }); }, swiperChange: function (e) { this.setData({ currentSwiper: e.detail.current, }); }, toActDetailDown: function (e) { if (e.detail.listLength !== this.data.pageSize) { this.setData({ loadMoreVisible: true, loadMoreType: "none", }); } this.setData({ actId: e.detail.actId, listLength: e.detail.listLength, }); }, clickImage: function (e) { this.setData({ ifClickImage: e.detail, }); }, bannerListV2: function () { var that = this; var params = { bannerType: "0", }; api.bannerList(params).then(function (res) { that.setData({ banner: res.data, }); wx.stopPullDownRefresh(); }); }, getImgUrl: function () { var that = this; api.getImgUrl("0").then(function (res) { that.setData({ getImgUrl: res.data[0], }); }); }, govolunteer: function (e) { return __awaiter(this, void 0, void 0, function () { var _a, msg, data, param; return __generator(this, function (_b) { switch (_b.label) { case 0: return [4, promise_wx_api_1.wxGetUserProfile({ desc: "用于完善居民信息", })]; case 1: _a = _b.sent(), msg = _a.msg, data = _a.data; if (msg == "success") { param = { nickName: data.userInfo.nickName, gender: data.userInfo.gender, avatarUrl: data.userInfo.avatarUrl, province: data.userInfo.province, country: data.userInfo.country, city: data.userInfo.city, }; api.updateWxUserInfo(param).then(function (res) { wx.navigateTo({ url: "/subpages/heart/pages/volunteer/volunteer?from=index", }); }); } else { wx.showModal({ title: "提示", content: "请先授权", showCancel: false, confirmText: "确定", success: function (res) { if (res.confirm) { console.log("用户点击了“返回授权”"); } }, }); } return [2]; } }); }); }, getPhone: function (e) { wx.showModal({ title: "拨打电话", content: "", cancelColor: "#29B9A5", confirmColor: "#29B9A5", success: function (res) { if (res.confirm) { console.log("用户点击确定"); wx.makePhoneCall({ phoneNumber: e.currentTarget.dataset.number, }); } else if (res.cancel) { console.log("用户点击取消"); } }, }); }, getInProgress: function () { var _this = this; api.getInProgress().then(function (res) { if (res.data.length > 0) { _this.setData({ inProgressTitle: res.data[0].title, inProgressId: res.data[0].actId, showTip: true, }); } else { _this.setData({ showTip: false, }); } }); }, subTabChange: function (e) { this.setData({ loadMoreVisible: true, loadMoreType: "loading", indexPage: 1, selectSubTab: e.currentTarget.dataset.subtab, }); var params = { pageIndex: 1, pageSize: this.data.pageSize, actType: 1, type: "auditing", actId: this.data.actId, selectedTab: this.data.selectedTab, customerId: app.globalData.customerId, qkdat: true, }; if (e.currentTarget.dataset.subtab == "tab1") { params.type = "passed"; } else if (e.currentTarget.dataset.subtab == "tab2") { params.type = "refused"; } else if (e.currentTarget.dataset.subtab == "tab3") { params.type = "canceld"; } this.selectComponent("#state-3").getMyActivityList(params); }, goDial: function (e) { var tel = e.target.dataset.tel; wx.makePhoneCall({ phoneNumber: tel, }); }, toTipDetail: function (e) { var actid = e.target.dataset.actid; wx.navigateTo({ url: "/subpages/heart/pages/heartDetail/heartDetail?id=" + actid, }); }, }, });