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.
|
|
|
|
// pages/order/components/coupon/index.js
|
|
|
|
|
import commonApi from "../../../../utils/https/common"
|
|
|
|
|
let app = getApp()
|
|
|
|
|
Component({
|
|
|
|
|
/**
|
|
|
|
|
* 组件的属性列表
|
|
|
|
|
*/
|
|
|
|
|
properties: {
|
|
|
|
|
money:{
|
|
|
|
|
type:String,
|
|
|
|
|
value:"0"
|
|
|
|
|
},
|
|
|
|
|
sku:{
|
|
|
|
|
type:String,
|
|
|
|
|
value:""
|
|
|
|
|
},
|
|
|
|
|
couponFlag:{
|
|
|
|
|
type:Boolean,
|
|
|
|
|
value:false,
|
|
|
|
|
observer(nv, ov) {
|
|
|
|
|
console.log(nv,ov)
|
|
|
|
|
if (nv) {
|
|
|
|
|
app.globalData.couponInfo = null
|
|
|
|
|
this.setData({
|
|
|
|
|
coupon:null
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 组件的初始数据
|
|
|
|
|
*/
|
|
|
|
|
data: {
|
|
|
|
|
coupon:null
|
|
|
|
|
},
|
|
|
|
|
pageLifetimes: {
|
|
|
|
|
show: function() {
|
|
|
|
|
this.getMaxCoupon()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
lifetimes:{
|
|
|
|
|
attached(){
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 组件的方法列表
|
|
|
|
|
*/
|
|
|
|
|
methods: {
|
|
|
|
|
setNullCoupon:function(){
|
|
|
|
|
app.globalData.couponInfo = null
|
|
|
|
|
this.setData({
|
|
|
|
|
coupon:null
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getMaxCoupon(){
|
|
|
|
|
// console.log(app.globalData.couponInfo);
|
|
|
|
|
console.log(this.data.coupon);
|
|
|
|
|
if (app.globalData.couponInfo===false) {
|
|
|
|
|
this.setData({
|
|
|
|
|
coupon:null
|
|
|
|
|
})
|
|
|
|
|
this.triggerEvent('getNewCoupon',null);
|
|
|
|
|
}else{
|
|
|
|
|
commonApi.user_post('coupon/use_max_coupon_list',{
|
|
|
|
|
money:this.data.money,
|
|
|
|
|
sku_ids:this.data.sku
|
|
|
|
|
}).then(res=>{
|
|
|
|
|
if (app.globalData.couponInfo&&app.globalData.couponInfo.hasOwnProperty('SubCoupon')) {
|
|
|
|
|
this.setData({
|
|
|
|
|
coupon:app.globalData.couponInfo
|
|
|
|
|
})
|
|
|
|
|
this.triggerEvent('getNewCoupon',app.globalData.couponInfo);
|
|
|
|
|
console.log("我用的原来的数据");
|
|
|
|
|
}else{
|
|
|
|
|
console.log("我用的新的数据");
|
|
|
|
|
console.log('123123132',res.data);
|
|
|
|
|
if ( Object.keys(res.data).length!=0) {
|
|
|
|
|
app.globalData.couponInfo = res.data
|
|
|
|
|
this.setData({
|
|
|
|
|
coupon:res.data
|
|
|
|
|
})
|
|
|
|
|
console.log(this.data.coupon);
|
|
|
|
|
this.triggerEvent('getNewCoupon',res.data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
})
|