[订单拆分,周五福利添加配送方式]
This commit is contained in:
@@ -4,14 +4,21 @@ Page({
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
address : '', //默认收货地址
|
||||
allAddress : '', //收货地址列表
|
||||
addressShow : false, //收货地址显示
|
||||
noticeShow : false, //须知显示状态
|
||||
pointMoreShow : false, //重要提示显示状态
|
||||
isdeliver : -1,
|
||||
groupId : '', //权益id
|
||||
contData : '', //全局内容
|
||||
rightData : '', //权益详情
|
||||
content : '', //内容介绍
|
||||
notification : '', //重要提示
|
||||
remark : '', //使用须知
|
||||
platformCp : [], //选择提交数组
|
||||
platIndex : 0, //选择提交方式下标
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -36,11 +43,31 @@ Page({
|
||||
*/
|
||||
rightsInfo() {
|
||||
wx.$api.index.welfares(this.data.groupId).then(res=>{
|
||||
let obj = res.data.detail.right.express
|
||||
let defGet = res.data.detail.right.def_get
|
||||
let arr = new Array
|
||||
|
||||
arr = Object.keys(obj).map(val=>{
|
||||
return { ...obj[val], ...{key: val} }
|
||||
})
|
||||
|
||||
if(this.data.isdeliver == -1){
|
||||
if(res.data.detail.right.type == 'physical') {
|
||||
this.setData({
|
||||
isdeliver : res.data.detail.right.def_get
|
||||
})
|
||||
}
|
||||
if(res.data.detail.right.type == 'virtual') this.setData({isdeliver : 1})
|
||||
}
|
||||
|
||||
this.setData({
|
||||
contData : res.data,
|
||||
rightData : res.data.right,
|
||||
remark : res.data.remark.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;"'),
|
||||
content : res.data.content.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;"')
|
||||
address : res.data.address,
|
||||
allAddress : res.data.all_address,
|
||||
contData : res.data.detail,
|
||||
platformCp : arr,
|
||||
rightData : res.data.detail.right,
|
||||
remark : res.data.detail.remark.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;"'),
|
||||
content : res.data.detail.content.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;"')
|
||||
})
|
||||
}).catch(err=>{
|
||||
if(!err.login){
|
||||
@@ -88,12 +115,69 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 选择提交方式
|
||||
*/
|
||||
platBind(e) {
|
||||
this.setData({
|
||||
platIndex : e.detail.value,
|
||||
isdeliver : this.data.platformCp[e.detail.value].value
|
||||
})
|
||||
// 获取详情
|
||||
this.rightsInfo()
|
||||
},
|
||||
|
||||
/**
|
||||
* 收货地址收起
|
||||
*/
|
||||
addressTap() {
|
||||
this.setData({
|
||||
addressShow : !this.data.addressShow
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 选择收货地址
|
||||
*/
|
||||
selectAddress(e){
|
||||
let new_addressId = e.currentTarget.dataset.id,
|
||||
addressId = this.data.address.id
|
||||
if (new_addressId != addressId) {
|
||||
this.setData({
|
||||
address : e.currentTarget.dataset.index,
|
||||
addressShow : false
|
||||
})
|
||||
}else{
|
||||
this.setData({
|
||||
addressShow : false
|
||||
})
|
||||
}
|
||||
|
||||
// 获取详情
|
||||
this.rightsInfo()
|
||||
},
|
||||
|
||||
/**
|
||||
* 新增收货地址
|
||||
*/
|
||||
addSelect() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/address/address?type=selectAddress'
|
||||
})
|
||||
this.setData({
|
||||
addressShow : false
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 支付提交
|
||||
*/
|
||||
submitOrder() {
|
||||
let welfareId = this.data.contData.welfare_id
|
||||
wx.$api.index.fridayInfo(welfareId).then(res=>{
|
||||
let welfareId = this.data.contData.welfare_id,
|
||||
address_id = this.data.address.id,
|
||||
is_deliver = this.data.isdeliver
|
||||
|
||||
wx.$api.index.fridayInfo(welfareId, address_id, is_deliver).then(res=>{
|
||||
wx.$api.index.fridayPay(res.data.trade_no).then(res=>{
|
||||
let payInfo = JSON.parse(res.data)
|
||||
wx.requestPayment({
|
||||
@@ -109,16 +193,28 @@ Page({
|
||||
icon : 'success'
|
||||
})
|
||||
setTimeout(()=>{
|
||||
wx.reLaunch({
|
||||
url: '/pages/coupon/coupon?type=couponPublic'
|
||||
})
|
||||
if(this.data.isdeliver == 1) {
|
||||
wx.reLaunch({
|
||||
url: '/pages/order/order?orderType=welfareGoods'
|
||||
})
|
||||
} else {
|
||||
wx.reLaunch({
|
||||
url: '/pages/order/order?orderType=welfare'
|
||||
})
|
||||
}
|
||||
},3000)
|
||||
}
|
||||
},
|
||||
fail : res=>{
|
||||
wx.reLaunch({
|
||||
url: '/pages/order/order?stateType=unpay'
|
||||
})
|
||||
if(this.data.isdeliver == 1) {
|
||||
wx.reLaunch({
|
||||
url: '/pages/order/order?orderType=welfareGoods&stateType=unpay'
|
||||
})
|
||||
} else {
|
||||
wx.reLaunch({
|
||||
url: '/pages/order/order?orderType=welfare&stateType=unpay'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user