// pages/orderDetail/orderDetail.js const app = getApp() import Order from '../../api/order' Page({ /** * 页面的初始数据 */ data: { nextPage: 1, companyName: "康道" }, /** * 生命周期函数--监听页面加载 */ onLoad: async function (options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: async function () { await app.wxLogin({"type":"slince"}) const userInfo = await app.getWxUserInfo() this.setData({ userInfo }) if (!userInfo.mobile) { return } await this.couponList('init') }, async couponList(type) { const self = this if (type === "init") { self.setData({ nextPage: 1 }) } const data = { phone: this.data.userInfo.mobile, nextPage: self.data.nextPage, pageSize: 10 } const rs = await Order.couponList(data) if (type == "pull") { const data = self.data.list.concat(rs.records) self.setData({ list: data, maxPage: rs.totalPage }) }else { self.setData({ list: rs.records, // list: [], maxPage: rs.totalPage }) } }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { let page = this.data.nextPage let maxPage = this.data.maxPage if (page >= maxPage) { wx.showToast({ title: '亲,到底了哦!', // 内容 }); return } this.setData({ nextPage: page + 1 }) this.couponList('pull') }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, jumpBuy (e) { const sn = e.currentTarget.dataset.sn const name = e.currentTarget.dataset.name const status = e.currentTarget.dataset.status if (status == 2 || status == 3) { return } wx.navigateTo({ url: `/pages/qrCode/qrCode?sn=${sn}&name=${name}`, }) }, getMobile: async function (params) { console.log(params); let _self = this const data = { encryptedData:params.detail.encryptedData, iv: params.detail.iv } const userInfo = await app.getPhoneNumber(data) console.log(userInfo) let hasMobile = false if (userInfo.mobile > 1) { hasMobile:true } _self.setData({ hasMobile: hasMobile, mobile: userInfo.mobile, userInfo }) _self.couponList('init') }, })