添加规格支付

This commit is contained in:
wangxiaowei 2024-09-16 17:30:49 +08:00
parent b25d5ca40e
commit 588ec4c17e
2 changed files with 81 additions and 31 deletions

@ -92,7 +92,7 @@
import {wxpay} from '@/utils/pay'
import {localShopPay, localShopLogin, localShopPayWeixin, localBalance} from '@/api/user.js'
import {getLocalShopById} from "@/api/shop"
import {getLocalGoodsDetails} from '@/api/store'
import {localOrderDetails} from '@/api/store'
export default {
data() {
@ -114,7 +114,6 @@
goods: [],
showPay: false,
payInfo: '',
payMoney: '',
spec_item_id: 0
};
},
@ -129,7 +128,8 @@
if (query?.type && query?.goods_id) {
this.goods_id = query.goods_id
this.spec_item_id = query.spec_item_id
this.getLocalGoodsDetailsFun()
this.lsg_order_id = query.lsg_order_id
this.localOrderDetailsFun()
}
this.login()
@ -153,23 +153,23 @@
}
},
async getLocalGoodsDetailsFun() {
const {data, code} = await getLocalGoodsDetails({
id: this.goods_id,
lstore_id: this.lstore_id,
spec_item_id: this.spec_item_id,
buy_shop_num: 1
async localOrderDetailsFun(){
const {data, code} = await localOrderDetails({
lsg_order_id: this.lsg_order_id
})
if (code == 1) {
this.goods = data
if (this.spec_item_id > 0) {
this.money = data.spec.price
} else {
this.money = data.price
this.info = data.local_msg
this.goods = data.goods_msg
this.goods.goods_num = data.goods_num
this.money = data.goods_total_price
if (data.sku_msg) {
this.goods.spec = data.sku_msg
}
} else {
this.$toast({title: '商品获取失败'})
return this.$toast({
title: '订单信息获取错误,请重新提交'
})
}
},
@ -251,12 +251,14 @@
title: '支付中',
mask: true
})
localShopPayWeixin({
money: this.money,
lid: this.lstore_id,
user_id: this.user_id,
spec_item_id: this.spec_item_id,
buy_shop_num: 1
goods_num: this.goods ? this.goods.goods_num : 1,
lsg_order_id: this.lsg_order_id
}).then((result) => {
if (result.code == 1) {
const pay = {

@ -17,9 +17,9 @@
</view>
<!-- <view class="block p-l-20 p-r-20 m-b-20 p-t-20 p-b-20 flex row-between"> -->
<view @click="showPopup = true" class="block p-l-20 p-r-20 m-b-20 p-t-20 p-b-20 flex row-between" v-if="data.is_multiple_spec">
<view @click="showPopup = true" class="block p-l-20 p-r-20 m-b-20 p-t-20 p-b-20 flex row-between">
<view class="bold">
选规格:{{active == -1 ? '默认' : shop_spec}}
选规格:{{active == -1 ? '默认' : shop_spec}},数量:x <text>{{shop_num}}</text>
</view>
<u-icon name="arrow-right" size="32" color="#bbb"></u-icon>
</view>
@ -30,9 +30,9 @@
</view>
<view class="footer">
<router-link :to="{path: '/bundle_b/pages/local_shop/local_pay', query: {id: data.lstore_id, goods_id: data.id, spec_item_id, type: 'shop'}}">
<button class="primary-btn white flex row-center">支付</button>
</router-link>
<!-- <router-link :to="{path: '/bundle_b/pages/local_shop/local_pay', query: {id: data.lstore_id, goods_id: data.id, spec_item_id, type: 'shop'}}"> -->
<button class="primary-btn white flex row-center" @click="toPay">支付</button>
<!-- </router-link> -->
</view>
<u-popup v-model="showPopup" mode="bottom">
@ -57,12 +57,24 @@
</view>
</view>
<view>
<view class="m-t-20 m-b-20" v-if="active > -1">
<view class="bold">
库存:
{{shop_stock}}
</view>
</view>
<view class="m-t-20 m-b-20" v-if="active > -1">
<view class="bold">
规格说明:
{{active == -1 ? '无' : shop_note}}
{{shop_note}}
</view>
</view>
<view class="flex row-between m-t-20 m-b-20">
<view class="bold">数量:{{shop_num}}</view>
<u-number-box v-model="shop_num" :min="1" :max="shop_max"></u-number-box>
</view>
</view>
</u-popup>
</view>
@ -70,7 +82,8 @@
<script>
import {
getLocalGoodsDetails
getLocalGoodsDetails,
submitLocalOrder
} from '@/api/store'
export default {
@ -85,7 +98,10 @@
shop_price: 0,
active: -1,
shop_note: '',
spec_item_id: 0
spec_item_id: 0,
shop_num: 1,
shop_stock: 0,
shop_max: 999
}
},
onLoad(options) {
@ -115,17 +131,49 @@
selectSpec(index, stock) {
if (index != -1 && stock <= 0) return this.$toast({title: '库存不足'})
console.log(123)
this.active = index
if (this.active == -1) {
this.spec_item_id = 0
this.shop_stock = 999
this.shop_max = 999
this.shop_image = this.data.pic[0].url
this.shop_price = this.data.price
this.shop_note = '无'
this.shop_spec = '默认'
} else {
this.spec_item_id = this.data.item[index].id
this.shop_stock = this.data.item[index].stock
this.shop_max = this.data.item[index].stock
this.shop_image = this.data.item[index].image
this.shop_price = this.data.item[index].price
this.shop_note = this.data.item[index].note || '无'
this.shop_spec = this.data.item[index].spec_value_str
}
},
async toPay() {
const {data, code} = await submitLocalOrder({
lstore_id: this.lstore_id,
goods_id: this.id,
goods_num: this.shop_num,
item_id: this.spec_item_id
})
if (code == 1) {
this.$Router.push({
path: '/bundle_b/pages/local_shop/local_pay',
query: {
id: this.data.lstore_id,
goods_id: this.data.id,
spec_item_id: this.spec_item_id,
type: 'shop',
lsg_order_id: data.lsg_order_id
}
})
} else {
return this.$toast({title: '订单错误'})
}
this.shop_image = this.data.item[index].image
this.shop_price = this.data.item[index].price
this.shop_note = this.data.item[index].note || '无'
this.shop_spec = this.data.item[index].spec_value_str
}
}
}