From af2a86dbbe05d74b00a6e7bdc426e26bb0453654 Mon Sep 17 00:00:00 2001
From: xuxueyang <xuxy@fengyuntec.com>
Date: 星期三, 31 七月 2024 11:35:34 +0800
Subject: [PATCH] fix bug
---
sub_pages/customer/self/collect.vue | 143 ++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 121 insertions(+), 22 deletions(-)
diff --git a/sub_pages/customer/self/collect.vue b/sub_pages/customer/self/collect.vue
index 3a6706f..4d9fa5f 100644
--- a/sub_pages/customer/self/collect.vue
+++ b/sub_pages/customer/self/collect.vue
@@ -56,15 +56,28 @@
},
methods: {
toDetail(item) {
+ if (item.status == 'UP') {
+
+ } else {
+ this.$message.showToast('商品已下架,无法查看详情')
+ return
+ }
uni.navigateTo({
url: `/sub_pages/customer/trade/detail?id=${item.id}`
})
},
async submitShopping(dto) {
//提交到购物车中
- this.$message.showLoading()
- await this.$store.dispatch('submitShopping', dto);
- this.$message.hideLoading()
+ // this.$message.showLoading()
+ // this.$message.hideLoading()
+ const {
+ code,
+ data
+ } = await this.$store.dispatch('submitShopping', dto);
+ if (code == 0) {
+ dto.shopnum = data || 0
+ this.$forceUpdate()
+ }
},
select_level(e) {
this.level_show = false
@@ -80,6 +93,67 @@
this.refreshList()
},
+ async updateItemNum(item) {
+ const res = await this.$message.confirm('', {
+ editable: true,
+ title: '请输入想要购买的数量'
+ })
+ if (res.content && res.confirm) {
+ // 发送请求
+ var t = parseInt(res.content)
+ if (isNaN(t) || t < 0) {
+ this.$message.showToast('数目需要大于等于0')
+
+ } else {
+ if (!item.stock || t > item.stock) {
+ this.$message.showToast('库存不足无法修改')
+ return
+ }
+ this.addnum(item, (t - item.shopnum))
+
+ }
+ } else {
+
+ }
+ },
+ async addnum(item, addnum) {
+ if (!this.currentInfo.id) {
+ await this.$message.confirm('请前往登录')
+ uni.navigateTo({
+ url: '/pages/user/supplier-user'
+ })
+ return
+ }
+ if (!item.shopnum) {
+ item.shopnum = 0
+ }
+ if (!item.stock) {
+ item.stock = 0
+ }
+ if (addnum > 0 & item.shopnum + addnum > item.stock) {
+ this.$message.showToast('库存不足,无法修改')
+ return
+ }
+ if (item.shopnum + addnum >= 0) {
+
+ } else {
+ return
+ }
+ this.$message.showLoading()
+ const {
+ code
+ } = await this.$http.request('post', '/api/customer/flower/cart/change-num', {
+ data: {
+ id: item.id,
+ num: addnum
+ }
+ })
+ this.$message.hideLoading()
+ if (code === 0) {
+ item.shopnum += addnum
+ this.$forceUpdate()
+ }
+ },
}
}
</script>
@@ -91,7 +165,7 @@
<view class="flex1 input">
<u-input placeholder="请输入花名" v-model="query.name">
<template slot="suffix">
- <uni-icons color="#20613D" type="search" size="24" @tap="refreshList"></uni-icons>
+ <uni-icons color="#20613D" type="search" size="24" @click="refreshList"></uni-icons>
</template>
</u-input>
</view>
@@ -117,15 +191,15 @@
@cancel="order_show=false"></u-picker>
<view class="trade-list-container">
- <view class="trade-info-container flex" v-for="(dto,index) of list" :key="index" @click.stop="toDetail(dto)">
- <image class="img img100 br-4 m-r-10" :src="dto.url||dto.cover"></image>
+ <view class="trade-info-container flex" :class="[dto.status]" v-for="(dto,index) of list" :key="index">
+ <image class="img img100 br-4 m-r-10" :src="dto.url||dto.cover" @click.stop="toDetail(dto)"></image>
<view class="flex1">
- <view class="flex">
+ <view class="flex" @click.stop="toDetail(dto)">
<view class="title">
<span class="m-r-5" style="display: inline-block;"
- v-if="item.categoryStr">{{item.categoryStr||''}}</span>
- <span v-if="item.levelStr" class="m-r-5"
- style="display: inline-block;">{{ item.levelStr || '' }}</span>
+ v-if="dto.categoryStr">{{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 m-l-a m-r-0">
@@ -133,13 +207,23 @@
</view>
</view>
<view class="flex">
- <view class="desc m-t-12 flex">
+ <view class="desc p-t-12 flex" @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 m-t-20">
- <view class="m-r-0 gwc" @click.stop="submitShopping(dto)">
+ <view class="button-icons flex m-l-a m-r-0 m-t-20" v-if="dto.status=='UP'">
+ <view class="m-r-0 gwc" @click.stop="submitShopping(dto)" v-if="!dto.shopnum">
+ 购物车
+ </view>
+ <view class="m-r-0 flex" v-if="dto.shopnum">
+ <uni-icons v-if="dto.shopnum&&dto.shopnum>=1" type="minus" size="32"
+ @click.stop="addnum(dto,-1)"></uni-icons>
+ <view class="curnums" @click.stop="updateItemNum(dto)"
+ v-if="dto.shopnum&&dto.shopnum>=1">
+ {{ dto.shopnum }}
+ </view>
+ <uni-icons v-if="!dto.shopnum||dto.shopnum<=99" type="plus-filled" size="32"
+ @click.stop="addnum(dto,1)"></uni-icons>
</view>
</view>
</view>
@@ -153,6 +237,8 @@
<style lang="scss" scoped>
.page-collect {
+ min-height: 99vh;
+
.search-container {
display: flex;
margin: 12rpx 0rpx 20rpx 0rpx;
@@ -174,14 +260,27 @@
}
}
- .trade-info-container {
- background-color: #fff;
- border-top-right-radius: 40rpx;
- border-top-left-radius: 40rpx;
- padding: 30rpx;
- overflow: hidden;
+ .trade-list-container {
min-height: calc(100vh - 300rpx);
overflow-y: scroll;
+ border-top-right-radius: 40rpx;
+ border-top-left-radius: 40rpx;
+ padding: 20rpx;
+
+ }
+
+ .trade-info-container.UP {
+ .title {
+ color: #000000;
+ }
+ }
+
+ .trade-info-container {
+ background-color: #fff;
+ border-radius: 40rpx;
+ margin-bottom: 20rpx;
+ padding: 20rpx;
+
.img {
width: 124rpx;
@@ -192,7 +291,7 @@
font-weight: 600;
font-size: 28rpx;
- color: #000000;
+ color: #333;
line-height: 40rpx;
.level {
@@ -221,8 +320,8 @@
line-height: 40rpx;
.curnums {
- margin-left: 10rpx;
- margin-right: 10rpx;
+ padding-left: 20rpx;
+ padding-right: 20rpx;
}
}
--
Gitblit v1.9.3