123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- // 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')
- },
- })
|