Commit 525941af by 高淑倩

地址

parent 6f742c2d
// pages/confirmOrder/confirmOrder.js // pages/confirmOrder/confirmOrder.js
const wxService = require('../../utils/wxService') const wxService = require('../../utils/wxService')
const { memberId } = wx.getStorageSync('_baseUserInfo')
wxService.page({ wxService.page({
/** /**
...@@ -11,13 +12,20 @@ wxService.page({ ...@@ -11,13 +12,20 @@ wxService.page({
skuIds: [], skuIds: [],
trolleySku2Buy: Array, trolleySku2Buy: Array,
currentOrderList: Array, currentOrderList: Array,
isSelect: false isSelect: false,
goodsAddress: false,
citys: null,
cityView: '',
multiIndex: [0, 0, 0],
selectCityName: ['', '']
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
// 地址列表
this.getAddressList()
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
...@@ -30,12 +38,78 @@ wxService.page({ ...@@ -30,12 +38,78 @@ wxService.page({
this.calPreferentialPrice(trolleySku2Buy) // 计算优惠价 this.calPreferentialPrice(trolleySku2Buy) // 计算优惠价
}) })
} }
this.initCitys()
},
initCitys() {
wxService.getC1().then((c1) => {
return wxService.Promise.all([wxService.Promise.resolve(c1), wxService.getC2ByC1('北京'), wxService.getC3ByC2('北京北京市')])
}).then(res => {
const citys = res.map(item => {
return [...item]
})
this.setData({
citys
})
})
}, },
bindMultiPickerChange(e) {
const citys = this.data.citys
const multiIndex = e.detail.value
if (citys) {
const cityView = [citys[0][multiIndex[0]], citys[1][multiIndex[1]], citys[2][multiIndex[2]]].join(' ')
this.setData({
multiIndex,
cityView
},()=>{
console.log('================0', this.data.cityView,this.data.multiIndex)
})
}
},
bindMultiPickerColumnChange(e) {
const detail = e.detail
const index = detail.value
let cityName = ''
switch (detail.column) {
case 0:
cityName = this.data.citys[0][index]
this.data.selectCityName[0] = cityName
wxService.getC2ByC1(cityName)
.then(item => {
let c2 = [...item]
this.data.selectCityName[1] = c2[0]
return wxService.Promise.all([wxService.Promise.resolve(item), wxService.getC3ByC2(this.data.selectCityName.join(''))])
}).then((res) => {
this.setData({
'citys[1]': [...res[0]],
'citys[2]': [...res[1]]
})
})
break
case 1:
cityName = this.data.citys[1][index]
this.data.selectCityName[1] = cityName
wxService.getC3ByC2(this.data.selectCityName.join(''))
.then(item => {
this.setData({
'citys[2]': [...item]
})
})
break
default:
break
}
},
handelChangeSelectVip() { handelChangeSelectVip() {
this.setData({ this.setData({
isSelect: !this.data.isSelect isSelect: !this.data.isSelect
}) })
}, },
// 默认地址
selectAddress() {
wxService.router('/pages/myAddress/myAddress')
},
// 计算优惠价 // 计算优惠价
calPreferentialPrice(trolleySku2Buy) { calPreferentialPrice(trolleySku2Buy) {
wx.showLoading({ wx.showLoading({
...@@ -67,7 +141,7 @@ wxService.page({ ...@@ -67,7 +141,7 @@ wxService.page({
delete data.appId delete data.appId
wx.requestPayment(Object.assign({ wx.requestPayment(Object.assign({
success(res) { success(res) {
console.log('000000',res) console.log('000000', res)
wx.hideLoading() wx.hideLoading()
// 支付成功页面 // 支付成功页面
wxService.router('/subPackage/page/pages/paymentStatus/paymentStatus') wxService.router('/subPackage/page/pages/paymentStatus/paymentStatus')
...@@ -85,13 +159,32 @@ wxService.page({ ...@@ -85,13 +159,32 @@ wxService.page({
} }
}) })
}, },
// 获取地址列表
getAddressList() {
wxService.post(`/member/addressManage/getall`, {
userId: memberId
}).then(res => {
if (!res) return false
const { result, data } = res.data
if (result == 0) {
if (!data.length) {
this.setData({
goodsAddress: true
})
}
}
}).finally(() => {
})
},
//获取微信地址 //获取微信地址
chooseWxAddress() { chooseWxAddress() {
wx.chooseAddress({ wx.chooseAddress({
success: (res) => { success: (res) => {
console.log(res) console.log('微信地址', res)
this.setData({ this.setData({
addressInfo: res goodsAddress: false,
addressInfo: res,
}) })
}, },
fail: function (err) { fail: function (err) {
......
<!--pages/confirmOrder/confirmOrder.wxml--> <!--pages/confirmOrder/confirmOrder.wxml-->
<view class="page-confirm-order"> <view class="page-confirm-order">
<view class="address-wrap"> <view class="address-wrap">
<block wx:if="{{false}}"> <block wx:if="{{goodsAddress}}">
<view class="address-section"> <view class="address-section">
<input class="address-input" placeholder="请输入收货人姓名" /> <input class="address-input" placeholder="请输入收货人姓名" />
<input class="address-input" placeholder="请输入手机号码" /> <input class="address-input" placeholder="请输入手机号码" />
</view> </view>
<view class="address-section"> <view class="address-section">
<!-- <view class="">所在区域</view> -->
<picker <picker
class="address-input address-picker" class="address-input address-picker"
mode="region" mode="multiSelector"
bindchange="bindRegionChange" bindchange="bindMultiPickerChange"
value="{{region}}" bindcolumnchange="bindMultiPickerColumnChange"
custom-item="{{customItem}}" value="{{multiIndex}}"
range="{{citys}}"
> >
<view class="picker-choose" /> <view class="form-picker" style="padding-top: 8rpx;" wx:if="{{cityView}}">
{{cityView}}
</view>
<view wx:if="{{!cityView}}">
<input
class='form-input'
placeholder-class="placeholder-picker"
style="padding-top: 8rpx;"
type="text"
disabled
placeholder="所在区域"
/>
</view>
</picker> </picker>
</view> </view>
<view class="address-section"> <view class="address-section">
<input class="address-input address-detail" placeholder="请输入路名门牌号" /> <input class="address-input address-detail" placeholder="请输入路名门牌号" />
</view> </view>
</block> </block>
<block> <block wx:if="{{!goodsAddress}}">
<view class="address-list"> <view class="address-list" bindtap="selectAddress">
<view class="address-info"> <view class="address-info">
<view> <view>
<text class="user-name">{{addressInfo.userName}}</text> <text class="user-name">{{addressInfo.userName}}</text>
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
background-color: rgba(238, 238, 238, 1); background-color: rgba(238, 238, 238, 1);
opacity: 0.5; opacity: 0.5;
padding: 0 20rpx; padding: 0 20rpx;
color: rgba(0, 0, 0, 0.25); color: #000;
font-size: 28rpx; font-size: 28rpx;
margin-bottom: 18rpx; margin-bottom: 18rpx;
} }
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
.address-picker{ .address-picker{
flex: 1; flex: 1;
} }
.picker-choose{ .picker-choose{
color: rgba(0, 0, 0, 0.25); color: rgba(0, 0, 0, 0.25);
font-size: 28rpx; font-size: 28rpx;
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
"list": [] "list": []
}, },
"miniprogram": { "miniprogram": {
"current": 16, "current": 17,
"list": [ "list": [
{ {
"id": -1, "id": -1,
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
"id": 17, "id": 17,
"name": "确认订单", "name": "确认订单",
"pathName": "pages/confirmOrder/confirmOrder", "pathName": "pages/confirmOrder/confirmOrder",
"query": "trolleySku2Buy=[{\"count\":3,\"skuId\":1556108807316001},{\"count\":1,\"skuId\":1556108807316000}]", "query": "trolleySku2Buy=[{\"count\":1,\"skuId\":2000704}]",
"scene": null "scene": null
}, },
{ {
......
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