city_card/packagecard/cardList/cardList.js
2023-07-15 14:25:28 +08:00

152 lines
5.0 KiB
JavaScript
Executable File

var e = getApp();
Page({
data: {
imgUrl: e.baseUrls.baseCardUrl,
cardList: [],
currentIndex: 0,
optionsList: [],
isNeedPay: !1,
needPayPrice: 0,
needPayTeamPrice: 0,
curTypeId: "",
isRefreshing: !1,
isRefresh: !1,
isShowCodeInput: !1,
code: "",
contentHeight: e.globalData.windowHeight,
pageType: null,
id: ""
},
onLoad: function(e) {
this.setData({
pageType: e.type,
id: e.id
});
},
onShow: function() {
this.dorefreshList();
},
dorefreshList: function() {
this.setData({
isRefresh: !1,
isRefreshing: !0,
cardList: []
}), this.getPayState();
},
getOptionsList: function() {
var t = this;
wx.showLoading({
title: "加载中..."
}), e.http.get(e.urls.getDictionaryList.format({
dataParentId: "4bf68c60-eac5-480d-b5e1-15203d0282f9"
}), {
header: {
token: e.globalData.token
}
}).then(function(e) {
wx.hideLoading({}), e.data.length > 0 && (t.setData({
optionsList: e.data,
curTypeId: e.data[t.data.currentIndex].dataId
}), t.getList());
}).catch(function(e) {
console.log(e), t.setData({
isRefreshing: !1
});
});
},
getList: function() {
var t = this;
wx.showLoading({
title: "加载中..."
}), e.http.get(e.urls.getCardList, {
header: {
token: e.globalData.token
},
data: {
templateType: t.data.curTypeId,
page: "1",
rows: "2"
}
}).then(function(e) {
wx.hideLoading({}), e.data.forEach(function(e) {
e.picturesTemplateNumber > 1e3 && e.picturesTemplateNumber < 1e4 ? e.number = e.picturesTemplateNumber / 1e3 + "K+" : e.picturesTemplateNumber > 1e4 && e.picturesTemplateNumber < 1e6 ? e.number = e.picturesTemplateNumber / 1e4 + "W+" : e.number = e.picturesTemplateNumber;
}), t.setData({
cardList: e.data,
isRefreshing: !1
});
}).catch(function(e) {
wx.hideLoading({}), t.setData({
isRefreshing: !1
});
});
},
goDetail: function(e) {
var t = e.currentTarget.dataset.id, a = e.currentTarget.dataset.ispay, i = e.currentTarget.dataset.price, n = e.currentTarget.dataset.paystate;
this.data.isNeedPay ? wx.navigateTo({
url: "/packagecard/paypage/paypage?price=" + this.data.needPayPrice + "&teamprice=" + this.data.needPayTeamPrice + "&displayTreaty=1&type=1"
}) : "1" == a ? n ? wx.navigateTo({
url: "../cardDetail/cardDetail?id=" + t + "&type=" + this.data.pageType + "&taskId=" + this.data.id
}) : wx.navigateTo({
url: "/packagecard/paypage/paypage?price=" + i + "&type=2"
}) : wx.navigateTo({
url: "../cardDetail/cardDetail?id=" + t + "&type=" + this.data.pageType + "&taskId=" + this.data.id
});
},
onChange: function(e) {
this.setData({
currentIndex: e.detail.index,
curTypeId: this.data.optionsList[e.detail.index].dataId,
cardList: []
}), this.getList();
},
getPayState: function() {
var t = this;
wx.showLoading({
title: "加载中..."
}), e.http.get(e.urls.getPayState, {
header: {
token: e.globalData.token
}
}).then(function(e) {
wx.hideLoading({}), console.log(e.data), t.setData({
isNeedPay: !1,
needPayPrice: e.data.cardChargePrice,
needPayTeamPrice: e.data.cardChargeDepartmentPrice
}), t.getOptionsList();
}).catch(function(e) {
t.setData({
isRefreshing: !1
});
});
},
onPullDownRefresh: function() {
this.getList();
},
onClose: function(e) {
this.setData({
isShowCodeInput: !1
});
},
inpuWatch: function(e) {
this.setData({
code: e.detail.value
});
},
codeCreate: function(e) {
"" == this.data.code ? wx.showToast({
title: "请输入邀请码",
icon: "none"
}) : wx.navigateTo({
url: "/packagecard/paypage/paypage?price=" + this.data.needPayPrice + "&teamprice=" + this.data.needPayTeamPrice + "&displayTreaty=1&type=1&code=" + this.data.code
});
},
noCodeCreate: function(e) {
wx.navigateTo({
url: "/packagecard/paypage/paypage?price=" + _self.data.needPayPrice + "&teamprice=" + _self.data.needPayTeamPrice + "&displayTreaty=1&type=1"
});
},
loadMore: function() {
console.log("触底了");
}
});