|
|
|
@ -1,52 +1,54 @@ |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<view class="cart-container"> |
|
|
|
<!-- 选择收货地址的盒子 --> |
|
|
|
<view class="address-choose-box" v-if="JSON.stringify(address) === '{}'"> |
|
|
|
<view class="address-choose-box"> |
|
|
|
<button type="primary" size="mini" class="btnChooseAddress" @click="chooseAddress">请选择收货地址+</button> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 渲染收货信息的盒子 --> |
|
|
|
<view class="address-info-box" v-else @click="chooseAddress"> |
|
|
|
<!-- 底部的边框线 --> |
|
|
|
<image src="/static/cart_border@2x.png" class="address-border"></image> |
|
|
|
|
|
|
|
<!-- 循环渲染地址信息 --> |
|
|
|
|
|
|
|
<view> |
|
|
|
<uni-swipe-action> |
|
|
|
<block v-for="(item, i) in addressList" :key="i"> |
|
|
|
<uni-swipe-action-item :options="options" @click="swipeItemClickHandler(item)"> |
|
|
|
<view class="address-info-box"> |
|
|
|
<view class="row1"> |
|
|
|
<view class="row1-left"> |
|
|
|
<view class="username">收货人:{{address.userName}}</view> |
|
|
|
<view class="username">收货人:{{item.name}}</view> |
|
|
|
</view> |
|
|
|
<view class="row1-right"> |
|
|
|
<view class="phone">电话:{{address.telNumber}}</view> |
|
|
|
<view class="phone">电话:{{item.mobile}}</view> |
|
|
|
<uni-icons type="arrowright" size="16"></uni-icons> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="row2"> |
|
|
|
<view class="row2-left">收货地址:</view> |
|
|
|
<view class="row2-right">{{addstr}}</view> |
|
|
|
<view class="row2-right">{{item.address}}</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 底部的边框线 --> |
|
|
|
<image src="/static/cart_border@2x.png" class="address-border"></image> |
|
|
|
|
|
|
|
<!-- 循环渲染地址信息 --> |
|
|
|
<view> |
|
|
|
<block v-for="(goods, i) in addressList" :key="i"> |
|
|
|
<view class="goods-item"> |
|
|
|
<!-- 左侧的盒子 --> |
|
|
|
<view class="goods-item-left"> |
|
|
|
<radio :checked="goods.goods_state" color="#C00000" v-if="showRadio" @click="radioClickHandler"></radio> |
|
|
|
<image :src="goods.goods_small_logo || defaultPic" class="goods-pic"></image> |
|
|
|
</uni-swipe-action-item> |
|
|
|
</block> |
|
|
|
</uni-swipe-action> |
|
|
|
<!-- <block v-for="(item, i) in addressList" :key="i"> |
|
|
|
<view class="address-info-box"> |
|
|
|
<view class="row1"> |
|
|
|
<view class="row1-left"> |
|
|
|
<view class="username">收货人:{{item.name}}</view> |
|
|
|
</view> |
|
|
|
<view class="row1-right"> |
|
|
|
<view class="phone">电话:{{item.mobile}}</view> |
|
|
|
<uni-icons type="arrowright" size="16"></uni-icons> |
|
|
|
</view> |
|
|
|
<!-- 右侧的盒子 --> |
|
|
|
<view class="goods-item-right"> |
|
|
|
<!-- 商品的名字 --> |
|
|
|
<view class="goods-name">{{goods.goods_name}}</view> |
|
|
|
<view class="goods-info-box"> |
|
|
|
<view class="goods-price"><bV> </bV>{{goods.goods_price | tofixed}}</view> |
|
|
|
<uni-number-box :min="1" :value="goods.goods_count" v-if="showNum" @change="numChangeHandler"></uni-number-box> |
|
|
|
</view> |
|
|
|
<view class="row2"> |
|
|
|
<view class="row2-left">收货地址:</view> |
|
|
|
<view class="row2-right">{{item.address}}</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</block> |
|
|
|
</block> --> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
@ -57,17 +59,39 @@ |
|
|
|
export default { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
address: {}, |
|
|
|
addressList:[{"goods_name":"111"}] |
|
|
|
addressList:[] |
|
|
|
}; |
|
|
|
}, |
|
|
|
onLoad() { |
|
|
|
this.initAddress(); |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
...mapMutations('m_user', ['updateAddress']), |
|
|
|
async initAddress(){ |
|
|
|
const { |
|
|
|
data: res |
|
|
|
} = await uni.$http.post('/small/project/address/listAll',{userId:this.userId}) |
|
|
|
if (!res.success) return uni.$showMsg() |
|
|
|
this.addressList = res.data; |
|
|
|
}, |
|
|
|
async chooseAddress() { |
|
|
|
const [err, succ] = await uni.chooseAddress().catch(err => err) |
|
|
|
if (err === null && succ.errMsg === 'chooseAddress:ok') { |
|
|
|
// this.address = succ |
|
|
|
this.updateAddress(succ) |
|
|
|
|
|
|
|
const addressObj = { |
|
|
|
userId: this.userId, |
|
|
|
name: succ.userName, |
|
|
|
mobile: succ.telNumber, |
|
|
|
address: succ.provinceName + succ.cityName + succ.countyName + succ.detailInfo |
|
|
|
} |
|
|
|
this.addressList.push(addressObj) |
|
|
|
|
|
|
|
const { |
|
|
|
data: res |
|
|
|
} = await uni.$http.post('/small/project/address/add',addressObj) |
|
|
|
if (!res.success) return uni.$showMsg() |
|
|
|
this.initAddress(); |
|
|
|
} |
|
|
|
|
|
|
|
if (err && (err.errMsg === 'chooseAddress:fail auth deny' || err.errMsg === 'chooseAddress:fail authorize no response')) { |
|
|
|
@ -97,7 +121,7 @@ |
|
|
|
} |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
...mapState('m_user', ['address']), |
|
|
|
...mapState('m_user', ['address','userId']), |
|
|
|
...mapGetters('m_user', ['addstr']) |
|
|
|
} |
|
|
|
} |
|
|
|
|