Browse Source

feat: 添加客服组件并优化库存显示逻辑

在多个页面中添加了客服组件 `<kefu>`,并在商品相关组件中优化了库存显示逻辑,包括库存不足时的按钮禁用状态和提示信息。同时,更新了部分页面的布局和样式,确保用户体验一致性和功能完整性。
master
前端-胡立永 4 hours ago
parent
commit
2f09085639
17 changed files with 226 additions and 32 deletions
  1. +63
    -0
      components/base/kefu.vue
  2. +17
    -5
      components/product/productItem.vue
  3. +10
    -3
      components/user/productList.vue
  4. +1
    -1
      config.js
  5. +2
    -0
      main.js
  6. +2
    -0
      pages/index/cart.vue
  7. +2
    -0
      pages/index/category.vue
  8. +6
    -6
      pages/index/center.vue
  9. +2
    -0
      pages/index/index.vue
  10. +2
    -0
      pages/index/order.vue
  11. +22
    -5
      pages_order/components/product/submit.vue
  12. +9
    -8
      pages_order/mine/partner.vue
  13. +2
    -0
      pages_order/order/createOrder.vue
  14. +2
    -0
      pages_order/order/giftList.vue
  15. +2
    -0
      pages_order/order/orderDetail.vue
  16. +55
    -4
      pages_order/product/productDetail.vue
  17. +27
    -0
      static/image/base/kefu.svg

+ 63
- 0
components/base/kefu.vue View File

@ -0,0 +1,63 @@
<template>
<view class="float-button">
<!-- <button type="default" open-type="contact" class="kf-btn">
<img src="../../static/images/details/kefu.svg" style="width: 26px;height: 36px;" alt="kefu"
srcset="">
</button> -->
<button open-type="contact" class="kf-btn">
<img src="@/static/image/base/kefu.svg" style="width: 26px;height: 36px;" alt="kefu" srcset="">
</button>
</view>
</template>
<script>
export default {
data() {
return {
};
},
methods: {
// openCustomerService() {
// uni.openCustomerServiceChat({
// //id
// corpId: 'wwccd9a21f09fed62d',
// extInfo: {
// //
// url: 'https://work.weixin.qq.com/kfid/kfc09f128696578f66d'
// },
// success: (e) => {
// console.log('e', e)
// },
// fail: (err) => {
// console.log('err', err)
// }
// })
// }
}
}
</script>
<style lang="scss">
.float-button {
position: fixed;
bottom: 150px;
/* 距离底部的距离 */
right: 10px;
/* 距离右侧的距离 */
width: 50px;
/* 按钮的宽度 */
height: 50px;
/* 按钮的高度 */
/* 其他样式 */
.kf-btn {
background-color: rgba(255, 255, 255, 1);
height: 52px;
width: 52px;
border-radius: 50%;
display: flex;
align-items: center;
}
}
</style>

+ 17
- 5
components/product/productItem.vue View File

@ -95,19 +95,23 @@
</view>
<view class="sales-volume-number">
已售出{{ item.payNum }}+
已售出{{ item.payNum }}+ | 库存{{ item.num }}
</view>
</view>
<!-- 购买按钮 -->
<view class=""
style="display: flex;justify-content: space-between;">
<view @click.stop="purchase(item.id)" class="buy-btn">
购买
<view @click.stop="item.num > 0 ? purchase(item.id) : ''"
class="buy-btn"
:class="{'disabled-btn': item.num <= 0}">
{{ item.num > 0 ? '购买' : '库存不足' }}
</view>
<view @click.stop="addCart(item)" class="buy-btn">
加入购物车
<view v-if="item.num > 0" @click.stop="item.num > 0 ? addCart(item) : ''"
class="buy-btn"
:class="{'disabled-btn': item.num <= 0}">
{{ item.num > 0 ? '加入购物车' : '库存不足' }}
</view>
</view>
</view>
@ -326,6 +330,14 @@
transition: all 0.3s;
margin-top: 4rpx;
}
//
.disabled-btn {
background: #cccccc;
color: #ffffff;
box-shadow: none;
cursor: not-allowed;
}
}
}
</style>

+ 10
- 3
components/user/productList.vue View File

@ -29,12 +29,14 @@
</view>
</view>
<view class="num">
已售卖{{ item.payNum }}+
已售卖{{ item.payNum }}+ | 库存{{ item.num }}
</view>
</view>
<view @click.stop="purchase(item.id)" class="btn">
购买
<view @click.stop="item.num > 0 ? purchase(item.id) : ''"
class="btn"
:class="{'disabled-btn': item.num <= 0}">
{{ item.num > 0 ? '购买' : '无库存' }}
</view>
</view>
</view>
@ -177,6 +179,11 @@
color: #fff;
background-color: $uni-color;
}
.disabled-btn {
background-color: #cccccc;
cursor: not-allowed;
}
}
}
}


+ 1
- 1
config.js View File

@ -6,7 +6,7 @@ import uvUI from '@/uni_modules/uv-ui-tools'
Vue.use(uvUI);
// 当前环境
const type = 'test'
const type = 'dev'
// 环境配置


+ 2
- 0
main.js View File

@ -21,9 +21,11 @@ Vue.mixin(mixinConfigList)
//组件注册
import configPopup from '@/components/config/configPopup.vue'
import navbar from '@/components/base/navbar.vue'
import kefu from '@/components/base/kefu.vue'
Vue.component('configPopup',configPopup)
Vue.component('navbar',navbar)
Vue.component('kefu',kefu)
const app = new Vue({
...App,


+ 2
- 0
pages/index/cart.vue View File

@ -94,6 +94,8 @@
</view>
</view>
</view>
<kefu></kefu>
<tabber select="cart" />
</view>


+ 2
- 0
pages/index/category.vue View File

@ -72,6 +72,8 @@
</uv-vtabs>
</view>
<kefu></kefu>
<!-- tabbar -->
<tabber select="category" />
</view>


+ 6
- 6
pages/index/center.vue View File

@ -50,7 +50,7 @@
<view @click="$utils.navigateTo({url : '/pages_order/mine/memberCenter' })"
v-if="userInfo.role != 0"
class="earnings">
<view v-if="index + 1 == userInfo.role" v-for="(item,index) in vipList" :key="item.id" class="member-item">
<view v-if="index == userInfo.role" v-for="(item,index) in vipList" :key="item.id" class="member-item">
<image :src="item.headImage" mode="aspectFill" class="member-image"></image>
<view class="member-info">
@ -67,23 +67,23 @@
</view>
<!-- 佣金数据 -->
<view @click="$utils.navigateTo('/pages_order/mine/withdraw')" class="brokerage-data"
<view class="brokerage-data"
:class="{'brokerage-data-mt' : !userInfo.role}">
<view class="brokerage">
<view class="brokerage" @click="$utils.navigateTo('/pages_order/mine/runningWater')">
<image :src="configList.money_image" mode="aspectFill" class="brokerage-img"></image>
<div class="main">
<div class="title">我的佣金</div>
<div class="money">{{ riceInfo.canWithdraw || 0 }}</div>
<div class="money">{{ riceInfo.balance|| 0 }}</div>
</div>
</view>
<view class="balance">
<view class="balance" @click="$utils.navigateTo('/pages_order/mine/withdraw')">
<image :src="configList.price_image" mode="aspectFill" class="balance-img"></image>
<div class="main">
<div class="title">我的余额</div>
<div class="money">{{ riceInfo.balance || 0 }}</div>
<div class="money">{{ riceInfo.canWithdraw || 0 }}</div>
</div>
</view>
</view>


+ 2
- 0
pages/index/index.vue View File

@ -104,6 +104,8 @@
<!-- 优惠券弹窗 -->
<couponPopup v-if="riceInfo.isGetCoupon"></couponPopup>
<kefu></kefu>
</view>
</template>


+ 2
- 0
pages/index/order.vue View File

@ -83,6 +83,8 @@
<customerServicePopup ref="customerServicePopup" />
<kefu></kefu>
<tabber select="order" />
</view>
</template>


+ 22
- 5
pages_order/components/product/submit.vue View File

@ -16,7 +16,6 @@
name="kefu-ermai"
size="45rpx"
></uv-icon>
</image>
<view class="title">
客服
</view>
@ -37,11 +36,15 @@
<view class="submit-btn">
<view class="l"
@click="$emit('addCart')">
加入购物车
@click="!disabled && $emit('addCart')"
:class="{'disabled': disabled}">
{{ disabled ? '库存不足' : '加入购物车' }}
</view>
<view class="r" @click="$emit('submit')">
{{ submiitTitle }}
<view class="r"
v-if="item.num > 0"
@click="!disabled && $emit('submit')"
:class="{'disabled': disabled}">
{{ disabled ? '库存不足' : submiitTitle }}
</view>
</view>
</view>
@ -58,6 +61,10 @@
detail: {
default: {}
},
disabled: {
type: Boolean,
default: false
}
},
data() {
return {
@ -148,6 +155,16 @@
display: flex;
justify-content: center;
align-items: center;
&.disabled {
background: #cccccc;
cursor: not-allowed;
}
}
.l.disabled {
color: #999999;
cursor: not-allowed;
}
}
}

+ 9
- 8
pages_order/mine/partner.vue View File

@ -54,7 +54,10 @@
已加入平台{{ daysBetweenDates(item.createTime,new Date().toString())}}
</view> -->
<view class="time">
加入时间{{ item.createTime }}
加入时间{{ $dayjs(item.createTime).format('YYYY-MM-DD') }}
</view>
<view class="time">
手机号{{ item.phone }}
</view>
</view>
</view>
@ -63,7 +66,7 @@
<view class="order-money">
下单量: <text>{{ item.orderNum }}</text>
</view>
<text>|</text>
|
<view class="money">
佣金:<text>{{ item.commission }}</text>
</view>
@ -263,7 +266,6 @@
box-sizing: border-box;
.brokerage-user {
width: 50%;
display: flex;
align-items: center;
flex-wrap: wrap;
@ -293,21 +295,20 @@
}
.brokerage-money {
width: 50%;
width: 260rpx;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
font-size: 24rpx;
.order-money {
text {
margin-left: 10rpx;
margin-right: 5rpx;
}
}
.money {
text {
color: #FEB814;
margin-left: 10rpx;
margin-left: 5rpx;
}
}
}


+ 2
- 0
pages_order/order/createOrder.vue View File

@ -197,6 +197,8 @@
</uv-popup>
<configPopup ref="popup"></configPopup>
<kefu></kefu>
</view>
</template>


+ 2
- 0
pages_order/order/giftList.vue View File

@ -66,6 +66,8 @@
<uv-empty mode="list" v-if="list.length === 0"></uv-empty>
</view>
</view>
<kefu></kefu>
</view>
</template>


+ 2
- 0
pages_order/order/orderDetail.vue View File

@ -191,6 +191,8 @@
</view>
</view>
<kefu></kefu>
<customerServicePopup ref="customerServicePopup" />
</view>


+ 55
- 4
pages_order/product/productDetail.vue View File

@ -65,6 +65,12 @@
</image>
</view>
</view>
<!-- 库存信息 -->
<view class="stock-info">
<text>库存: {{ productDetail.num }}</text>
<text v-if="productDetail.num <= 0" class="stock-warning">库存不足</text>
</view>
</view>
<!-- 服务 -->
@ -109,7 +115,8 @@
@toSend="toSend"
@submit="submit"
@addCart="addCart"
:detail="productDetail" />
:detail="productDetail"
:disabled="productDetail.num <= 0" />
<!-- 联系客服 -->
<customerServicePopup ref="customerServicePopup" />
@ -149,6 +156,15 @@
},
//
addCart(){
//
if(this.productDetail.num <= 0) {
uni.showToast({
title: '库存不足,无法加入购物车',
icon: 'none'
});
return;
}
this.$api('addCart', {
shopId : this.id,
num : 1,
@ -163,6 +179,15 @@
},
//
submit() {
//
if(this.productDetail.num <= 0) {
uni.showToast({
title: '库存不足,无法下单',
icon: 'none'
});
return;
}
this.$store.commit('setPayOrderProduct', [
this.productDetail
])
@ -170,6 +195,15 @@
this.$utils.navigateTo('/pages_order/order/createOrder')
},
toSend(){
//
if(this.productDetail.num <= 0) {
uni.showToast({
title: '库存不足,无法赠送',
icon: 'none'
});
return;
}
this.$store.commit('setPayOrderProduct', [
this.productDetail
])
@ -184,7 +218,11 @@
id: this.id
}, res => {
if (res.code == 200) {
res.result.num = 1
// API1
// API0
if(res.result.num === undefined) {
res.result.num = 0;
}
this.productDetail = res.result
}
})
@ -263,14 +301,13 @@
color: #f40;
font-size: 30rpx;
align-items: flex-end;
.money {
font-size: 30rpx;
.unit {
font-size: 24rpx;
}
}
.price-imgs {
display: flex;
flex-wrap: wrap;
@ -282,6 +319,20 @@
}
}
}
.stock-info {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10rpx 0;
font-size: 28rpx;
color: #666;
.stock-warning {
color: #ff0000;
font-weight: bold;
}
}
.oldPrice{
color: #999;
font-size: 24rpx;


+ 27
- 0
static/image/base/kefu.svg View File

@ -0,0 +1,27 @@
<svg xmlns="http://www.w3.org/2000/svg" width="26" height="36" viewBox="0 0 26 36" fill="none">
<path d="M16.7473 21.7889L13.252 24.5688L9.75669 21.7889C9.75669 21.7889 1.2894 18.4022 3.0651 8.16351C4.1866 1.70318 9.7193 0.0195768 13.0464 0C16.3735 0 21.9062 1.6836 23.009 8.14394C24.7847 18.4022 16.7473 21.7889 16.7473 21.7889Z" fill="#484848"/>
<path d="M13.2148 2.0179C13.3831 2.0179 13.4765 2.03748 13.4765 2.03748C13.4765 2.03748 20.4298 1.01948 22.4859 11.3169C23.1588 11.4147 23.3644 10.8666 23.3644 10.8666C23.3644 10.8666 22.5793 1.03906 13.4765 1.03906H13.2148V2.0179Z" fill="#74797D"/>
<path d="M22.8597 12.1529C23.4204 12.3095 23.5886 13.2101 23.2335 14.1497C22.8784 15.0894 22.112 15.7159 21.5512 15.5397C20.9905 15.3831 20.8223 14.4825 21.1774 13.5429C21.5326 12.6228 22.2802 11.9963 22.8597 12.1529Z" fill="#FFDDB8"/>
<path d="M3.5698 12.1169C3.00906 12.2735 2.84083 13.1936 3.19597 14.1333C3.5698 15.073 4.31747 15.719 4.87821 15.5428C5.43896 15.3862 5.60719 14.4661 5.25205 13.5264C4.9156 12.5867 4.14924 11.9407 3.5698 12.1169Z" fill="#F5D4B1"/>
<path d="M13.0278 36.0007H25.9437C25.9437 36.0007 25.3082 28.2091 16.4858 26.9954C14.0746 26.8388 13.0278 26.8975 13.0278 26.8975V36.0007Z" fill="#3B5E7C"/>
<path d="M12.9721 36.0007H0.112305C0.112305 36.0007 0.747819 28.2091 9.55156 26.9954C11.9441 26.8388 12.9908 26.8975 12.9908 26.8975V36.0007H12.9721Z" fill="#283F53"/>
<path d="M9.79443 21.9453H16.5982V32.8887H9.79443V21.9453Z" fill="#FFDDB8"/>
<path d="M9.79443 22.0254H16.5982V23.846L9.79443 27.409V22.0254Z" fill="#E5C6A5"/>
<path d="M13.0278 35.9807H15.1774C15.4577 35.5892 18.8222 27.6801 18.8035 27.5627C18.7848 27.4844 14.3923 28.3066 14.3923 28.3066L13.0278 27.4844V35.9807Z" fill="white"/>
<path d="M14.187 34.6906C14.187 34.6906 14.2805 35.6499 15.0095 34.7689C15.7384 33.888 13.2524 29.9922 13.2524 29.9922L14.187 34.6906Z" fill="#3B5E7C"/>
<path d="M13.2714 35.98H11.1219C10.8415 35.5689 7.47699 27.6795 7.49568 27.562C7.51437 27.4837 12.019 28.2864 12.019 28.2864L13.2714 27.6207V35.98Z" fill="#E0ECFF"/>
<path d="M16.7475 25.5078L19.0652 27.1523C19.0652 27.1523 19.1213 31.792 19.0652 31.6158C19.0092 31.4396 13.1587 27.6025 13.1587 27.6025L16.7475 25.5078Z" fill="white"/>
<path d="M13.4013 29.9922C13.4013 29.9922 10.9341 33.888 11.663 34.7689C12.392 35.6499 12.4855 34.6906 12.4855 34.6906L13.4013 29.9922Z" fill="#283F53"/>
<path d="M9.58877 25.5078L7.27102 27.1523C7.27102 27.1523 7.21494 31.792 7.27102 31.6158C7.32709 31.4396 13.1776 27.6025 13.1776 27.6025L9.58877 25.5078Z" fill="white"/>
<path d="M13.1777 30.4014C13.1777 30.4014 16.5235 32.9072 16.5609 31.2628V28.4437C16.5609 28.4437 16.2805 27.6607 15.0282 28.4437C13.2712 29.4617 13.1777 29.54 13.1777 29.54V30.4014Z" fill="#3B5E7C"/>
<path d="M13.3641 30.3819C13.3641 30.3819 10.0183 32.9073 9.98096 31.2629V28.4047C9.98096 28.4047 10.2613 27.6216 11.5137 28.4047C13.2707 29.4422 13.3641 29.501 13.3641 29.501V30.3819Z" fill="#283F53"/>
<path d="M3.5514 29.5195V35.9994H0C0.0186916 35.9994 0.35514 32.2603 3.5514 29.5195ZM26 35.9994H22.4486V29.5195C25.6449 32.2603 26 35.9994 26 35.9994Z" fill="#E0ECFF"/>
<path d="M5.66355 18.8499C7.15887 21.4928 11.9439 23.2155 13.1215 23.2742V5.2832C8.11214 5.2832 4.46729 9.31602 4.46729 14.2885C4.46729 15.9721 4.91588 17.4991 5.66355 18.8499Z" fill="#F5D4B1"/>
<path d="M20.5605 18.8499C19.0465 21.4928 14.2054 23.2155 13.0278 23.2742V5.2832C18.0933 5.2832 21.7755 9.31602 21.7755 14.2885C21.7755 15.9721 21.3269 17.5187 20.5605 18.8499Z" fill="#FFDDB8"/>
<path d="M16.4107 4.54303C16.4107 4.54303 12.0181 9.94622 4.59757 12.3737C2.95271 9.86791 3.32655 7.2642 3.32655 7.2642C3.32655 7.2642 9.77514 2.48747 16.4107 4.54303Z" fill="#484848"/>
<path d="M17.0091 20.1831C17.0091 20.1831 21.2334 18.4016 22.3175 16.1895C23.0278 16.3265 22.8409 16.6789 22.8409 16.6789C22.8409 16.6789 21.2708 18.8127 17.2895 20.7117C15.7194 21.1032 17.0091 20.1831 17.0091 20.1831Z" fill="#91959B"/>
<path d="M23.1773 10.808C21.4577 10.6123 21.6446 12.3546 21.4203 14.371C21.196 16.3874 20.6539 17.9535 22.3548 18.1493C24.0745 18.3451 25.6446 16.8377 25.8689 14.8017C26.1119 12.7853 24.8969 11.0038 23.1773 10.808Z" fill="#484848"/>
<path d="M2.95314 10.808C4.67276 10.6123 4.48585 12.3546 4.71015 14.371C4.93445 16.3874 5.49519 17.9535 3.77557 18.1493C2.05594 18.3451 0.485849 16.8377 0.261549 14.8017C0.0372504 12.7853 1.2522 11.0038 2.95314 10.808Z" fill="#333333"/>
<path d="M15.5332 19.4589C16.4865 19.3023 17.365 19.6547 17.5145 20.2811C17.664 20.888 17.0098 21.5341 16.0566 21.6907C15.1033 21.8473 14.2248 21.4949 14.0753 20.8684C13.9444 20.2616 14.5986 19.6351 15.5332 19.4589Z" fill="#484848"/>
<path d="M13.2711 2.0179C13.1029 2.0179 13.0094 2.03748 13.0094 2.03748C13.0094 2.03748 6.03747 0.999908 4.00009 11.3169C3.32719 11.4147 3.12158 10.8666 3.12158 10.8666C3.12158 10.8666 3.90663 1.03906 13.0094 1.03906H13.2711V2.0179Z" fill="#5F6366"/>
</svg>

Loading…
Cancel
Save