You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
359 lines
16 KiB
359 lines
16 KiB
"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 index_js_1 = require("../../miniprogram_npm/dai-mp/mixins/computed-component/index.js");
|
|
var promise_wx_api_1 = require("../../utils/promise-wx-api");
|
|
var tools_1 = require("../../utils/tools");
|
|
var app = getApp();
|
|
Component({
|
|
behaviors: [index_js_1.default],
|
|
data: {
|
|
iniLoaded: false,
|
|
pageTitle: "",
|
|
currentTab: "",
|
|
guide: {
|
|
pic: "",
|
|
cd: 0,
|
|
currentCd: 0,
|
|
},
|
|
eventTabIsLoaded: false,
|
|
issueTabIsLoaded: false,
|
|
groupTabIsLoaded: false,
|
|
gardenTabIsLoaded: false,
|
|
heartTabIsLoaded: false,
|
|
serviceTabIsLoaded: false,
|
|
mineTabIsLoaded: false,
|
|
availdTabKey: [
|
|
"issue",
|
|
"group",
|
|
"garden",
|
|
"heart",
|
|
"mine",
|
|
"service",
|
|
"event",
|
|
],
|
|
tabStyle: 0,
|
|
homeIndex: 0,
|
|
tabList: [],
|
|
},
|
|
watch: {
|
|
currentTab: function (tab) {
|
|
if (tab === "issue") {
|
|
this.setData({
|
|
issueTabIsLoaded: true,
|
|
});
|
|
}
|
|
else if (tab === "group") {
|
|
this.setData({
|
|
groupTabIsLoaded: true,
|
|
});
|
|
}
|
|
else if (tab === "garden") {
|
|
this.setData({
|
|
gardenTabIsLoaded: true,
|
|
});
|
|
}
|
|
else if (tab === "heart") {
|
|
this.setData({
|
|
heartTabIsLoaded: true,
|
|
});
|
|
}
|
|
else if (tab === "service") {
|
|
this.setData({
|
|
serviceTabIsLoaded: true,
|
|
});
|
|
}
|
|
else if (tab === "mine") {
|
|
this.setData({
|
|
mineTabIsLoaded: true,
|
|
});
|
|
}
|
|
else if (tab === "event") {
|
|
this.setData({
|
|
eventTabIsLoaded: true,
|
|
});
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
onLoad: function (options) {
|
|
return __awaiter(this, void 0, void 0, function () {
|
|
var tab, _a, currentTab, tabList;
|
|
return __generator(this, function (_b) {
|
|
switch (_b.label) {
|
|
case 0:
|
|
if (!(new Date().getTime() - app.globalData.appLaunchTime < 5000)) return [3, 2];
|
|
return [4, this.getYdyInfo()];
|
|
case 1:
|
|
_b.sent();
|
|
this.guideStartCd();
|
|
_b.label = 2;
|
|
case 2:
|
|
console.log(options);
|
|
return [4, app.doAfterLogin()];
|
|
case 3:
|
|
_b.sent();
|
|
return [4, this.getTabList()];
|
|
case 4:
|
|
|
|
|
|
_b.sent();
|
|
tab = options.tab;
|
|
if (!(typeof tab !== "undefined")) return [3, 6];
|
|
return [4, this.switchTab(tab)];
|
|
case 5:
|
|
_b.sent();
|
|
_b.label = 6;
|
|
case 6:
|
|
_a = this.data, currentTab = _a.currentTab, tabList = _a.tabList;
|
|
if (Array.isArray(tabList) &&
|
|
tabList.length > 0 &&
|
|
(currentTab == "" || tabList.every(function (item) { return item.barKey != currentTab; }))) {
|
|
currentTab = tabList[this.data.homeIndex].barKey;
|
|
this.switchTab(currentTab);
|
|
}
|
|
this.setData({
|
|
iniLoaded: true,
|
|
});
|
|
return [2];
|
|
}
|
|
});
|
|
});
|
|
},
|
|
onShow: function () {
|
|
console.log("main page onshow!", this.data.currentTab);
|
|
if (this.data.currentTab == "group") {
|
|
console.log(this.data.currentTab + "page onshow");
|
|
this.selectComponent("#group").refreshData();
|
|
}
|
|
if (this.data.currentTab == "index") {
|
|
console.log(this.data.currentTab + "page onshow");
|
|
this.selectComponent("#index").refreshData();
|
|
}
|
|
},
|
|
skipGuide: function () {
|
|
if (this.data.iniLoaded) {
|
|
this.setData({
|
|
"guide.currentCd": 0,
|
|
});
|
|
}
|
|
},
|
|
guideStartCd: function () {
|
|
return __awaiter(this, void 0, void 0, function () {
|
|
var currentCd;
|
|
return __generator(this, function (_a) {
|
|
switch (_a.label) {
|
|
case 0: return [4, tools_1.nextTick(1000)];
|
|
case 1:
|
|
_a.sent();
|
|
currentCd = this.data.guide.currentCd;
|
|
if (currentCd <= 0) {
|
|
return [2];
|
|
}
|
|
else {
|
|
this.setData({
|
|
"guide.currentCd": currentCd - 1,
|
|
});
|
|
this.guideStartCd();
|
|
}
|
|
return [2];
|
|
}
|
|
});
|
|
});
|
|
},
|
|
hintFillIdNum: function () {
|
|
return __awaiter(this, void 0, void 0, function () {
|
|
var _a, _b, code, data, msg, $modal, confirm;
|
|
return __generator(this, function (_c) {
|
|
switch (_c.label) {
|
|
case 0:
|
|
if (app.globalData.isHintedFillIdNum)
|
|
return [2];
|
|
return [4, promise_wx_api_1.wxRequestPost("resi/mine/mine/profile", {
|
|
customerId: app.globalData.customerId,
|
|
gridId: app.globalData.gridId,
|
|
}, {})];
|
|
case 1:
|
|
_a = _c.sent(), _b = _a.data.data, code = _b.code, data = _b.data, msg = _a.msg;
|
|
if (!(msg === "success" && code === 0)) return [3, 3];
|
|
app.globalData.isHintedFillIdNum = true;
|
|
if (data.userId) {
|
|
app.globalData.userId = data.userId;
|
|
}
|
|
if (!(data.registerFlag && !data.completeIdNum)) return [3, 3];
|
|
$modal = this.selectComponent("#modal");
|
|
return [4, $modal.show({
|
|
title: "补充信息",
|
|
content: "请补充您的身份信息",
|
|
showCancel: true,
|
|
})];
|
|
case 2:
|
|
confirm = _c.sent();
|
|
$modal.hide();
|
|
if (confirm) {
|
|
promise_wx_api_1.wxNavigateTo("/subpages/mine/pages/register/edit-base/index", {
|
|
from: "completeIdNum",
|
|
});
|
|
}
|
|
else {
|
|
wx.navigateBack();
|
|
}
|
|
_c.label = 3;
|
|
case 3: return [2];
|
|
}
|
|
});
|
|
});
|
|
},
|
|
getYdyInfo: function () {
|
|
return __awaiter(this, void 0, void 0, function () {
|
|
var localData, extAppid, _a, _b, code, data, msg;
|
|
return __generator(this, function (_c) {
|
|
switch (_c.label) {
|
|
case 0:
|
|
localData = wx.getStorageSync("yindaoye");
|
|
if (typeof localData === "object" && localData.resiUrl) {
|
|
this.setData({
|
|
"guide.pic": localData.resiUrl,
|
|
"guide.cd": localData.resiTime,
|
|
"guide.currentCd": localData.resiTime,
|
|
});
|
|
}
|
|
extAppid = app.globalData.extAppid;
|
|
return [4, promise_wx_api_1.wxRequestPost("oper/customize/customerstartpage/homestartpage", {
|
|
appId: extAppid,
|
|
}, {
|
|
hasToken: false,
|
|
})];
|
|
case 1:
|
|
_a = _c.sent(), _b = _a.data.data, code = _b.code, data = _b.data, msg = _a.msg;
|
|
if (msg === "success" && code === 0) {
|
|
wx.setStorage({
|
|
key: "yindaoye",
|
|
data: data,
|
|
success: function () {
|
|
console.log("引导页数据缓存成功");
|
|
},
|
|
});
|
|
if (!localData || localData.resiUrl != data.resiUrl) {
|
|
this.setData({
|
|
"guide.pic": data.resiUrl,
|
|
"guide.cd": data.resiTime,
|
|
"guide.currentCd": data.resiTime,
|
|
});
|
|
}
|
|
}
|
|
return [2];
|
|
}
|
|
});
|
|
});
|
|
},
|
|
getTabList: function () {
|
|
return __awaiter(this, void 0, void 0, function () {
|
|
var customerId, _a, _b, code, data, msg, availdTabKey_1, tabList;
|
|
return __generator(this, function (_c) {
|
|
switch (_c.label) {
|
|
case 0:
|
|
customerId = app.globalData.customerId;
|
|
return [4, promise_wx_api_1.wxRequestPost("data/aggregator/app/footbars", {
|
|
customerId: customerId,
|
|
appType: "resi",
|
|
}, {})];
|
|
case 1:
|
|
_a = _c.sent(), _b = _a.data.data, code = _b.code, data = _b.data, msg = _a.msg;
|
|
if (msg === "success") {
|
|
if (code === 0 &&
|
|
Array.isArray(data.footBarList) &&
|
|
data.footBarList.length > 0) {
|
|
availdTabKey_1 = this.data.availdTabKey;
|
|
tabList = data.footBarList.filter(function (item) {
|
|
return availdTabKey_1.indexOf(item.barKey) !== -1;
|
|
});
|
|
this.setData({
|
|
tabStyle: tabList.length % 2 == 1 && data.pattern == "float" ? 1 : 0,
|
|
homeIndex: parseInt(data.highLightNum),
|
|
tabList: tabList,
|
|
});
|
|
}
|
|
}
|
|
return [2];
|
|
}
|
|
});
|
|
});
|
|
},
|
|
handleTapTab: function (e) {
|
|
var current = e.target.dataset.current;
|
|
if (typeof current == "undefined" || this.data.currentTab === current) {
|
|
return;
|
|
}
|
|
this.switchTab(current);
|
|
},
|
|
handleCptSwitchTab: function (e) {
|
|
var tab = e.detail.tab;
|
|
if (typeof tab == "undefined" || this.data.currentTab === tab) {
|
|
return;
|
|
}
|
|
this.switchTab(tab);
|
|
},
|
|
switchTab: function (tab) {
|
|
return __awaiter(this, void 0, void 0, function () {
|
|
var tabList, currentItem, $tab;
|
|
return __generator(this, function (_a) {
|
|
console.log(tab);
|
|
this.setData({
|
|
currentTab: tab,
|
|
});
|
|
tabList = this.data.tabList;
|
|
currentItem = tabList.find(function (item) { return item.barKey === tab; });
|
|
if (currentItem) {
|
|
wx.setNavigationBarTitle({
|
|
title: currentItem.pageTitle,
|
|
});
|
|
this.setData({
|
|
pageTitle: currentItem.pageTitle,
|
|
});
|
|
$tab = this.selectComponent("#" + tab);
|
|
if ($tab && $tab.refreshData) {
|
|
$tab.refreshData();
|
|
}
|
|
}
|
|
return [2];
|
|
});
|
|
});
|
|
},
|
|
},
|
|
});
|
|
|