150 lines
5.1 KiB
Vue
150 lines
5.1 KiB
Vue
<template>
|
|
<view class="container">
|
|
<div class="address">
|
|
<div class="border">
|
|
<image src="http://192.168.0.172:5500/7.15/shop_border.png" mode="widthFix"></image>
|
|
</div>
|
|
<div class="address_Info" @click="choseAddress" v-if="defAddress">
|
|
<div class="address_Info_left">
|
|
<div class="address_Info_left_tit">收货地址</div>
|
|
<div class="address_Info_left_name">李佳 15901518415</div>
|
|
<div class="address_Info_left_addr">北京北京市朝阳区珠江绿洲文化广场</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="address_Info" @click="choseAddress" v-if="!defAddress">
|
|
<div class="address_Info_left noneDef">
|
|
<div class="address_Info_btn">添加收货地址</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="border">
|
|
<image src="http://192.168.0.172:5500/7.15/shop_border.png" mode="widthFix"></image>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="goodsCate" v-for="items, indexs in carList" :key="indexs">
|
|
<div class="goodsItem">
|
|
<div class="goodsItem_msg_img">
|
|
<image :src="picUrl + items.commodity_goods_info.commodity_pic">
|
|
</image>
|
|
</div>
|
|
<div class="goodsItem_msg_right">
|
|
<div class="goodsItem_msg_right_tit">{{ items.commodity_goods_info.goods_name }}</div>
|
|
<div class="goodsItem_msg_right_subTit">{{ items.commodity_goods_info.goods_intro }}</div>
|
|
<div class="goodsItem_msg_right_msg">
|
|
<div class="goodsItem_msg_right_msg_left">
|
|
<span>¥</span>{{ items.commodity_goods_info.sales_price }}
|
|
<span>/{{ items.commodity_goods_info.goods_unit }}</span>
|
|
</div>
|
|
<div class="goodsItem_msg_right_msg_right">
|
|
<u-number-box v-model="value">
|
|
<view slot="minus" class="minus" @click="minus(items, indexs)">
|
|
<u-icon name="minus" size="32" bold></u-icon>
|
|
</view>
|
|
<text slot="input" style="width: 80rpx;text-align: center;" class="input">
|
|
{{ items.count }}
|
|
</text>
|
|
<view slot="plus" class="plus" @click="add(items, indexs)">
|
|
<u-icon name="plus" color="#FFFFFF" size="32" bold></u-icon>
|
|
</view>
|
|
</u-number-box>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="yf">
|
|
<span>运费</span>¥9.9
|
|
</div>
|
|
<div class="line"></div>
|
|
</div>
|
|
|
|
|
|
<div class="footer">
|
|
<div class="btn">立即支付¥{{ totalMony }}</div>
|
|
</div>
|
|
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {
|
|
apiArr
|
|
} from '../../../api/shop';
|
|
import {
|
|
picUrl,
|
|
menuButtonInfo,
|
|
request,
|
|
NavgateTo
|
|
} from '../../../utils';
|
|
export default {
|
|
data() {
|
|
return {
|
|
picUrl,
|
|
top: "",
|
|
localHeight: "",
|
|
value: 3,
|
|
type: "error",
|
|
carList: [],
|
|
totalMony: 0,
|
|
defAddress:{},
|
|
}
|
|
},
|
|
methods: {
|
|
choseAddress() {
|
|
NavgateTo('../address/index')
|
|
},
|
|
|
|
calcTotal() {
|
|
let total = 0
|
|
this.carList.forEach(item => {
|
|
total += item.commodity_goods_info.sales_price * item.count
|
|
})
|
|
this.totalMony = total
|
|
},
|
|
|
|
minus(item, index) {
|
|
let that = this
|
|
if (item.count === 1) {
|
|
request(apiArr.deleteCar, "POST", {
|
|
ids: [item.id]
|
|
}).then(res => {
|
|
that.carList.splice(index, 1)
|
|
that.calcTotal()
|
|
})
|
|
}
|
|
this.carList[index].count = this.carList[index].count - 1
|
|
this.calcTotal()
|
|
},
|
|
add(item, index) {
|
|
this.carList[index].count = this.carList[index].count + 1
|
|
this.calcTotal()
|
|
},
|
|
//用户收货地址
|
|
getUserAddress() {
|
|
request(apiArr.getUserDefAddress, "POST", {}).then(res => {
|
|
this.defAddress = res.default_address
|
|
})
|
|
},
|
|
|
|
},
|
|
onShow() {
|
|
this.getUserAddress()
|
|
},
|
|
onLoad(options) {
|
|
const meun = menuButtonInfo();
|
|
this.top = meun.top;
|
|
this.localHeight = meun.height;
|
|
this.carList = JSON.parse(options.shopCarList)
|
|
this.calcTotal()
|
|
},
|
|
onReachBottom() {
|
|
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
@import url("./index.css");
|
|
</style> |