Commit 243e7bda by 高淑倩

确认订单地址

parent f1350a3d
......@@ -49,7 +49,6 @@ wxService.page({
},
/**
* 生命周期函数--监听页面显示
*/
......
......@@ -7,7 +7,7 @@ wxService.page({
* 页面的初始数据
*/
data: {
addressInfo: '',
addressInfo: [],
showSelectCoupon: false,
skuIds: [],
trolleySku2Buy: Array,
......@@ -24,8 +24,7 @@ wxService.page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// 地址列表
this.getAddressList()
},
/**
* 生命周期函数--监听页面显示
......@@ -39,11 +38,74 @@ wxService.page({
})
}
this.initCitys()
// 地址列表
this.getAddressList()
},
// 提交
formSubmit(e){
console.log('提交', e)
formSubmit(e) {
const { goodsAddress } = this.data
// 保存地址 && 支付
if (goodsAddress) {
if (!e.detail.value.name) {
wx.showToast({
title: `请输入姓名`,
icon: 'none'
})
return false;
}
if (!e.detail.value.phone) {
wx.showToast({
title: `请输入电话`,
icon: 'none'
})
return false;
}
if (!this.data.cityView) {
wx.showToast({
title: `请选择地区`,
icon: 'none'
})
return false;
}
if (!e.detail.value.address) {
wx.showToast({
title: `请输入详细地址`,
icon: 'none'
})
return false;
}
this.setData({
params: {
userId: memberId,
name: e.detail.value.name,
phone: e.detail.value.phone,
fullArea: this.data.cityView,
address: e.detail.value.address,
type: this.data.isSelect ? 1 : 0
}
})
wx.showLoading({
title: '加载中'
})
wxService.post(`/member/addressManage/save`, this.data.params).then(res => {
const { result } = res.data
if (result == 0) {
wx.hideLoading()
wx.showToast({
title: `保存成功`,
icon: 'none'
})
// 调起支付
this.handelGobuy()
}
})
} else {
// 调起支付
this.handelGobuy()
}
},
initCitys() {
wxService.getC1().then((c1) => {
......@@ -65,8 +127,8 @@ wxService.page({
this.setData({
multiIndex,
cityView
},()=>{
console.log('================0', this.data.cityView,this.data.multiIndex)
}, () => {
console.log('================0', this.data.cityView, this.data.multiIndex)
})
}
},
......@@ -130,9 +192,8 @@ wxService.page({
})
},
handelGobuy() {
this.formSubmit()
const { trolleySku2Buy } = this.data
// this.getBill(trolleySku2Buy) // 下单
this.getBill(trolleySku2Buy) // 下单
},
// 下单
getBill(trolleySku2Buy) {
......@@ -176,6 +237,24 @@ wxService.page({
this.setData({
goodsAddress: true
})
} else {
// 缓存有没有地址
let hasDefalut = wx.getStorageSync('_defalutAddress')
let _defalutAddress = null
if(hasDefalut) {
_defalutAddress = hasDefalut
} else {
data.forEach(item=>{
if(item.type == 1){
_defalutAddress = item
}
})
}
this.setData({
addressInfo: _defalutAddress
})
}
}
}).finally(() => {
......@@ -189,7 +268,6 @@ wxService.page({
this.setData({
goodsAddress: false,
addressInfo: res,
})
},
fail: function (err) {
......
......@@ -35,16 +35,16 @@
<input class="address-input address-detail" name="address" placeholder="请输入路名门牌号" />
</view>
</block>
<block wx:if="{{!goodsAddress}}">
<view class="address-list" bindtap="selectAddress">
<view class="address-info">
<view>
<text class="user-name">{{addressInfo.userName}}</text>
<text class="phone-number">{{addressInfo.telNumber}}</text>
<image class="defalut-add-img" src="{{addressInfo.type == 1 ? '/assets/imgs/7_1_0/08_22/defalut.png' : '/assets/imgs/7_1_0/08_22/no-defalut.png'}}" />
<text class="user-name">{{addressInfo.name}}</text>
<text class="phone-number">{{addressInfo.phone}}</text>
</view>
<view class="address-list-detail">
{{addressInfo.provinceName}} {{addressInfo.cityName}} {{addressInfo.countyName}} {{addressInfo.detailInfo}}
{{addressInfo.fullArea}} {{addressInfo.address}}
</view>
<view class="arrow-right-wrap">
<image class="arrow-right" src="/assets/imgs/7_1_0/arrow-right.png" />
......
/* pages/confirmOrder/confirmOrder.wxss */
@import './../../base/base.wxss';
.defalut-add-img {
width: 84rpx;
height: 33rpx;
border-radius: 16rpx;
/* background-color: rgba(203, 60, 60, 1); */
}
.address-wrap{
padding: 0 30rpx;
}
......
......@@ -24,7 +24,15 @@ wxService.page({
onLoad: function (options) {
},
handelCheckShopAddress(e) {
const index = e.currentTarget.dataset.index
const item = this.data.addressList[index]
wx.setStorageSync('_defalutAddress', item)
setTimeout(() => {
wxService.router().back()
}, 300)
},
/**
* 生命周期函数--监听页面显示
......
......@@ -14,7 +14,9 @@
bindtouchstart="drawStart"
bindtouchmove="drawMove"
bindtouchend="drawEnd"
bindtap='handelCheckShopAddress'
style="right:{{item.right}}rpx"
data-id="{{item.id}}"
data-index="{{index}}"
>
<view class="name">
......@@ -27,7 +29,7 @@
data-type="{{item.type}}"
data-id="{{item.id}}"
>
<view class="{{item.type == 1 ? 'theme-color' : ''}} circle-radio">
<view class="{{item.type == 1 ? 'theme-color' : ''}} circle-radio check-default-address">
<image
wx:if="{{item.type == 1}}"
class="tick-success"
......
......@@ -80,9 +80,11 @@ page{
.tick-success{
width: 18rpx;
}
.default-address{
display: flex;
margin-top: 25rpx;
width: 250rpx;
}
.setting-default{
margin-left: 19rpx;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment