|
|
@ -1,14 +1,12 @@ |
|
|
<template> |
|
|
<template> |
|
|
<view class="wrap"> |
|
|
<view class="wrap"> |
|
|
<view class="stabar"></view> |
|
|
<view class="stabar"></view> |
|
|
<view class="secbar"><label class="back" @click="back()"></label> |
|
|
<view class="secbar"><label class="back" @click="back()"></label> |
|
|
<view class="title">联系地址</view> |
|
|
<view class="title">联系地址</view> |
|
|
</view> |
|
|
</view> |
|
|
<view class="cart-container"> |
|
|
<view class="mainwrap2"> |
|
|
<!-- 选择收货地址的盒子 --> |
|
|
<view class="subwrap"> |
|
|
<view class="address-choose-box"> |
|
|
|
|
|
<button type="primary" size="mini" class="btnChooseAddress" @click="chooseAddress">新增地址+</button> |
|
|
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
|
|
<!-- 底部的边框线 --> |
|
|
<!-- 底部的边框线 --> |
|
|
<image src="/static/cart_border@2x.png" class="address-border"></image> |
|
|
<image src="/static/cart_border@2x.png" class="address-border"></image> |
|
|
@ -39,11 +37,21 @@ |
|
|
</uni-swipe-action> |
|
|
</uni-swipe-action> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
|
|
|
<!-- 选择收货地址的盒子 --> |
|
|
|
|
|
<view class="address-choose-box"> |
|
|
|
|
|
<button type="primary" size="mini" class="uni-button" @click="chooseAddress">批量刪除</button> |
|
|
|
|
|
<button type="primary" size="mini" class="uni-button" @click="chooseAddress">新增地址</button> |
|
|
|
|
|
</view> |
|
|
|
|
|
</view> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import { mapState, mapMutations, mapGetters } from 'vuex' |
|
|
import { |
|
|
|
|
|
mapState, |
|
|
|
|
|
mapMutations, |
|
|
|
|
|
mapGetters |
|
|
|
|
|
} from 'vuex' |
|
|
import addressVue from './address.vue'; |
|
|
import addressVue from './address.vue'; |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
@ -55,7 +63,7 @@ |
|
|
backgroundColor: '#C00000' |
|
|
backgroundColor: '#C00000' |
|
|
} |
|
|
} |
|
|
}], |
|
|
}], |
|
|
addressList:[] |
|
|
addressList: [] |
|
|
}; |
|
|
}; |
|
|
}, |
|
|
}, |
|
|
onLoad() { |
|
|
onLoad() { |
|
|
@ -63,10 +71,12 @@ |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
...mapMutations('m_user', ['updateAddress']), |
|
|
...mapMutations('m_user', ['updateAddress']), |
|
|
async initAddress(){ |
|
|
async initAddress() { |
|
|
const { |
|
|
const { |
|
|
data: res |
|
|
data: res |
|
|
} = await uni.$http.post('/small/project/address/listAll',{userId:this.userId}) |
|
|
} = await uni.$http.post('/small/project/address/listAll', { |
|
|
|
|
|
userId: this.userId |
|
|
|
|
|
}) |
|
|
if (!res.success) return uni.$showMsg() |
|
|
if (!res.success) return uni.$showMsg() |
|
|
this.addressList = res.data; |
|
|
this.addressList = res.data; |
|
|
}, |
|
|
}, |
|
|
@ -85,12 +95,13 @@ |
|
|
|
|
|
|
|
|
const { |
|
|
const { |
|
|
data: res |
|
|
data: res |
|
|
} = await uni.$http.post('/small/project/address/add',addressObj) |
|
|
} = await uni.$http.post('/small/project/address/add', addressObj) |
|
|
if (!res.success) return uni.$showMsg() |
|
|
if (!res.success) return uni.$showMsg() |
|
|
this.initAddress(); |
|
|
this.initAddress(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (err && (err.errMsg === 'chooseAddress:fail auth deny' || err.errMsg === 'chooseAddress:fail authorize no response')) { |
|
|
if (err && (err.errMsg === 'chooseAddress:fail auth deny' || err.errMsg === |
|
|
|
|
|
'chooseAddress:fail authorize no response')) { |
|
|
// 通过调用这个方法,让用户重新授权 |
|
|
// 通过调用这个方法,让用户重新授权 |
|
|
this.reAuth() |
|
|
this.reAuth() |
|
|
} |
|
|
} |
|
|
@ -111,32 +122,37 @@ |
|
|
if (confirmResult.confirm) return uni.openSetting({ |
|
|
if (confirmResult.confirm) return uni.openSetting({ |
|
|
success: (settingResult) => { |
|
|
success: (settingResult) => { |
|
|
if (!settingResult.authSetting['scope.address']) return uni.$showMsg('您取消了授权!') |
|
|
if (!settingResult.authSetting['scope.address']) return uni.$showMsg('您取消了授权!') |
|
|
if (settingResult.authSetting['scope.address']) return uni.$showMsg('授权成功!请选择地址') |
|
|
if (settingResult.authSetting['scope.address']) return uni.$showMsg( |
|
|
|
|
|
'授权成功!请选择地址') |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
async swipeItemClickHandler(item){ |
|
|
async swipeItemClickHandler(item) { |
|
|
this.addressList = this.addressList.filter(x=>x.guid!=item.guid); |
|
|
this.addressList = this.addressList.filter(x => x.guid != item.guid); |
|
|
const { |
|
|
const { |
|
|
data: res |
|
|
data: res |
|
|
} = await uni.$http.post('/small/project/address/remove',item.guid) |
|
|
} = await uni.$http.post('/small/project/address/remove', item.guid) |
|
|
if (!res.success) return uni.$showMsg() |
|
|
if (!res.success) return uni.$showMsg() |
|
|
}, |
|
|
}, |
|
|
back(){ |
|
|
back() { |
|
|
uni.navigateBack({ |
|
|
uni.navigateBack({ |
|
|
delta:1,//返回层数,2则上上页 |
|
|
delta: 1, //返回层数,2则上上页 |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
computed: { |
|
|
computed: { |
|
|
...mapState('m_user', ['address','userId']), |
|
|
...mapState('m_user', ['address', 'userId']), |
|
|
...mapGetters('m_user', ['addstr']) |
|
|
...mapGetters('m_user', ['addstr']) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<style lang="scss"> |
|
|
<style lang="scss"> |
|
|
@import url("@/static/base_css.css"); |
|
|
@import url("@/static/base_css.css"); |
|
|
|
|
|
.mainwrap2 { |
|
|
|
|
|
height: calc(100% - 350rpx); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
.address-border { |
|
|
.address-border { |
|
|
display: block; |
|
|
display: block; |
|
|
width: 100%; |
|
|
width: 100%; |
|
|
@ -144,19 +160,46 @@ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.address-choose-box { |
|
|
.address-choose-box { |
|
|
height: 90px; |
|
|
|
|
|
display: flex; |
|
|
display: flex; |
|
|
justify-content: center; |
|
|
position: fixed; |
|
|
|
|
|
bottom: 0; |
|
|
|
|
|
padding: 10rpx 0 50rpx 0; |
|
|
|
|
|
width: 100vw; |
|
|
|
|
|
height: 90rpx; |
|
|
|
|
|
border-top: 1px solid #ddd; |
|
|
|
|
|
background-color: #fff; |
|
|
|
|
|
|
|
|
|
|
|
.uni-button { |
|
|
|
|
|
margin: 1% 2%; |
|
|
|
|
|
font-size: 30rpx; |
|
|
|
|
|
width: 55%; |
|
|
|
|
|
height: 70rpx; |
|
|
|
|
|
display: flex; |
|
|
align-items: center; |
|
|
align-items: center; |
|
|
|
|
|
justify-content: center; |
|
|
|
|
|
background: #1367fe; |
|
|
|
|
|
border: 1px solid #1367fe; |
|
|
|
|
|
border-radius: 50rpx; |
|
|
|
|
|
white-space: nowrap; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.uni-button:first-child { |
|
|
|
|
|
width: 35%; |
|
|
|
|
|
background-color: #fff; |
|
|
|
|
|
color: #1367fe; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.address-info-box { |
|
|
.address-info-box { |
|
|
font-size: 12px; |
|
|
|
|
|
height: 90px; |
|
|
|
|
|
display: flex; |
|
|
display: flex; |
|
|
|
|
|
margin: 10rpx 0; |
|
|
|
|
|
padding: 0 10px; |
|
|
|
|
|
height: 180rpx; |
|
|
|
|
|
background: #fff; |
|
|
|
|
|
border-radius: 20rpx; |
|
|
|
|
|
font-size: 30rpx; |
|
|
flex-direction: column; |
|
|
flex-direction: column; |
|
|
justify-content: center; |
|
|
justify-content: center; |
|
|
padding: 0 5px; |
|
|
|
|
|
|
|
|
|
|
|
.row1 { |
|
|
.row1 { |
|
|
display: flex; |
|
|
display: flex; |
|
|
@ -242,4 +285,5 @@ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</style> |
|
|
</style> |