seamwang 2 vuotta sitten
vanhempi
commit
2b16829995
2 muutettua tiedostoa jossa 38 lisäystä ja 45 poistoa
  1. 4 6
      src/components/shop-cart.vue
  2. 34 39
      src/pages/class/shoppingCart.vue

+ 4 - 6
src/components/shop-cart.vue

@@ -18,20 +18,18 @@ export default {
18 18
       default: false
19 19
     }
20 20
   },
21
-  data () {
21
+  data() {
22 22
     return {
23 23
       key: 1212
24 24
     }
25 25
   },
26 26
   computed: {
27
-    ...mapGetters([
28
-      'carts'
29
-    ])
27
+    ...mapGetters(['carts'])
30 28
   },
31 29
   methods: {
32
-    goCart () {
30
+    goCart() {
33 31
       if (this.disableBtn) return false
34
-      this.$emit('changeDisableBtn')// 改变按钮点击
32
+      this.$emit('changeDisableBtn') // 改变按钮点击
35 33
       this.globalNavigateTo('classCart')
36 34
     }
37 35
   }

+ 34 - 39
src/pages/class/shoppingCart.vue

@@ -1,56 +1,55 @@
1 1
 <template>
2 2
   <view class="page">
3 3
     <cu-custom :isBack="true"></cu-custom>
4
-    <view class="header" :style="[{top:topHeader + 'px'}]">
4
+    <view class="header" :style="[{ top: topHeader + 'px' }]">
5 5
       <view class="header-title">
6 6
         <view class="header-title-main">
7
-          <view class="margin-bottom-xs">{{title}}</view>
7
+          <view class="margin-bottom-xs">{{ title }}</view>
8 8
           <view class="point"></view>
9 9
         </view>
10 10
       </view>
11 11
     </view>
12
-    <scroll-view scroll-y="true" :style="[{height:'calc(100vh - 64px - 70px - '+ topHeader+'px)'}]" class="scroll-main">
12
+    <scroll-view scroll-y="true" :style="[{ height: 'calc(100vh - 64px - 70px - ' + topHeader + 'px)' }]" class="scroll-main">
13 13
       <view class="list">
14 14
         <checkbox-group @change="checkChange">
15
-          <view class="cu-card margin-bottom shadow" v-for="(item,index) in list" :key="index">
15
+          <view class="cu-card margin-bottom shadow" v-for="(item, index) in list" :key="index">
16 16
             <label class="cu-item">
17 17
               <view class="card-header flex justify-between solid-bottom">
18 18
                 <view>
19
-                  <checkbox style="transform:scale(0.8)" class="round" :value="item.shopping_id"
20
-                    :checked="checkedIds.includes(item.shopping_id)"></checkbox>
21
-                  {{item.student_name}}
19
+                  <checkbox style="transform: scale(0.8);" class="round" :value="item.shopping_id" :checked="checkedIds.includes(item.shopping_id)"></checkbox>
20
+                  {{ item.student_name }}
22 21
                 </view>
23
-                <view @tap.stop=''>
24
-                  <text class="cuIcon-delete text-red" @tap="del(item,index)"></text>
22
+                <view @tap.stop="">
23
+                  <text class="cuIcon-delete text-red" @tap="del(item, index)"></text>
25 24
                 </view>
26 25
               </view>
27 26
               <view class="card flex">
28 27
                 <view class="card-left">
29
-                  <img mode="scaleToFill" :src="item.image" alt="" class="card-image">
28
+                  <img mode="scaleToFill" :src="item.image" alt="" class="card-image" />
30 29
                 </view>
31 30
                 <view class="card-right flex-sub margin-left-sm text-sm">
32
-                  <view class="card-title">{{item.class_attend_name}}</view>
33
-                  <view class="text-price text-student text-xl margin-top-xs">{{item.price}}</view>
31
+                  <view class="card-title">{{ item.class_attend_name }}</view>
32
+                  <view class="text-price text-student text-xl margin-top-xs">{{ item.price }}</view>
34 33
                   <view class="card-item">
35 34
                     <text class="card-label">机构:</text>
36
-                    <text class="card-text">{{item.agency_name||'-'}}</text>
35
+                    <text class="card-text">{{ item.agency_name || '-' }}</text>
37 36
                   </view>
38
-                  <view class="card-item margin-top-xs" v-if="item.cate_type===0">
37
+                  <view class="card-item margin-top-xs" v-if="item.cate_type === 0">
39 38
                     <text class="card-label">老师:</text>
40
-                    <text class="card-text">{{item.teacher_name||'-'}}</text>
39
+                    <text class="card-text">{{ item.teacher_name || '-' }}</text>
41 40
                   </view>
42 41
                   <view class="card-item margin-top-xs">
43 42
                     <text class="card-label">总共:</text>
44
-                    <text class="card-text">{{item.class_total||'-'}}</text>
43
+                    <text class="card-text">{{ item.class_total || '-' }}</text>
45 44
                   </view>
46 45
                   <view class="card-item margin-top-xs">
47 46
                     <text class="card-label">时间:</text>
48
-                    <text class="card-text">{{item.week_limit||'-'}}</text>
47
+                    <text class="card-text">{{ item.week_limit || '-' }}</text>
49 48
                   </view>
50 49
                 </view>
51 50
               </view>
52 51
               <view class="card-footer margin-top-xs" v-if="item.prop">
53
-                <view v-for="(tag,index) in item.prop" :key="index" class="cu-tag line-red">{{tag}}</view>
52
+                <view v-for="(tag, index) in item.prop" :key="index" class="cu-tag line-red">{{ tag }}</view>
54 53
               </view>
55 54
               <view class="card-bottom margin-top-xs">
56 55
                 <!-- <button @tap="pay(item)" class="cu-btn round bg-student text-white">立即下单</button> -->
@@ -63,14 +62,11 @@
63 62
     <view class="static flex shadow">
64 63
       <view class="static-price">
65 64
         <checkbox-group @change="chooseAll">
66
-          <label>
67
-            <checkbox class="round" :checked="checkAll" style="transform:scale(0.8);" />全选
68
-          </label>
65
+          <label class="padding-tb-sm"> <checkbox class="round" :checked="checkAll" style="transform: scale(0.8);" />全选 </label>
69 66
         </checkbox-group>
70 67
       </view>
71
-      <view class="static-choose text-center" v-if="checkedIds.length>0">
72
-        <text>已选:</text><text class="margin-right-xs">{{checkedIds.length}}</text>
73
-        <text>总价:</text><text class="text-price text-red">{{sum}}</text>
68
+      <view class="static-choose text-center" v-if="checkedIds.length > 0">
69
+        <text>已选:</text><text class="margin-right-xs">{{ checkedIds.length }}</text> <text>总价:</text><text class="text-price text-red">{{ sum }}</text>
74 70
       </view>
75 71
       <view class="static-order flex align-center">
76 72
         <button class="cu-btn round bg-student text-white margin-left-xs" @tap="pay">立即下单</button>
@@ -86,7 +82,7 @@ import { deepClone } from '@/common/utils'
86 82
 import NP from 'number-precision'
87 83
 import socket from '@/common/webSocket'
88 84
 export default {
89
-  data () {
85
+  data() {
90 86
     return {
91 87
       title: '购物车',
92 88
       topHeader: this.globalCustomBarHeight,
@@ -99,41 +95,39 @@ export default {
99 95
     }
100 96
   },
101 97
   computed: {
102
-    ...mapGetters([
103
-      'carts', 'phone', 'ifConnectOrder'
104
-    ])
98
+    ...mapGetters(['carts', 'phone', 'ifConnectOrder'])
105 99
   },
106
-  onShow () {
100
+  onShow() {
107 101
     this.get_list()
108 102
   },
109
-  onLoad (options) {
103
+  onLoad(options) {
110 104
     socket.initSocket()
111 105
   },
112 106
   methods: {
113
-    checkChange (e) {
107
+    checkChange(e) {
114 108
       this.checkedIds = e.detail.value.map(x => Number(x))
115 109
       this.shoppingList = this.list.filter(item => this.checkedIds.includes(item.shopping_id))
116 110
       this.sum_money()
117 111
     },
118
-    chooseAll () {
112
+    chooseAll() {
119 113
       this.checkAll = !this.checkAll
120 114
       this.checkedIds = this.checkAll ? this.all : []
121 115
       this.shoppingList = this.checkAll ? deepClone(this.list) : []
122 116
       this.sum_money()
123 117
     },
124
-    sum_money () {
118
+    sum_money() {
125 119
       const arr = this.shoppingList.map(item => item.price)
126 120
       this.sum = arr.reduce((x, y) => NP.plus(x, y), 0)
127 121
     },
128
-    get_list () {
122
+    get_list() {
129 123
       _shopList().then(res => {
130 124
         this.list = res.data
131
-        this.all = this.list.map(item => item.shopping_id)// 统计全部
125
+        this.all = this.list.map(item => item.shopping_id) // 统计全部
132 126
         const carts = this.list.map(item => item.class_attend_id)
133
-        this.$store.dispatch('setCarts', carts)// 刷新购物车
127
+        this.$store.dispatch('setCarts', carts) // 刷新购物车
134 128
       })
135 129
     },
136
-    del (item, index) {
130
+    del(item, index) {
137 131
       const _self = this
138 132
       uni.showModal({
139 133
         title: '提示',
@@ -149,7 +143,7 @@ export default {
149 143
         }
150 144
       })
151 145
     },
152
-    pay () {
146
+    pay() {
153 147
       if (!this.phone) {
154 148
         return this.globalNavigateTo('bindPhone')
155 149
       }
@@ -168,7 +162,8 @@ export default {
168 162
       _createOrder({ result: order, notShowLoading: true }).then(res => {
169 163
         this.$store.dispatch('setCarts', carts)
170 164
         setTimeout(() => {
171
-          if (!this.ifConnectOrder) { // socket非正常状态
165
+          if (!this.ifConnectOrder) {
166
+            // socket非正常状态
172 167
             uni.hideLoading()
173 168
             this.globalNavigateTo('order', { type: 1 })
174 169
           }