[订单拆分,周五福利添加配送方式]
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'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -51,6 +51,34 @@
|
||||
<view class="rightsLabel-left">{{contData.attribute.form_type}}</view>
|
||||
<view class="rightsLabel-right rightsLabel-red">¥{{contData.score}}</view>
|
||||
</view>
|
||||
<block wx:if="{{rightData.type == 'physical'}}">
|
||||
<view class="rightsLabel">
|
||||
<view class="rightsLabel-left">请选择提交方式</view>
|
||||
<view class="rightsLabel-right rightsLabel-range">
|
||||
<picker range="{{platformCp}}" range-key="name" bindchange="platBind">
|
||||
<view class="tabs-text">
|
||||
{{platformCp[platIndex].name}}
|
||||
</view>
|
||||
</picker>
|
||||
<image class="rightsLabel-row" src="/static/icon/rightsArrow.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view class="rightsLabel rightsLabel-address" wx:if="{{platformCp[platIndex].name == '快递'}}">
|
||||
<view class="rightsLabel-left">收货地址</view>
|
||||
<block wx:if="{{address != ''}}">
|
||||
<view class="rightsLabel-right" bindtap="addressTap">
|
||||
<text class="nowrap">{{address.all_address}}</text>
|
||||
<image class="rightsLabel-row" src="/static/icon/rightsArrow.png"></image>
|
||||
</view>
|
||||
</block>
|
||||
<block wx:else>
|
||||
<navigator class="rightsLabel-right" hover-class="none"
|
||||
url="/pages/address_form/address_form?type=Add">
|
||||
添加收货地址<image class="rightsLabel-row" src="/static/icon/rightsArrow.png"></image>
|
||||
</navigator>
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<!-- 应付总金额 -->
|
||||
@@ -85,4 +113,26 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 选择收货地址 -->
|
||||
<view class="addressBack {{addressShow ? 'active':''}}" bindtap="addressTap"></view>
|
||||
<view class="addressCont {{addressShow ? 'active':''}}">
|
||||
<view class="addressCont-title uni-border-bottom">
|
||||
<view class="addressCont-left">请选择收货地址</view>
|
||||
<view class="addressCont-right" bindtap="addSelect">新增收货地址</view>
|
||||
</view>
|
||||
<scroll-view class="header-classify" scroll-y="true">
|
||||
<view class="addressCont-list uni-border-bottom" wx:for="{{allAddress}}" wx:key="allAddress"
|
||||
bindtap="selectAddress" data-id="{{item.id}}" data-index="{{item}}">
|
||||
<view class="addressCont-top">
|
||||
<view class="addressCont-name">{{item.name}}</view>
|
||||
<view class="addressCont-tel">{{item.mobile}}</view>
|
||||
</view>
|
||||
<view class="addressCont-text">
|
||||
{{item.all_address}}
|
||||
</view>
|
||||
<view class="address-tool-icon">选择地址</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
Reference in New Issue
Block a user