Commit fb3509e3 by 谢中龙

提交订单地址相关优化

parent 13836622
...@@ -47,7 +47,7 @@ App({ ...@@ -47,7 +47,7 @@ App({
updateManager.onCheckForUpdate(function (res) { updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调 // 请求完新版本信息的回调
console.log(res.hasUpdate) console.log('请求完新版本信息的回调 ---',res.hasUpdate)
}); });
updateManager.onUpdateReady(function () { updateManager.onUpdateReady(function () {
......
...@@ -12,7 +12,7 @@ const PROJECT_ENV = 'prod' // 生产 prod, 开发 dev, 测试 test, 预生产 pr ...@@ -12,7 +12,7 @@ const PROJECT_ENV = 'prod' // 生产 prod, 开发 dev, 测试 test, 预生产 pr
//泰华 2006 , //泰华 2006 ,
//多多一上 2007 , //多多一上 2007 ,
//雪岛书屋 2008 //雪岛书屋 2008
//苏州邻里 2006 //苏州邻里 2003
const BRANCH_ID = 3001 const BRANCH_ID = 3001
const isMall = true const isMall = true
......
...@@ -43,7 +43,8 @@ wxService.page({ ...@@ -43,7 +43,8 @@ wxService.page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
wx.hideShareMenu() wx.hideShareMenu();
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
...@@ -428,6 +429,7 @@ wxService.page({ ...@@ -428,6 +429,7 @@ wxService.page({
} }
}) })
}, },
handelGobuy() { handelGobuy() {
// 第一项 defalutCouponId couponId/ // 第一项 defalutCouponId couponId/
const { const {
...@@ -516,77 +518,73 @@ wxService.page({ ...@@ -516,77 +518,73 @@ wxService.page({
}, },
// 获取地址列表 // 获取地址列表
getAddressList() { getAddressList() {
const { memberId } = wx.getStorageSync('_baseUserInfo') const { memberId } = wx.getStorageSync('_baseUserInfo');
const { trolleySku2Buy, checkByPremium } = this.data;
let params = {checkByPremium, trolleySku2Buy};
wxService.post(`/member/addressManage/getall`, { wxService.post(`/member/addressManage/getall`, {
userId: memberId userId: memberId
}).then(res => { }).then(res => {
if (!res) return false if (!res) return false;
const { result, data } = res.data let hasDefalut = wx.getStorageSync('_defalutAddress');
let { result, data } = res.data
if (result == 0) { if (result == 0) {
if (!data.length) { //看看本地是不是有已经选择的地址了
wx.removeStorageSync('_defalutAddress'); if (!hasDefalut){ // 无
this.data.addressId = ''; //看一下地址列表中是不是有默认地址
this.data.addressInfo = null; let defaultInAddressList = null;
this.setData({ data = data ? data : [];
goodsAddress: true data.forEach(item => {
item.fullArea = item.province + ' ' + item.city + ' ' + item.district
if (item.type == 1) {
defaultInAddressList = item
}
}); });
const { trolleySku2Buy, checkByPremium, addressId, addressInfo } = this.data
let params = { if (defaultInAddressList){
checkByPremium, this.data.addressId = defaultInAddressList ? defaultInAddressList.id : '';
trolleySku2Buy, this.data.addressInfo = defaultInAddressList;
params.addressId = this.data.addressId;
} }
this.calPreferentialPrice(params) // 计算优惠价
} this.setData({
else { addressInfo: this.data.addressInfo,
// 缓存有没有地址 addressId: this.data.addressId,
let hasDefalut = wx.getStorageSync('_defalutAddress') goodsAddress: params.addressId ? false : true,
let _defalutAddress = null });
//有默认地址 但是需要判断当前缓存的默认地址在地址列表中还是否存在 如果不存在则删除 存在则使用 }
if (hasDefalut){ else{ // 有已经选择的地址了
let id = hasDefalut.id; let defaultInAddressList = null;
let filterArr = data.filter(item => item.id == id); //判断地址列表中是不是已经把这个地址删除了
if(filterArr.length > 0){ let id = hasDefalut.id;
_defalutAddress = hasDefalut let filterArr = data.filter(item => item.id == id);
} if (filterArr.length > 0) {
else{ defaultInAddressList = hasDefalut
//移除地址
wx.removeStorageSync('_defalutAddress');
this.setData({
goodsAddress: true
});
const { trolleySku2Buy, checkByPremium} = this.data;
let params = {
checkByPremium,
trolleySku2Buy,
}
this.calPreferentialPrice(params)
}
} }
else{ else{ // 无
//此时已经没有 看看是不是有默认地址 有则默认选中
data = data ? data : [];
data.forEach(item => { data.forEach(item => {
item.fullArea = item.province + ' ' + item.city + ' ' + item.district item.fullArea = item.province + ' ' + item.city + ' ' + item.district
if (item.type == 1) { if (item.type == 1) {
_defalutAddress = item defaultInAddressList = item
} }
}) });
} }
this.data.addressId = _defalutAddress ? _defalutAddress.id : ''; if (defaultInAddressList) {
this.setData({ this.data.addressId = defaultInAddressList ? defaultInAddressList.id : '';
addressInfo: _defalutAddress, this.data.addressInfo = defaultInAddressList;
addressId: this.data.addressId params.addressId = this.data.addressId;
}, () => { }
// preview
const { trolleySku2Buy, checkByPremium, addressId, addressInfo } = this.data
let params = {
checkByPremium,
trolleySku2Buy,
addressId: addressId ? addressId : addressInfo.id // 微信地址 or 地址id
}
this.calPreferentialPrice(params) // 计算优惠价 this.setData({
}) addressInfo: this.data.addressInfo,
addressId: this.data.addressId,
goodsAddress: params.addressId ? false : true,
});
} }
this.calPreferentialPrice(params)
} }
}).finally(() => { }).finally(() => {
}) })
...@@ -614,22 +612,29 @@ wxService.page({ ...@@ -614,22 +612,29 @@ wxService.page({
address: res.detailInfo, address: res.detailInfo,
type: 0 type: 0
} }
}) });
wxService.post(`/member/addressManage/save`, this.data.params).then(res => { wxService.post(`/member/addressManage/save`, this.data.params).then(res => {
const { result, data } = res.data const { result, data } = res.data
if (result == 0) { if (result == 0) {
wx.hideLoading() wx.hideLoading();
this.data.addressInfo.fullArea = this.data.addressInfo.provinceName + ' ' +
this.data.addressInfo.cityName + ' ' + this.data.addressInfo.countyName
this.data.addressInfo.id = data;
wx.setStorageSync('_defalutAddress', this.data.addressInfo)
this.setData({ this.setData({
addressId: data addressId: data,
goodsAddress: true,
},() => {
this.getAddressList();
}) })
} }
}).finally(() => { }).finally(() => {
wx.hideLoading() wx.hideLoading()
}) })
this.data.addressInfo.fullArea = this.data.addressInfo.provinceName + ' ' +
this.data.addressInfo.cityName + ' ' + this.data.addressInfo.countyName
wx.setStorageSync('_defalutAddress', this.data.addressInfo)
}, },
fail: function (err) { fail: function (err) {
console.log(err) console.log(err)
......
...@@ -101,6 +101,12 @@ wxService.page({ ...@@ -101,6 +101,12 @@ wxService.page({
wx.showLoading({ wx.showLoading({
title: '加载中' title: '加载中'
}) })
const { memberId } = wx.getStorageSync('_baseUserInfo')
if (!memberId) {
return;
}
const params = { const params = {
pageNo: this.data.pageNo, pageNo: this.data.pageNo,
pageSize: this.data.pageSize pageSize: this.data.pageSize
......
...@@ -104,7 +104,6 @@ wxService.page({ ...@@ -104,7 +104,6 @@ wxService.page({
if (result == 0) { if (result == 0) {
this.getAddressList() this.getAddressList()
} }
}).finally(() => { }).finally(() => {
}) })
} }
...@@ -112,7 +111,6 @@ wxService.page({ ...@@ -112,7 +111,6 @@ wxService.page({
drawStart: function (e) { drawStart: function (e) {
var touch = e.touches[0] var touch = e.touches[0]
for (var index in this.data.addressList) { for (var index in this.data.addressList) {
var item = this.data.addressList[index] var item = this.data.addressList[index]
item.right = 0 item.right = 0
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<view class="address-detail">{{item.province}} {{item.city}} {{item.district}} {{item.address}}</view> <view class="address-detail">{{item.province}} {{item.city}} {{item.district}} {{item.address}}</view>
<view <view
class="default-address" class="default-address"
bindtap="settingDefalutAddress" catchtap="settingDefalutAddress"
data-type="{{item.type}}" data-type="{{item.type}}"
data-id="{{item.id}}" data-id="{{item.id}}"
> >
......
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