From 59df75db03ab719ec68739aa92f18cb6857f8e99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TOP=E7=B3=AF=E7=B1=B3?= <1130395124@qq.com> Date: Fri, 7 Apr 2023 14:54:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9C=8D=E5=8A=A1=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E4=B8=8B=E5=8D=95=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/service/list.vue | 50 ++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/src/pages/service/list.vue b/src/pages/service/list.vue index bec9b2c..ec5551a 100644 --- a/src/pages/service/list.vue +++ b/src/pages/service/list.vue @@ -19,7 +19,7 @@ {{ cartCount }} - + 去下单 @@ -37,7 +37,7 @@ export default { utils: this.$utils, pageConfig: {}, data: [], - + canUse: false, currentId: 0, }; }, @@ -54,18 +54,7 @@ export default { }), }, onLoad(e) { - this.pageConfig = getApp().globalData.pageConfig; - if (this.isLogin) { - this.$store.dispatch("cart/updateCount"); - this.$store.dispatch("cart/briefCart"); - } - - if (!e.id) { - this.$utils.toast("参数错误"); - return; - } - this.currentId = e.id; - this.loadList(this.currentId); + this.initPage(e); }, onShow() {}, onReady() {}, @@ -73,7 +62,30 @@ export default { onPullDownRefresh() {}, onShareTimeline() {}, onShareAppMessage() {}, + watch: { + cartCount(count) { + this.canUse = count > 0; + }, + }, methods: { + /** + * 初始化页面 + */ + initPage(e) { + this.pageConfig = getApp().globalData.pageConfig; + if (this.isLogin) { + this.$store.dispatch("cart/updateCount"); + this.$store.dispatch("cart/briefCart"); + } + this.canUse = this.cartCount > 0; + if (!e.id) { + return this.$utils.toast("参数错误"); + } + this.currentId = e.id; + // 初始化列表 + this.data = []; + this.loadList(this.currentId); + }, /** * 加载列表 */ @@ -134,10 +146,8 @@ export default { * 去下单 */ toCart() { - if (this.cartCount > 0) { + if (this.canUse) { this.$utils.toPage("/pages/service/cart"); - } else { - this.$utils.toast("请添加服务到购物车"); } }, }, @@ -188,13 +198,17 @@ export default { width: 300rpx; height: 75rpx; text-align: center; - background: linear-gradient(-90deg, #8194f2, #4c60c1); border-radius: 38rpx; + background: #e0e0e0; + transition: all 0.35s; .text { font-size: 30rpx; color: #ffffff; line-height: 75rpx; } } + .order-btn.active { + background: linear-gradient(-90deg, #8194f2, #4c60c1); + } } \ No newline at end of file