seamwang il y a 2 ans
Parent
commit
c908b0649c

+ 45 - 45
src/components/shop-cart.vue

@@ -1,45 +1,45 @@
1
-<template>
2
-	<view class="shop" @tap="goCart">
3
-		<view class="cu-tag badge" v-if="carts.includes(class_attend_id)"></view>
4
-		<text class="cuIcon-cart text-student cart"></text>
5
-	</view>
6
-</template>
7
-
8
-<script>
9
-import { mapGetters } from 'vuex'
10
-export default {
11
-  props: {
12
-    class_attend_id: {
13
-      type: Number,
14
-      default: 0
15
-    }
16
-  },
17
-  data() {
18
-    return {
19
-      key: 1212
20
-    }
21
-  },
22
-  computed: {
23
-    ...mapGetters([
24
-      'carts'
25
-    ])
26
-  },
27
-  methods: {
28
-    goCart() {
29
-      this.globalNavigateTo('classCart')
30
-    }
31
-  }
32
-}
33
-</script>
34
-
35
-<style lang="scss" scoped>
36
-.shop{
37
-	position:relative;
38
-}
39
-.cart{
40
-	font-size:24px;
41
-}
42
-.cu-tag.badge{
43
-	top:2px;
44
-}
45
-</style>
1
+<template>
2
+	<view class="shop" @tap="goCart">
3
+		<view class="cu-tag badge" v-if="carts.includes(class_attend_id)"></view>
4
+		<text class="cuIcon-cart text-student cart"></text>
5
+	</view>
6
+</template>
7
+
8
+<script>
9
+import { mapGetters } from 'vuex'
10
+export default {
11
+  props: {
12
+    class_attend_id: {
13
+      type: Number,
14
+      default: 0
15
+    }
16
+  },
17
+  data() {
18
+    return {
19
+      key: 1212
20
+    }
21
+  },
22
+  computed: {
23
+    ...mapGetters([
24
+      'carts'
25
+    ])
26
+  },
27
+  methods: {
28
+    goCart() {
29
+      this.globalNavigateTo('classCart')
30
+    }
31
+  }
32
+}
33
+</script>
34
+
35
+<style lang="scss" scoped>
36
+.shop{
37
+	position:relative;
38
+}
39
+.cart{
40
+	font-size:24px;
41
+}
42
+.cu-tag.badge{
43
+	top:2px;
44
+}
45
+</style>

+ 5 - 3
src/pages/class/detail.vue

@@ -281,7 +281,6 @@ export default {
281 281
       if (this.carts.includes(this.attend_id)) {
282 282
         uni.showToast({ title: '课程已存在,请勿重复添加!', icon: 'none' })
283 283
         setTimeout(() => {
284
-          // this.disableBtn = false
285 284
           this.globalNavigateTo('classCart')
286 285
         }, 1000)
287 286
         return false
@@ -293,8 +292,11 @@ export default {
293 292
       }
294 293
       const props = this.goods.props.join(',')
295 294
       _joinShop({ class_attend_id: this.attend_id, prop: props }).then(res => {
296
-        // this.disableBtn = false
297
-        this.globalNavigateTo('classCart')
295
+        if (res.code === 1) {
296
+          this.globalNavigateTo('classCart')
297
+        } else {
298
+          this.disableBtn = false
299
+        }
298 300
       })
299 301
     },
300 302
     setDefaultGoods(props) {

+ 2 - 2
src/pages/class/shoppingCart.vue

@@ -85,7 +85,7 @@ export default {
85 85
     get_list() {
86 86
       _shopList().then(res => {
87 87
         this.list = res.data
88
-        const carts = this.list.map(item => item.class_attend_id)
88
+        const carts = this.list.map(item => Number(item.class_attend_id))
89 89
         this.$store.dispatch('setCarts', carts)// 刷新购物车
90 90
       })
91 91
     },
@@ -108,7 +108,7 @@ export default {
108 108
     pay(item) {
109 109
       const order = JSON.stringify([item])
110 110
       let carts = deepClone(this.carts)
111
-      const index = carts.indexOf(item.class_attend_id)
111
+      const index = carts.indexOf(Number(item.class_attend_id))
112 112
       carts = carts.splice(index, 1)
113 113
       if (!this.phone) {
114 114
         return this.globalNavigateTo('bindPhone')

+ 1 - 1
src/pages/myStudents/myStudents.vue

@@ -213,7 +213,7 @@ export default {
213 213
     },
214 214
     setCarts() { // 刷新购物车
215 215
       _shopList().then(res => {
216
-        const carts = res.data.map(item => item.class_attend_id)
216
+        const carts = res.data.map(item => Number(item.class_attend_id))
217 217
         this.$store.dispatch('setCarts', carts)
218 218
       })
219 219
     },

+ 1 - 1
src/pages/studentcenter/index.vue

@@ -96,7 +96,7 @@
96 96
 											<text class="card-label">机构:</text>
97 97
 										 	<text class="card-text">{{item.agency_name||'-'}}</text>
98 98
 									  </view>
99
-										<view class="card-item margin-top-xs" >
99
+										<view class="card-item margin-top-xs">
100 100
 											<text class="card-label">老师:</text>
101 101
 										 	<text class="card-text">{{item.teacher||'-'}}</text>
102 102
 									  </view>