You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

103 lines
1.8 KiB

// pages/order/coupon/index.js
import commonApi from "../../../utils/https/common";
import util from "../../../utils/util";
let app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
list:[],
moreFlag:true
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getList(options)
},
getList:function(options){
if(!this.data.moreFlag) return
commonApi.user_post('coupon/use_coupon_list',{
money:options.money,
sku_ids:options.sku
}).then(res=>{
res.data.map(item=>{
item.selected = false;
})
this.setData({
list:res.data
})
})
},
selectIt:function(e){
wx.showLoading({
title: '加载中'
})
let list = this.data.list,index = e.currentTarget.dataset.index;
list.map((item,i)=>{
if(i!=index) {
item.selected = false;
}
})
list[index].selected = list[index].selected?false:true;
this.setData({
list:list
})
wx.hideLoading()
},
submit:function(){
let list = this.data.list,coupon = null;
list.map(item=>{
if(item.selected){
coupon = item;
}
})
console.log(coupon)
app.globalData.couponInfo = coupon;
util.back()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
app.globalData.couponInfo = null;
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
}
})