Browse Source

no message

seamwang 2 years ago
parent
commit
2b16829995
2 changed files with 38 additions and 45 deletions
  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
       default: false
18
       default: false
19
     }
19
     }
20
   },
20
   },
21
-  data () {
21
+  data() {
22
     return {
22
     return {
23
       key: 1212
23
       key: 1212
24
     }
24
     }
25
   },
25
   },
26
   computed: {
26
   computed: {
27
-    ...mapGetters([
28
-      'carts'
29
-    ])
27
+    ...mapGetters(['carts'])
30
   },
28
   },
31
   methods: {
29
   methods: {
32
-    goCart () {
30
+    goCart() {
33
       if (this.disableBtn) return false
31
       if (this.disableBtn) return false
34
-      this.$emit('changeDisableBtn')// 改变按钮点击
32
+      this.$emit('changeDisableBtn') // 改变按钮点击
35
       this.globalNavigateTo('classCart')
33
       this.globalNavigateTo('classCart')
36
     }
34
     }
37
   }
35
   }

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

@@ -1,56 +1,55 @@
1
 <template>
1
 <template>
2
   <view class="page">
2
   <view class="page">
3
     <cu-custom :isBack="true"></cu-custom>
3
     <cu-custom :isBack="true"></cu-custom>
4
-    <view class="header" :style="[{top:topHeader + 'px'}]">
4
+    <view class="header" :style="[{ top: topHeader + 'px' }]">
5
       <view class="header-title">
5
       <view class="header-title">
6
         <view class="header-title-main">
6
         <view class="header-title-main">
7
-          <view class="margin-bottom-xs">{{title}}</view>
7
+          <view class="margin-bottom-xs">{{ title }}</view>
8
           <view class="point"></view>
8
           <view class="point"></view>
9
         </view>
9
         </view>
10
       </view>
10
       </view>
11
     </view>
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
       <view class="list">
13
       <view class="list">
14
         <checkbox-group @change="checkChange">
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
             <label class="cu-item">
16
             <label class="cu-item">
17
               <view class="card-header flex justify-between solid-bottom">
17
               <view class="card-header flex justify-between solid-bottom">
18
                 <view>
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
                 </view>
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
                 </view>
24
                 </view>
26
               </view>
25
               </view>
27
               <view class="card flex">
26
               <view class="card flex">
28
                 <view class="card-left">
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
                 </view>
29
                 </view>
31
                 <view class="card-right flex-sub margin-left-sm text-sm">
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
                   <view class="card-item">
33
                   <view class="card-item">
35
                     <text class="card-label">机构:</text>
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
                   </view>
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
                     <text class="card-label">老师:</text>
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
                   </view>
40
                   </view>
42
                   <view class="card-item margin-top-xs">
41
                   <view class="card-item margin-top-xs">
43
                     <text class="card-label">总共:</text>
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
                   </view>
44
                   </view>
46
                   <view class="card-item margin-top-xs">
45
                   <view class="card-item margin-top-xs">
47
                     <text class="card-label">时间:</text>
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
                   </view>
48
                   </view>
50
                 </view>
49
                 </view>
51
               </view>
50
               </view>
52
               <view class="card-footer margin-top-xs" v-if="item.prop">
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
               </view>
53
               </view>
55
               <view class="card-bottom margin-top-xs">
54
               <view class="card-bottom margin-top-xs">
56
                 <!-- <button @tap="pay(item)" class="cu-btn round bg-student text-white">立即下单</button> -->
55
                 <!-- <button @tap="pay(item)" class="cu-btn round bg-student text-white">立即下单</button> -->
@@ -63,14 +62,11 @@
63
     <view class="static flex shadow">
62
     <view class="static flex shadow">
64
       <view class="static-price">
63
       <view class="static-price">
65
         <checkbox-group @change="chooseAll">
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
         </checkbox-group>
66
         </checkbox-group>
70
       </view>
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
       </view>
70
       </view>
75
       <view class="static-order flex align-center">
71
       <view class="static-order flex align-center">
76
         <button class="cu-btn round bg-student text-white margin-left-xs" @tap="pay">立即下单</button>
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
 import NP from 'number-precision'
82
 import NP from 'number-precision'
87
 import socket from '@/common/webSocket'
83
 import socket from '@/common/webSocket'
88
 export default {
84
 export default {
89
-  data () {
85
+  data() {
90
     return {
86
     return {
91
       title: '购物车',
87
       title: '购物车',
92
       topHeader: this.globalCustomBarHeight,
88
       topHeader: this.globalCustomBarHeight,
@@ -99,41 +95,39 @@ export default {
99
     }
95
     }
100
   },
96
   },
101
   computed: {
97
   computed: {
102
-    ...mapGetters([
103
-      'carts', 'phone', 'ifConnectOrder'
104
-    ])
98
+    ...mapGetters(['carts', 'phone', 'ifConnectOrder'])
105
   },
99
   },
106
-  onShow () {
100
+  onShow() {
107
     this.get_list()
101
     this.get_list()
108
   },
102
   },
109
-  onLoad (options) {
103
+  onLoad(options) {
110
     socket.initSocket()
104
     socket.initSocket()
111
   },
105
   },
112
   methods: {
106
   methods: {
113
-    checkChange (e) {
107
+    checkChange(e) {
114
       this.checkedIds = e.detail.value.map(x => Number(x))
108
       this.checkedIds = e.detail.value.map(x => Number(x))
115
       this.shoppingList = this.list.filter(item => this.checkedIds.includes(item.shopping_id))
109
       this.shoppingList = this.list.filter(item => this.checkedIds.includes(item.shopping_id))
116
       this.sum_money()
110
       this.sum_money()
117
     },
111
     },
118
-    chooseAll () {
112
+    chooseAll() {
119
       this.checkAll = !this.checkAll
113
       this.checkAll = !this.checkAll
120
       this.checkedIds = this.checkAll ? this.all : []
114
       this.checkedIds = this.checkAll ? this.all : []
121
       this.shoppingList = this.checkAll ? deepClone(this.list) : []
115
       this.shoppingList = this.checkAll ? deepClone(this.list) : []
122
       this.sum_money()
116
       this.sum_money()
123
     },
117
     },
124
-    sum_money () {
118
+    sum_money() {
125
       const arr = this.shoppingList.map(item => item.price)
119
       const arr = this.shoppingList.map(item => item.price)
126
       this.sum = arr.reduce((x, y) => NP.plus(x, y), 0)
120
       this.sum = arr.reduce((x, y) => NP.plus(x, y), 0)
127
     },
121
     },
128
-    get_list () {
122
+    get_list() {
129
       _shopList().then(res => {
123
       _shopList().then(res => {
130
         this.list = res.data
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
         const carts = this.list.map(item => item.class_attend_id)
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
       const _self = this
131
       const _self = this
138
       uni.showModal({
132
       uni.showModal({
139
         title: '提示',
133
         title: '提示',
@@ -149,7 +143,7 @@ export default {
149
         }
143
         }
150
       })
144
       })
151
     },
145
     },
152
-    pay () {
146
+    pay() {
153
       if (!this.phone) {
147
       if (!this.phone) {
154
         return this.globalNavigateTo('bindPhone')
148
         return this.globalNavigateTo('bindPhone')
155
       }
149
       }
@@ -168,7 +162,8 @@ export default {
168
       _createOrder({ result: order, notShowLoading: true }).then(res => {
162
       _createOrder({ result: order, notShowLoading: true }).then(res => {
169
         this.$store.dispatch('setCarts', carts)
163
         this.$store.dispatch('setCarts', carts)
170
         setTimeout(() => {
164
         setTimeout(() => {
171
-          if (!this.ifConnectOrder) { // socket非正常状态
165
+          if (!this.ifConnectOrder) {
166
+            // socket非正常状态
172
             uni.hideLoading()
167
             uni.hideLoading()
173
             this.globalNavigateTo('order', { type: 1 })
168
             this.globalNavigateTo('order', { type: 1 })
174
           }
169
           }