From e998d551df1c96572838bbf661be938aa79d1be8 Mon Sep 17 00:00:00 2001
From: xuxueyang <xuxy@fengyuntec.com>
Date: 星期四, 25 七月 2024 15:01:16 +0800
Subject: [PATCH] fix bug
---
sub_pages/customer/trade/list.vue | 97 ++++++++++++++++++++++++++++++++----------------
1 files changed, 64 insertions(+), 33 deletions(-)
diff --git a/sub_pages/customer/trade/list.vue b/sub_pages/customer/trade/list.vue
index 3f7e9f7..1af11b2 100644
--- a/sub_pages/customer/trade/list.vue
+++ b/sub_pages/customer/trade/list.vue
@@ -58,8 +58,8 @@
</view>
<view class="component-shop-item flex" v-for="(item,index) of list" :key="index"
- @click="toDetail(item)">
- <view class="img">
+ >
+ <view class="img" @click.stop="toDetail(item)">
<image class="img img100"
src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/ff/fff3027bd0a146478fd1f0aae816a028%E5%BE%AE%E4%BF%A1%E6%88%AA%E5%9B%BE_20240710224139.png">
</image>
@@ -69,41 +69,43 @@
</view>
<view class="m-l-12 info-container flex1">
- <view class="title">
- 橙色芭比
- <view class="price">
- ¥6.60/扎
+ <view @click.stop="toDetail(item)">
+ <view class="title">
+ 橙色芭比
+ <view class="price">
+ ¥6.60/扎
+ </view>
</view>
- </view>
- <view class="shop-name">
- 牛油果泡泡·白色
- </view>
- <view class="other-info flex">
- <view class="m-r-15">
- 已售:7
+ <view class="shop-name">
+ 牛油果泡泡·白色
</view>
- <view class="m-r-15">
- 剩余:13
- </view>
- <view class="m-r-15">
- 1支/扎
+ <view class="other-info flex">
+ <view class="m-r-15">
+ 已售:7
+ </view>
+ <view class="m-r-15">
+ 剩余:13
+ </view>
+ <view class="m-r-15">
+ 1支/扎
+ </view>
</view>
</view>
<view class="bottom-buttons flex">
<view class="icons flex">
<uni-icons v-if="item.shopnum&&item.shopnum>=1" type="minus" size="32"
- @click.stop="mulnum(item)"></uni-icons>
+ @click.stop="addnum(item,-1)"></uni-icons>
<view class="curnums" v-if="item.shopnum&&item.shopnum>=1">{{ item.shopnum }}</view>
<uni-icons v-if="!item.shopnum||item.shopnum<=99" type="plus-filled" size="32"
- @click.stop="addnum(item)"></uni-icons>
+ @click.stop="addnum(item,1)"></uni-icons>
</view>
</view>
</view>
</view>
- <view class="icon-shop" v-if="list&&list.length>0">
+ <view class="icon-shop" v-if="list&&list.length>0" @click="goto('/sub_pages/customer/shopping/shopping',true)">
<!-- 购物图标 -->
<!-- 如果有购买的东西,就要附带数字了 -->
<view v-if="shoptotal>0" class="number">
@@ -149,6 +151,8 @@
</template>
<script>
+import http from "../../../plugins/http";
+
export default {
data() {
return {
@@ -178,7 +182,7 @@
this.query.category = options.categoryId || ''
this.query.zoneId = options.zoneId || ''
this.listApi = '/api/customer/flower/list'
- this.getList()
+ this.getList('post')
this.$http.request('get', '/api/code/value', {
params: {
type: 'FLOWER_LEVEL'
@@ -274,21 +278,48 @@
url: `/sub_pages/customer/trade/detail?id=${item.id}`
})
},
- mulnum(item) {
- if (item.shopnum > 0) {
- item.shopnum -= 1
+ // mulnum(item) {
+ // if (item.shopnum > 0) {
+ // item.shopnum -= 1
+ // }
+ // this.shoptotal -= 1
+ // this.$forceUpdate()
+ //
+ // },
+ async addnum(item, addnum) {
+ if (!this.currentInfo.id) {
+ await this.$message.confirm('请前往登录')
+ uni.navigateTo({
+ url: '//pages/user/supplier-user'
+ })
+ return
}
- this.shoptotal -= 1
- this.$forceUpdate()
+ if (!item.shopnum) {
+ item.shopnum = 0
+ }
+ if (item.shopnum + addnum >= 0) {
- },
- addnum(item) {
- if (item.shopnum) {
- item.shopnum += 1
} else {
- item.shopnum = 1
+ return
}
- this.shoptotal += 1
+ this.$message.showLoading()
+ const {code} = await http.request('post', '/api/api/customer/flower/cart/change-num', {
+ data: {
+ id: item.id,
+ num: addnum
+ }
+ }
+ )
+ this.$message.hideLoading()
+ if (code === 0) {
+ item.shopnum += addnum
+ }
+ // if (item.shopnum) {
+ // item.shopnum += 1
+ // } else {
+ // item.shopnum = 1
+ // }
+ // this.shoptotal += 1
this.$forceUpdate()
},
}
--
Gitblit v1.9.3