import common from '../../utils/util'; import server from '../../utils/main'; const app = getApp(); Page({ data: { PayList: null, IsShowActivty: false, }, onLoad: function (options) { //测试***************** // if (!app.globalData.userInfo) // app.globalData.userInfo = { UserID: 4 }; var UnloadType = ""; if (options && options.type) UnloadType = options.type; this.setData({ Height: common.getSystemHeight(), UnloadType: UnloadType, }); this.init(); }, onUnload: function () { if (this.data.UnloadType == "finished") { wx.reLaunch({ url: '../main/index' }); } }, init: function () { var that = this; server.getData('GetWXUsersAllPayInfo?UserID=' + app.globalData.userInfo.UserID + "&ProductID=" + app.globalData.ProgramID, function (data) { if (data) { var isShowActivty = false; for (var i = 0; i < data.length; i++) { for (var j = 0; j < data[i].List.length; j++) { data[i].List[j].isShowActivty = false; if (data[i].List[j].Status == 0) { data[i].List[j].isShowActivty = true; isShowActivty = true; } } } that.setData({ PayList: data, IsShowActivty: isShowActivty, }); if (isShowActivty) wx.setStorageSync("IsShowActivty", isShowActivty); else wx.removeStorageSync("IsShowActivty"); } else { that.setData({ PayList: [], }); } }); }, gotoActive: function (e) { var that = this; var productid = e.currentTarget.dataset.productid; var list = server.getProgramList(); for (var i = 0; i < list.length; i++) { if (productid == list[i].ID) { var path = list[i].path; path += "&ProductBuyInfoID=" + e.currentTarget.dataset.id; path += "&ProductID=" + app.globalData.ProgramID; path += "&ProductUserID=" + app.globalData.userInfo.UserID; path += "&BuyType=" + e.currentTarget.dataset.buytype; wx.navigateToMiniProgram({ appId: list[i].appId, path: path, success(res) { } }); var data = this.data.PayList; for (var i = 0; i < data.length; i++) { for (var j = 0; j < data[i].List.length; j++) { if (data[i].List[j].ProductID == productid) { data[i].List[j].isShowActivty = false; } } } that.setData({ PayList: data, }); break; } } }, gotoFeedback: function () { server.gotoFeedback(); }, refresh: function () { var that = this; wx.showLoading({ title: '加载中', }); setTimeout(function () { wx.hideLoading(); that.init(); }, 1000); }, onShareAppMessage: function () { return { title: app.globalData.ShareTitle, path: 'pages/index/index?UserID=' + app.globalData.userInfo.UserID, imageUrl: '../../images/07001.png', } }, })