瀏覽代碼

no message

seamwang 2 年之前
父節點
當前提交
289d44e044
共有 5 個文件被更改,包括 190 次插入87 次删除
  1. 3 0
      src/common/webSocket.js
  2. 117 45
      src/pages/class/shoppingCart.vue
  3. 58 40
      src/pages/order/index.vue
  4. 2 2
      src/pages/studentcenter/evaluate.vue
  5. 10 0
      src/store/user.js

+ 3 - 0
src/common/webSocket.js

@@ -18,6 +18,9 @@ const socket = {
18 18
         uni.showToast({ title: message.msg, icon: 'none', duration: 2000 })
19 19
         return false
20 20
       }
21
+      if (message.push_type === 'reload_order') {
22
+        store.dispatch('setReload', true)
23
+      }
21 24
       if (message.push_type === 'order') {
22 25
         uni.hideLoading()
23 26
         store.dispatch('setConnect', true)

+ 117 - 45
src/pages/class/shoppingCart.vue

@@ -10,52 +10,78 @@
10 10
 			</view>
11 11
 		</view>
12 12
 			<scroll-view  scroll-y="true"
13
-			:style="[{height:'calc(100vh - 64px - '+ topHeader+'px)'}]"
13
+			:style="[{height:'calc(100vh - 64px - 70px - '+ topHeader+'px)'}]"
14 14
 			class="scroll-main">
15 15
 				<view class="list">
16
-					<view class="cu-card margin-bottom shadow" v-for="(item,index) in list" :key="index">
17
-						<view class="cu-item">
18
-							<view class="card-header flex justify-between solid-bottom">
19
-								 <view>{{item.student_name}}</view>
20
-								 <view>
21
-									  <text class="cuIcon-delete text-red" @tap="del(item,index)"></text>
22
-								 </view>
23
-							</view>
24
-							<view class="card flex">
25
-								<view class="card-left">
26
-									<img mode="scaleToFill" :src="item.image" alt="" class="card-image">
27
-								</view>
28
-								<view class="card-right flex-sub margin-left-sm">
29
-									<view class="card-title">{{item.class_attend_name}}</view>
30
-									<view class="text-price text-student text-xl margin-top-xs">{{item.price}}</view>
31
-									<view class="card-item">
32
-										 <text class="card-label">机构:</text>
33
-										 <text class="card-text">{{item.agency_name||'-'}}</text>
16
+					<checkbox-group @change="checkChange">
17
+						<view class="cu-card margin-bottom shadow" v-for="(item,index) in list" :key="index">
18
+							<!-- <label class="cu-item"> -->
19
+								<label class="cu-item">
20
+									<view class="card-header flex justify-between solid-bottom">
21
+										<view>
22
+											<checkbox style="transform:scale(0.7)"  :value="item.shopping_id" :checked="checkedIds.includes(item.shopping_id)"></checkbox>
23
+											<!-- <checkbox
24
+											style="transform:scale(0.7)"
25
+											:value="item.shopping_id" :checked="checked.includes(item.shopping_id)"></checkbox> -->
26
+											{{item.student_name}}
27
+										</view>
28
+										<view @tap.stop=''>
29
+												<text class="cuIcon-delete text-red" @tap="del(item,index)"></text>
30
+										</view>
34 31
 									</view>
35
-									<view class="card-item margin-top-xs" v-if="item.cate_type===0">
36
-										 <text class="card-label">老师:</text>
37
-										 <text class="card-text">{{item.teacher_name||'-'}}</text>
32
+									<view class="card flex">
33
+										<view class="card-left">
34
+											<img mode="scaleToFill" :src="item.image" alt="" class="card-image">
35
+										</view>
36
+										<view class="card-right flex-sub margin-left-sm">
37
+											<view class="card-title">{{item.class_attend_name}}</view>
38
+											<view class="text-price text-student text-xl margin-top-xs">{{item.price}}</view>
39
+											<view class="card-item">
40
+												<text class="card-label">机构:</text>
41
+												<text class="card-text">{{item.agency_name||'-'}}</text>
42
+											</view>
43
+											<view class="card-item margin-top-xs" v-if="item.cate_type===0">
44
+												<text class="card-label">老师:</text>
45
+												<text class="card-text">{{item.teacher_name||'-'}}</text>
46
+											</view>
47
+											<view class="card-item margin-top-xs">
48
+												<text class="card-label">总共:</text>
49
+												<text class="card-text">{{item.class_total||'-'}}</text>
50
+											</view>
51
+											<view class="card-item margin-top-xs">
52
+												<text class="card-label">时间:</text>
53
+												<text class="card-text">{{item.week_limit||'-'}}</text>
54
+											</view>
55
+										</view>
38 56
 									</view>
39
-									<view class="card-item margin-top-xs">
40
-										 <text class="card-label">总共:</text>
41
-										 <text class="card-text">{{item.class_total||'-'}}</text>
57
+									<view class="card-footer margin-top-xs" v-if="item.prop">
58
+										<view v-for="(tag,index) in item.prop" :key="index" class="cu-tag line-red">{{tag}}</view>
42 59
 									</view>
43
-									<view class="card-item margin-top-xs">
44
-										 <text class="card-label">时间:</text>
45
-										 <text class="card-text">{{item.week_limit||'-'}}</text>
60
+									<view class="card-bottom margin-top-xs">
61
+										<!-- <button @tap="pay(item)" class="cu-btn round bg-student text-white">立即下单</button> -->
46 62
 									</view>
47
-								</view>
48
-							</view>
49
-							<view class="card-footer margin-top-xs" v-if="item.prop">
50
-								<view v-for="(tag,index) in item.prop" :key="index" class="cu-tag line-red">{{tag}}</view>
51
-							</view>
52
-							<view class="card-bottom margin-top-xs">
53
-								<button @tap="pay(item)" class="cu-btn round bg-student text-white">立即下单</button>
54
-							</view>
63
+								</label>
64
+							<!-- </label> -->
55 65
 						</view>
56
-					</view>
66
+					</checkbox-group>
57 67
 				</view>
58 68
 			</scroll-view>
69
+			<view class="static flex shadow">
70
+				<view class="static-price">
71
+				  <checkbox-group @change="chooseAll">
72
+						<label>
73
+							<checkbox  :checked="checkAll" style="transform:scale(0.7);"/>全选
74
+						</label>
75
+				  </checkbox-group>
76
+				</view>
77
+				<view class="static-choose  text-ellipsis" v-if="checkedIds.length>0">
78
+					  <text>已选:</text><text class="margin-right-xs">{{checkedIds.length}}</text>
79
+						<text>总价:</text><text class="text-price text-red">{{sum}}</text>
80
+				</view>
81
+				<view class="static-order flex align-center">
82
+					<button class="cu-btn round bg-student text-white margin-left-xs" @tap="pay">立即下单</button>
83
+				</view>
84
+		  </view>
59 85
 	</view>
60 86
 </template>
61 87
 
@@ -63,13 +89,19 @@
63 89
 import { _shopList, _delShop, _createOrder } from '@/api/course'
64 90
 import { mapGetters } from 'vuex'
65 91
 import { deepClone } from '@/common/utils'
92
+import NP from 'number-precision'
66 93
 import socket from '@/common/webSocket'
67 94
 export default {
68 95
   data() {
69 96
     return {
70 97
       title: '购物车',
71 98
       topHeader: this.globalCustomBarHeight,
72
-      list: []
99
+      list: [],
100
+      checkedIds: [], // 已选择
101
+      shoppingList: [], // 购物车列表
102
+      sum: 0,
103
+      all: [], // 全部
104
+      checkAll: false
73 105
     }
74 106
   },
75 107
   computed: {
@@ -82,9 +114,25 @@ export default {
82 114
     socket.initSocket()
83 115
   },
84 116
   methods: {
117
+    checkChange(e) {
118
+      this.checkedIds = e.detail.value.map(x => Number(x))
119
+      this.shoppingList = this.list.filter(item => this.checkedIds.includes(item.shopping_id))
120
+      this.sum_money()
121
+    },
122
+    chooseAll() {
123
+      this.checkAll = !this.checkAll
124
+      this.checkedIds = this.checkAll ? this.all : []
125
+      this.shoppingList = this.checkAll ? deepClone(this.list) : []
126
+      this.sum_money()
127
+    },
128
+    sum_money() {
129
+      const arr = this.shoppingList.map(item => item.price)
130
+      this.sum = arr.reduce((x, y) => NP.plus(x, y), 0)
131
+    },
85 132
     get_list() {
86 133
       _shopList().then(res => {
87 134
         this.list = res.data
135
+        this.all = this.list.map(item => item.shopping_id)// 统计全部
88 136
         const carts = this.list.map(item => item.class_attend_id)
89 137
         this.$store.dispatch('setCarts', carts)// 刷新购物车
90 138
       })
@@ -105,18 +153,22 @@ export default {
105 153
         }
106 154
       })
107 155
     },
108
-    pay(item) {
156
+    pay() {
157
+      if (!this.phone) {
158
+        return this.globalNavigateTo('bindPhone')
159
+      }
160
+      if (this.checkedIds.length < 1) {
161
+        uni.showToast({ title: '请先选择课程', icon: 'none', duration: 1000 })
162
+        return false
163
+      }
109 164
       uni.showLoading({
110 165
         mask: true,
111 166
         title: '加载中...'
112 167
       })
113
-      const order = JSON.stringify([item])
168
+      const order = JSON.stringify(this.shoppingList)
114 169
       let carts = deepClone(this.carts)
115
-      const index = carts.indexOf(item.class_attend_id)
116
-      carts = carts.splice(index, 1)
117
-      if (!this.phone) {
118
-        return this.globalNavigateTo('bindPhone')
119
-      }
170
+      const shoppingCarts = this.shoppingList.map(item => item.class_attend_id)
171
+      carts = carts.filter(item => !shoppingCarts.includes(item))
120 172
       _createOrder({ result: order, notShowLoading: true }).then(res => {
121 173
         this.$store.dispatch('setCarts', carts)
122 174
         setTimeout(() => {
@@ -168,4 +220,24 @@ export default {
168 220
 .card-bottom{
169 221
 	text-align:right;
170 222
 }
223
+.static{
224
+    position: fixed;
225
+    left: 0;
226
+    right: 0;
227
+    bottom: 0;
228
+    display: flex;
229
+    background: #fff;
230
+    height: 70px;
231
+    align-items: center;
232
+    padding: 0 0.8rem;
233
+    justify-content: space-between;
234
+		&-price{
235
+			font-size:14px;
236
+		}
237
+		&-choose{
238
+      color: #666;
239
+    	width: calc(100vw - 240px);
240
+		}
241
+}
242
+
171 243
 </style>

+ 58 - 40
src/pages/order/index.vue

@@ -17,53 +17,57 @@
17 17
 		@refresherrefresh="onRefresh" @scrolltolower="loadMore">
18 18
 			<view class="list" v-if="params.type<7">
19 19
 				<view class="cu-card margin-top margin-bottom shadow" v-for="(item,index) in list" :key="index">
20
-					<view class="cu-item" v-for="(course,i) in item.list" :key="i">
21
-							<view class="card-header flex justify-between solid-bottom">
22
-								 <view>{{index}}</view>
23
-								 <view class="text-student course-status">
24
-									  {{item.status|status}}
25
-								 </view>
20
+					<view class="cu-item">
21
+						<view class="card-header flex justify-between solid-bottom">
22
+							<view>{{index}}</view>
23
+							<view class="text-student course-status">
24
+									{{item.status|status}}
26 25
 							</view>
27
-							<view class="card flex">
28
-								<view class="card-left">
29
-									<img mode="scaleToFill" :src="course.image" alt="" class="card-image">
30
-								</view>
31
-								<view class="card-right flex-sub margin-left-sm">
32
-									<view class="card-title">{{course.name}}</view>
33
-									<view class="card-item margin-top-xs">
34
-										 <text class="card-label">时间:</text>
35
-										 <text class="card-text">{{course.attend_day}}</text>
36
-									</view>
37
-									<view class="card-item margin-top-xs" >
38
-										 <text class="card-label">课时:</text>
39
-										 <text class="card-text">{{course.class_total}}</text>
40
-									</view>
41
-									<view class="card-item margin-top-xs">
42
-										 <text class="card-label">学生:</text>
43
-										 <text class="card-text">{{course.student_name}}</text>
26
+						</view>
27
+						<view class="card-center" v-for="(course,i) in item.list" :key="i">
28
+								<view class="card flex">
29
+									<view class="card-left">
30
+										<img mode="scaleToFill" :src="course.image" alt="" class="card-image">
44 31
 									</view>
45
-									<view class="card-item margin-top-xs">
46
-										 <text class="card-label">老师:</text>
47
-										 <text class="card-text">{{course.teacher||'--'}}</text>
32
+									<view class="card-right flex-sub margin-left-sm">
33
+										<view class="card-title">{{course.name}}</view>
34
+										<view class="card-item margin-top-xs">
35
+											<text class="card-label">时间:</text>
36
+											<text class="card-text">{{course.attend_day}}</text>
37
+										</view>
38
+										<view class="card-item margin-top-xs" >
39
+											<text class="card-label">课时:</text>
40
+											<text class="card-text">{{course.class_total}}</text>
41
+										</view>
42
+										<view class="card-item margin-top-xs">
43
+											<text class="card-label">学生:</text>
44
+											<text class="card-text">{{course.student_name}}</text>
45
+										</view>
46
+										<view class="card-item margin-top-xs">
47
+											<text class="card-label">老师:</text>
48
+											<text class="card-text">{{course.teacher||'--'}}</text>
49
+										</view>
48 50
 									</view>
49 51
 								</view>
50
-							</view>
51
-							<view class="flex card-footer solid-bottom padding-bottom-xs">
52
-										<view v-for="(prop,k) in course.prop" :key="k" class="margin-right-xs">
53
-											<text class="card-label">{{prop.name}}:</text><text class="text-price">{{prop.money}}</text>
54
-										</view>
55
-							</view>
56
-							<view class="card-bottom margin-top-xs flex justify-between">
57
-								<view>
58
-									<text class="text-price text-red">{{item.sum_money}}</text>
52
+								<view class="flex card-footer solid-bottom padding-bottom-xs">
53
+											<view v-for="(prop,k) in course.prop" :key="k" class="margin-right-xs">
54
+												<text class="card-label">{{prop.name}}:</text><text class="text-price">{{prop.money}}</text>
55
+											</view>
59 56
 								</view>
60
-								<view>
57
+								<view class="card-bottom flex justify-end">
61 58
 										<button @tap="dropCourse(course.order_info_id)" class="cu-btn round bg-student text-white" v-if="dropStatus.includes(item.status)&&course.is_return===0">退课</button>
62 59
 										<button @tap="droping" class="cu-btn round sm line-cyan" v-if="dropStatus.includes(item.status)&&course.is_return===1">退课中</button>
63
-										<button @tap="pay(item.order_id)" class="cu-btn round bg-student text-white margin-right-sm" v-if="item.status===0">立即付款</button>
64
-										<button @tap="cancel(item.order_id)" class="cu-btn round bg-gray" v-if="item.status===0&&!isPaying">取消</button>
65 60
 								</view>
66
-							</view>
61
+						</view>
62
+						<view class="card-bottom margin-top-xs flex justify-between">
63
+									<view>
64
+										<text class="text-price text-red">{{item.sum_money}}</text>
65
+									</view>
66
+									<view>
67
+											<button @tap="pay(item.order_id)" class="cu-btn round bg-student text-white margin-right-sm" v-if="item.status===0">立即付款</button>
68
+											<button @tap="cancel(item.order_id)" class="cu-btn round bg-gray" v-if="item.status===0&&!isPaying">取消</button>
69
+									</view>
70
+						</view>
67 71
 					</view>
68 72
 				</view>
69 73
 			</view>
@@ -116,6 +120,7 @@
116 120
 <script>
117 121
 import { _orderCenter, _dropList, _payOrder, _dropCourse, _cancelOrder } from '@/api/course'
118 122
 import swiperTab from '@/components/swiper-tab.vue'
123
+import { mapGetters } from 'vuex'
119 124
 export default {
120 125
   components: {
121 126
     swiperTab
@@ -132,7 +137,7 @@ export default {
132 137
       menuList: ['全部订单', '待付款', '已付款', '退课售后'],
133 138
       currentIndex: 0,
134 139
       list: [],
135
-      dropStatus: [1, 4],
140
+      dropStatus: [1],
136 141
       orderTypes: {
137 142
         0: 5,
138 143
         1: 0,
@@ -178,6 +183,19 @@ export default {
178 183
       this.get_list()
179 184
     }
180 185
   },
186
+  watch: {
187
+    ifReloadOrder(n, o) {
188
+      if (n) {
189
+        this.changeTab(0)
190
+        this.$store.dispatch('setReload', false)
191
+      }
192
+    }
193
+  },
194
+  computed: {
195
+    ...mapGetters([
196
+      'ifReloadOrder'
197
+    ])
198
+  },
181 199
   methods: {
182 200
     refresh() {
183 201
       this.params.page = 1

+ 2 - 2
src/pages/studentcenter/evaluate.vue

@@ -13,7 +13,7 @@
13 13
 			</view>
14 14
 		</view>
15 15
 		<view class="comment bg-white margin-top padding-lr padding-tb-lg">
16
-			<view>请评价</view>
16
+			<view>{{satisfaction.satisfaction?'已评价':'请评价'}}</view>
17 17
 			<view class="flex text-center margin-top" style="padding-left:80rpx;">
18 18
 					<view class="flex-sub">
19 19
 						<img src="/static/imgs/class/satisfaction.png" mode="widthFix" style="width:70px;">
@@ -42,7 +42,7 @@
42 42
 					<button class="cu-btn" :class="params.statisfaction===1?'bg-cyan':'line-cyan'"  @tap="evaluate('statisfaction',1)">一般</button>
43 43
 				</view>
44 44
 			</view>
45
-			<view class="margin-top-lg">
45
+			<view class="margin-top-lg" v-if="!satisfaction.satisfaction">
46 46
 				<button class="cu-btn bg-cyan lg" style="width:100%;" @tap="comment">提交评价</button>
47 47
 			</view>
48 48
 		</view>

+ 10 - 0
src/store/user.js

@@ -6,6 +6,7 @@ export default {
6 6
     kid: 0,
7 7
     phone: '',
8 8
     ifConnectOrder: false, // socket连接订单正常
9
+    ifReloadOrder: false, // 刷新订单列表
9 10
     carts: null// 购物车
10 11
   },
11 12
   getters: {
@@ -16,6 +17,9 @@ export default {
16 17
     ifConnectOrder(state) {
17 18
       return state.ifConnectOrder
18 19
     },
20
+    ifReloadOrder(state) {
21
+      return state.ifReloadOrder
22
+    },
19 23
     kid(state) {
20 24
       return state.kid || uni.getStorageSync('kid')
21 25
     },
@@ -87,6 +91,9 @@ export default {
87 91
     },
88 92
     SET_CONNECT(state, bool) {
89 93
       state.ifConnectOrder = bool
94
+    },
95
+    SET_RELOAD(state, bool) {
96
+      state.ifReloadOrder = bool
90 97
     }
91 98
   },
92 99
   actions: {
@@ -99,6 +106,9 @@ export default {
99 106
     setConnect({ commit }, bool) {
100 107
       commit('SET_CONNECT', bool)
101 108
     },
109
+    setReload({ commit }, bool) {
110
+      commit('SET_RELOAD', bool)
111
+    },
102 112
     setUser({ commit }, user) {
103 113
       commit('SET_USER', user)
104 114
     },