完善本地生活购物车
This commit is contained in:
parent
fc74a0fa8d
commit
dab8a7c27d
@ -87,3 +87,7 @@ export function getCartGoods(data) {
|
||||
export function modifyCart(data) {
|
||||
return request.post("LocalStoreGoods/modifyCart", data)
|
||||
}
|
||||
|
||||
export function clearCart(data) {
|
||||
return request.post("LocalStoreGoods/clearCart", data)
|
||||
}
|
||||
|
||||
@ -38,8 +38,7 @@
|
||||
<u-field label="城市:" label-width="160" placeholder="请选择城市" :border-bottom="false" v-mode="city"
|
||||
disabled :value="scheme_city.name" />
|
||||
</router-link>
|
||||
|
||||
<view v-if="scheme_city && city_data" class="open-shop">
|
||||
<view v-if="scheme_city != '' && city_data" class="open-shop">
|
||||
<view class="open-category">
|
||||
<view v-for="(item, index) in city_data" :key="index" :class="'open-item ' + ((partnerIndex == index ) ? 'active': '') + ' '" @click="selectPartner(index)">
|
||||
<view class="bold text-center">
|
||||
@ -390,7 +389,7 @@
|
||||
},
|
||||
onLoad(options) {
|
||||
this.scheme_city = options?.city
|
||||
|
||||
|
||||
// 获取店铺类型及合作方案
|
||||
this.getSchemeFun()
|
||||
// 获取上级及个人信息
|
||||
@ -613,8 +612,18 @@
|
||||
back_id_card,
|
||||
region,
|
||||
hand_id_card,
|
||||
cost_card
|
||||
cost_card,
|
||||
partnerIndex,
|
||||
selectIndex
|
||||
} = this;
|
||||
|
||||
if (partnerIndex == -1) {
|
||||
this.$toast({
|
||||
title: '请选择合伙人类型'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if (!realName) {
|
||||
this.$toast({
|
||||
@ -664,6 +673,13 @@
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectIndex == -1) {
|
||||
this.$toast({
|
||||
title: '请选择合伙人类型'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
let params = {
|
||||
real_name: realName,
|
||||
@ -809,6 +825,7 @@
|
||||
this.partnerIndex = i
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapGetters(['appConfig']),
|
||||
},
|
||||
|
||||
@ -172,49 +172,54 @@
|
||||
</u-popup>
|
||||
|
||||
<u-popup v-model="cart.popup" mode="bottom" height="60%">
|
||||
<view style="padding: 20rpx;height: 80rpx;">
|
||||
<view class="flex row-between">
|
||||
<view class="flex">
|
||||
<view>
|
||||
总价
|
||||
<price-format :color="colorConfig.primary" :subscript-size="26"
|
||||
:first-size="38" :second-size="26" :price="cart.total_amount" class="m-l-10">
|
||||
</price-format>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<u-icon name="trash" size="32" class="m-r-10"></u-icon>
|
||||
清空购物车
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<scroll-view scroll-y="true" style="height: calc(100% - 80rpx);">
|
||||
<view>
|
||||
<view class="p-20 flex row-between" v-for="(item, index) in cart.data" :key="index">
|
||||
<view class="m-r-20">
|
||||
<u-image width="120" height="120" :src="item.pic"></u-image>
|
||||
</view>
|
||||
|
||||
<view class="flex row-between flex-1">
|
||||
<view v-if="cart.data.length > 0">
|
||||
<view style="padding: 20rpx;height: 80rpx;">
|
||||
<view class="flex row-between">
|
||||
<view class="flex">
|
||||
<view>
|
||||
<view class="line-2">
|
||||
{{item.title}}
|
||||
</view>
|
||||
<view>
|
||||
<price-format :color="colorConfig.primary" :subscript-size="26"
|
||||
:first-size="38" :second-size="26" :price="item.price">
|
||||
</price-format>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row-between">
|
||||
<u-number-box :min="1" :max="spec.shop_max" :value="item.goods_num" :disabled-input="true" class="m-t-10" :index="item.id" @minus="minusCartFun" @plus="plusCartFun"/>
|
||||
<view class="m-t-20 u-text-right">移除</view>
|
||||
总价
|
||||
<price-format :color="colorConfig.primary" :subscript-size="26"
|
||||
:first-size="38" :second-size="26" :price="cart.total_amount" class="m-l-10">
|
||||
</price-format>
|
||||
</view>
|
||||
</view>
|
||||
<view @click="clearCartFun(0)">
|
||||
<u-icon name="trash" size="32" class="m-r-10"></u-icon>
|
||||
清空购物车
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
<scroll-view scroll-y="true" style="height: calc(100% - 80rpx);">
|
||||
<view>
|
||||
<view class="p-20 flex row-between" v-for="(item, index) in cart.data" :key="index">
|
||||
<view class="m-r-20">
|
||||
<u-image width="120" height="120" :src="item.pic"></u-image>
|
||||
</view>
|
||||
|
||||
<view class="flex row-between flex-1">
|
||||
<view>
|
||||
<view class="line-2">
|
||||
{{item.title}}
|
||||
</view>
|
||||
<view>
|
||||
<price-format :color="colorConfig.primary" :subscript-size="26"
|
||||
:first-size="38" :second-size="26" :price="item.price">
|
||||
</price-format>
|
||||
</view>
|
||||
</view>
|
||||
<view class="row-between">
|
||||
<u-number-box :min="1" :max="spec.shop_max" :value="item.goods_num" :disabled-input="true" class="m-t-10" :index="item.id" @minus="minusCartFun" @plus="plusCartFun"/>
|
||||
<view class="m-t-20 u-text-right" @click="clearCartFun(item.id, index)">移除</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<view v-if="cart.data.length == 0" class="text-center m-t-20 bold">
|
||||
暂无商品数据!
|
||||
</view>
|
||||
</u-popup>
|
||||
</view>
|
||||
</mescroll-uni>
|
||||
@ -235,7 +240,8 @@
|
||||
addCart,
|
||||
cartNum,
|
||||
getCartGoods,
|
||||
modifyCart
|
||||
modifyCart,
|
||||
clearCart
|
||||
} from '@/api/local_store';
|
||||
import {
|
||||
sortType,
|
||||
@ -459,6 +465,7 @@
|
||||
})
|
||||
|
||||
this.cartNum = this.cartNum + goods_num
|
||||
|
||||
this.zoomValue = 1.5
|
||||
setTimeout(() => {
|
||||
this.zoomValue = 1
|
||||
@ -476,18 +483,57 @@
|
||||
async modifyCartFun(goods_num, cart_id, type) {
|
||||
const {code, data} = await modifyCart({
|
||||
goods_num,
|
||||
cart_id,
|
||||
type
|
||||
cart_id
|
||||
})
|
||||
|
||||
if (code == 1) {
|
||||
this.cart.total_amount = data.total_amount
|
||||
|
||||
if (type == 'minus') {
|
||||
this.cartNum--
|
||||
} else {
|
||||
this.cartNum++
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 移除商品和清空购物车
|
||||
clearCartFun(cart_id = 0, index = 0) {
|
||||
let title = '购物车'
|
||||
let content = "是否清空购物车?"
|
||||
if (cart_id > 0) {
|
||||
content = '是否从购物车移除该商品?'
|
||||
}
|
||||
uni.showModal({
|
||||
title,
|
||||
content,
|
||||
success: async res => {
|
||||
let {
|
||||
confirm
|
||||
} = res;
|
||||
if (confirm) {
|
||||
const {code, data} = await clearCart({
|
||||
lstore_id: this.id,
|
||||
cart_id
|
||||
})
|
||||
|
||||
if (code == 1) {
|
||||
this.cart.total_amount = data.total_amount
|
||||
this.cartNum = data.goods_num
|
||||
|
||||
if (cart_id > 0) {
|
||||
this.cart.data.splice(index, 1)
|
||||
} else {
|
||||
this.cart.data = []
|
||||
}
|
||||
|
||||
this.$toast({
|
||||
title: '操作成功'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user