Commit 8cb518a1 by 赵雅纹

Merge branch 'dev_7.1.0' into feature-zyw-sc

parents 53f18953 243e7bda
...@@ -49,7 +49,6 @@ wxService.page({ ...@@ -49,7 +49,6 @@ wxService.page({
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
......
// 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({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
addressInfo: '', addressInfo: [],
showSelectCoupon: false, showSelectCoupon: false,
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) {
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
...@@ -30,12 +37,145 @@ wxService.page({ ...@@ -30,12 +37,145 @@ wxService.page({
this.calPreferentialPrice(trolleySku2Buy) // 计算优惠价 this.calPreferentialPrice(trolleySku2Buy) // 计算优惠价
}) })
} }
this.initCitys()
// 地址列表
this.getAddressList()
}, },
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) => {
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 +207,7 @@ wxService.page({ ...@@ -67,7 +207,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 +225,49 @@ wxService.page({ ...@@ -85,13 +225,49 @@ 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
})
} 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(() => {
})
},
//获取微信地址 //获取微信地址
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">
<form bindsubmit="formSubmit">
<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" name="name" placeholder="请输入收货人姓名" />
<input class="address-input" placeholder="请输入手机号码" /> <input class="address-input" name="phone" 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" name="address" 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> <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="phone-number">{{addressInfo.telNumber}}</text> <text class="user-name">{{addressInfo.name}}</text>
<text class="phone-number">{{addressInfo.phone}}</text>
</view> </view>
<view class="address-list-detail"> <view class="address-list-detail">
{{addressInfo.provinceName}} {{addressInfo.cityName}} {{addressInfo.countyName}} {{addressInfo.detailInfo}} {{addressInfo.fullArea}} {{addressInfo.address}}
</view> </view>
<view class="arrow-right-wrap"> <view class="arrow-right-wrap">
<image class="arrow-right" src="/assets/imgs/7_1_0/arrow-right.png" /> <image class="arrow-right" src="/assets/imgs/7_1_0/arrow-right.png" />
...@@ -135,8 +149,14 @@ ...@@ -135,8 +149,14 @@
<text class="cost-label">实付款:</text> <text class="cost-label">实付款:</text>
<text class="cost-price">¥306</text> <text class="cost-price">¥306</text>
</view> </view>
<view class="theme-color buy-btn" bindtap="handelGobuy">立即购买</view> <!-- <button form-type="submit" class="theme-color buy-btn">立即购买</button>-->
<!-- <view class="theme-color buy-btn" bindtap="handelGobuy">立即购买</view> -->
<view class="theme-color buy-btn">
<button form-type="submit" style="display: inline;" class="theme-color buy-btn">立即购买</button>
</view>
</view> </view>
</form>
</view> </view>
<!--goHome--> <!--goHome-->
<go-home/> <go-home/>
......
/* pages/confirmOrder/confirmOrder.wxss */ /* 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{ .address-wrap{
padding: 0 30rpx; padding: 0 30rpx;
} }
...@@ -13,7 +20,7 @@ ...@@ -13,7 +20,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 +30,7 @@ ...@@ -23,6 +30,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;
......
...@@ -24,7 +24,15 @@ wxService.page({ ...@@ -24,7 +24,15 @@ wxService.page({
onLoad: function (options) { 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 @@ ...@@ -14,7 +14,9 @@
bindtouchstart="drawStart" bindtouchstart="drawStart"
bindtouchmove="drawMove" bindtouchmove="drawMove"
bindtouchend="drawEnd" bindtouchend="drawEnd"
bindtap='handelCheckShopAddress'
style="right:{{item.right}}rpx" style="right:{{item.right}}rpx"
data-id="{{item.id}}"
data-index="{{index}}" data-index="{{index}}"
> >
<view class="name"> <view class="name">
...@@ -27,7 +29,7 @@ ...@@ -27,7 +29,7 @@
data-type="{{item.type}}" data-type="{{item.type}}"
data-id="{{item.id}}" 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 <image
wx:if="{{item.type == 1}}" wx:if="{{item.type == 1}}"
class="tick-success" class="tick-success"
......
...@@ -80,9 +80,11 @@ page{ ...@@ -80,9 +80,11 @@ page{
.tick-success{ .tick-success{
width: 18rpx; width: 18rpx;
} }
.default-address{ .default-address{
display: flex; display: flex;
margin-top: 25rpx; margin-top: 25rpx;
width: 250rpx;
} }
.setting-default{ .setting-default{
margin-left: 19rpx; margin-left: 19rpx;
......
...@@ -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