120 lines
2.3 KiB
JavaScript
120 lines
2.3 KiB
JavaScript
// user/balance/balance.js
|
|
const app = getApp();
|
|
const util = app.loadUtils("util")
|
|
const regeneratorRuntime = app.loadAsync()
|
|
const model = app.loadModel("index")
|
|
const http = app.loadHttp()
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
system: app.globalData.system, //设备相关信息
|
|
pageTitle: "我的余额", //头部标题
|
|
isBack: true,//显示返回
|
|
current_scroll: 1,//tab选中
|
|
cardData: [],//卡列表
|
|
userInfo: {},//用户信息
|
|
},
|
|
// tab切换
|
|
handleChangeScroll({ detail }) {
|
|
this.setData({
|
|
current_scroll: detail.key
|
|
});
|
|
this.getUserCard()
|
|
},
|
|
// 获取卡劵列表
|
|
async getUserCard() {
|
|
let res = await http.http.request2({ url: `${http.api.getCard}`, method: "POST", data: { type: this.data.current_scroll } })
|
|
let rel = res.data.data
|
|
if (res.data.status == 1) {
|
|
rel.map((v, i) => {
|
|
rel[i].create_time = v.create_time.slice(0, 10)
|
|
})
|
|
this.setData({
|
|
cardData: rel
|
|
})
|
|
}
|
|
if (rel.length <= 0) {
|
|
wx.showToast({
|
|
title: '无此会员卡',
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
}
|
|
},
|
|
// 跳转页面方法
|
|
goUrl(e) {
|
|
let url = e.currentTarget.dataset.url
|
|
let index = this.data.current_scroll
|
|
wx.navigateTo({
|
|
url: `${url}?index=${index}`
|
|
})
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
if (options['index']) {
|
|
this.setData({
|
|
current_scroll: options.index
|
|
})
|
|
}
|
|
this.getUserCard()
|
|
app.setWatching('userInfo', (v) => {
|
|
this.setData({
|
|
userInfo: v
|
|
});
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
}) |