From 1fb44496929548b4f07b37796d506dedc494d44a Mon Sep 17 00:00:00 2001
From: xuxueyang <xuxy@fengyuntec.com>
Date: 星期二, 30 七月 2024 17:29:35 +0800
Subject: [PATCH] update 问题修复
---
sub_pages/customer/shopping/shopping.vue | 84 ++++++++++++++++++++++++++++++++++-------
1 files changed, 69 insertions(+), 15 deletions(-)
diff --git a/sub_pages/customer/shopping/shopping.vue b/sub_pages/customer/shopping/shopping.vue
index 30d8998..a9f17ef 100644
--- a/sub_pages/customer/shopping/shopping.vue
+++ b/sub_pages/customer/shopping/shopping.vue
@@ -1,6 +1,6 @@
<template>
<view class="shopping-container">
- <view class="top-title"><span class="t-red">*</span> 苏州市一价全含,市区内包邮派送到店
+ <view class="top-title"><span class="t-red">*</span> 花满芫报价已包含打包材料费、交易佣金
</view>
<view class="top-desc">
全程鲜花冷链专线,时效快,损耗小
@@ -17,7 +17,8 @@
<view class="sup-title">
- <radio :checked="ids.indexOf(item.id)>=0" @click="changeItem(item,'supplier')"></radio>
+ <radio :checked="ids.indexOf('supplier@'+item.supplierId)>=0" @click="changeItem(item,'supplier')">
+ </radio>
{{ item.supplierName || '-' }}
</view>
<u-divider></u-divider>
@@ -27,26 +28,27 @@
<u-swipe-action-item :options="options1" @click="(e)=>{clickSwipeButton(dto)}">
<view class="item-each flex">
<radio :checked="ids.indexOf(dto.id)>=0" @click="changeItem(dto,'flower')"></radio>
- <image class="img img100 m-r-6" :src="dto.url||dto.cover"></image>
+ <image class="img img100 m-r-6 br-4" :src="dto.url||dto.cover"></image>
<view class="flex1">
- <view class="title"><span class="m-r-5"
- style="display: inline-block;">{{item.categoryStr||''}}</span><span
- v-if="item.levelStr" class="m-r-5"
- style="display: inline-block;">{{ item.levelStr || '' }}</span>{{ dto.name || '-' }}
+ <view class="title" @click.stop="toDetail(dto)"><span class="m-r-5"
+ style="display: inline-block;">{{dto.categoryStr||''}}</span><span
+ v-if="dto.levelStr" class="m-r-5"
+ style="display: inline-block;">{{ dto.levelStr || '' }}</span>{{ dto.name || '-' }}
</view>
- <view class="price">
+ <view class="price" @click.stop="toDetail(dto)">
{{ dto.price || '-' }}元/扎
</view>
<view class="flex">
- <view class="desc m-t-12 flex">
+ <view class="desc flex p-t-5" @click.stop="toDetail(dto)">
<view class="m-r-15">剩余:{{ dto.stock || 0 }}</view>
<view class="m-r-15">颜色:{{ dto.color || '-' }}</view>
</view>
<view class="button-icons flex m-l-a m-r-0">
<uni-icons v-if="dto.num&&dto.num>=1" type="minus" size="32"
- @click="addnum(dto,-1)"></uni-icons>
+ @click.stop="addnum(dto,-1)"></uni-icons>
<view class="curnums" v-if="dto.num&&dto.num>=1">{{ dto.num }}</view>
- <uni-icons type="plus-filled" size="32" @click="addnum(dto,1)"></uni-icons>
+ <uni-icons type="plus-filled" size="32"
+ @click.stop="addnum(dto,1)"></uni-icons>
</view>
</view>
</view>
@@ -174,8 +176,8 @@
this.ids.splice(this.ids.indexOf(item.id), 1)
}
for (var i = 0; i < this.list.length; i++) {
- if (this.list[i].id === item.supplierId) {
- this.list[i].splice(i, 1)
+ if (this.list[i].supplierId === item.supplierId) {
+ // this.list[i].flowerList.splice(i, 1)
if (this.list[i].flowerList.length === 1) {
if (this.ids.indexOf('supplier@' + this.list[i].supplierId) >= 0) {
this.ids.splice(this.ids.indexOf('supplier@' + this.list[i].supplierId), 1)
@@ -186,16 +188,18 @@
//只需要清楚这个元素
var k = -1
for (var j = 0; j < this.list[i].flowerList.length; j++) {
- if (this.list[i][j].id === item.id) {
+ if (this.list[i].flowerList[j].id === item.id) {
k = j;
break
}
}
this.list[i].flowerList.splice(k, 1)
}
+ this.$forceUpdate()
break
}
}
+ console.log('this.list', this.list)
}
},
@@ -215,6 +219,9 @@
this.ids.push(item.id)
}
})
+ if (this.ids.indexOf('supplier@' + dto.supplierId) < 0) {
+ this.ids.push('supplier@' + dto.supplierId)
+ }
})
this.checkall = true
}
@@ -233,8 +240,9 @@
} else {
this.checkall = false
this.ids.splice(this.ids.indexOf('supplier@' + dto.supplierId), 1)
+ console.log('this.ids splice', this.ids)
dto.flowerList.forEach(item => {
- this.ids.splice(this.ids.indexOf('supplier@' + item.supplierId), 1)
+ this.ids.splice(this.ids.indexOf(item.id), 1)
})
}
@@ -242,12 +250,41 @@
//更换个人的
if (this.ids.indexOf(dto.id) < 0) {
this.ids.push(dto.id)
+ var has = true
+
+ //判断如果都有,那么顶部的按钮也勾选上
+ for (var i = 0; i < this.list.length; i++) {
+ if (this.list[i].supplierId === dto.supplierId) {
+ for (var j = 0; j < this.list[i].flowerList.length; j++) {
+ if (this.ids.indexOf(this.list[i].flowerList[j].id) < 0) {
+ has = false
+ break
+ }
+ }
+ break
+ }
+ }
+ if (has) {
+ if (this.ids.indexOf('supplier@' + dto.supplierId) < 0) {
+ this.ids.push('supplier@' + dto.supplierId)
+ this.$forceUpdate()
+ }
+
+ } else {
+ console.log('has', this.ids, dto)
+ }
+
} else {
this.checkall = false
if (this.ids.indexOf(dto.id) >= 0) {
this.ids.splice(this.ids.indexOf(dto.id), 1)
}
+ //还要删除供应商的id
+ if (this.ids.indexOf('supplier@' + dto.supplierId) >= 0) {
+ this.ids.splice(this.ids.indexOf('supplier@' + dto.supplierId), 1)
+ }
+
}
}
@@ -256,6 +293,13 @@
if (dto.num + addnum >= 0) {
} else {
+ return
+ }
+ if (!dto.stock) {
+ dto.stock = 0
+ }
+ if (dto.num + addnum > dto.stock) {
+ this.$message.showToast('库存不足,无法添加')
return
}
this.$message.showLoading()
@@ -270,6 +314,11 @@
this.$message.hideLoading()
if (code === 0) {
dto.num += addnum
+ if (dto.num < 1) {
+ //id删除清空,并且
+ await this.clickSwipeButton(dto)
+ // await this.init()
+ }
}
},
async init() {
@@ -293,6 +342,11 @@
this.list = data || []
}
+ },
+ toDetail(dto) {
+ uni.navigateTo({
+ url: '/sub_pages/customer/trade/detail?id=' + dto.id
+ })
}
}
}
--
Gitblit v1.9.3