Quellcode durchsuchen

Merge branch 'master' into dev_seam_intelligent

seamwang vor 2 Jahren
Ursprung
Commit
56ffd847c5
4 geänderte Dateien mit 109 neuen und 73 gelöschten Zeilen
  1. 49 49
      src/common/utils/fetch.js
  2. 19 1
      src/pages/class/shoppingCart.vue
  3. 30 12
      src/pages/order/index.vue
  4. 11 11
      src/pages/studentcenter/works.vue

+ 49 - 49
src/common/utils/fetch.js

@@ -1,53 +1,53 @@
1 1
 import store from '@/store/index'
2 2
 
3 3
 // 统一请求方法
4
-export default function fetch(url, params = {}, method = 'POST', showFail = true) {
5
-  let showLoading = true
6
-  if (params && params.notShowLoading) {
7
-    showLoading = false
8
-  }
9
-  if (showLoading) {
10
-    uni.showLoading({
11
-      mask: true,
12
-      title: '加载中...'
13
-    })
14
-  }
15
-  url = process.env.VUE_APP_BASE_URL + url
16
-  params.token = store.getters.token
17
-  params.student_id = params.student_id || store.getters.kid
18
-  return new Promise((resolve, reject) => {
19
-    uni.request({
20
-      url,
21
-      data: params,
22
-      method,
23
-      header: {},
24
-      success: (res) => {
25
-        uni.hideLoading()
26
-        // 0:错误; 1:正确; 10000:没有token -2: 需要绑定手机
27
-        const rs = res.data
28
-        if (rs && rs.code === 1) {
29
-          resolve(rs)
30
-        } else if (rs.code === 10000) {
31
-          // // 跳转至登录页
32
-          uni.showModal({
33
-            title: '请先登录',
34
-            content: '您还没有登录,请先去登录',
35
-            success: res => {
36
-              if (res.confirm) {
37
-                uni.navigateTo({ url: '/pages/login/index' })
38
-              }
39
-            }
40
-          })
41
-        } else {
42
-          if (showFail) uni.showToast({ title: rs.msg, icon: 'none', duration: 2000 })// 直接提示错误
43
-          resolve(rs)
44
-        }
45
-      },
46
-      fail: (err) => {
47
-        uni.hideLoading()
48
-        uni.showToast({ title: err, icon: 'none', duration: 2000 })
49
-        reject(err)
50
-      }
51
-    })
52
-  })
4
+export default function fetch (url, params = {}, method = 'POST', showFail = true) {
5
+	let showLoading = true
6
+	if (params && params.notShowLoading) {
7
+		showLoading = false
8
+	}
9
+	if (showLoading) {
10
+		uni.showLoading({
11
+			mask: true,
12
+			title: '加载中...'
13
+		})
14
+	}
15
+	url = process.env.VUE_APP_BASE_URL + url
16
+	params.token = store.getters.token
17
+	params.student_id = params.student_id || store.getters.kid
18
+	return new Promise((resolve, reject) => {
19
+		uni.request({
20
+			url,
21
+			data: params,
22
+			method,
23
+			header: {},
24
+			success: (res) => {
25
+				uni.hideLoading()
26
+				// 0:错误; 1:正确; 10000:没有token -2: 需要绑定手机
27
+				const rs = res.data
28
+				if (rs && rs.code === 1) {
29
+					resolve(rs)
30
+				} else if (rs.code === 10000) {
31
+					// // 跳转至登录页
32
+					uni.showModal({
33
+						title: '请先登录',
34
+						content: '您还没有登录,请先去登录',
35
+						success: res => {
36
+							if (res.confirm) {
37
+								uni.navigateTo({ url: '/pages/login/index' })
38
+							}
39
+						}
40
+					})
41
+				} else {
42
+					if (showFail) uni.showToast({ title: rs.msg, icon: 'none', duration: 2000 })// 直接提示错误
43
+					resolve(rs)
44
+				}
45
+			},
46
+			fail: (err) => {
47
+				uni.hideLoading()
48
+				uni.showToast({ title: err, icon: 'none', duration: 2000 })
49
+				reject(err)
50
+			}
51
+		})
52
+	})
53 53
 }

+ 19 - 1
src/pages/class/shoppingCart.vue

@@ -105,6 +105,18 @@ export default {
105 105
     socket.initSocket()
106 106
   },
107 107
   methods: {
108
+    subscribeMsg() {
109
+      return new Promise((resolve, reject) => {
110
+        uni.requestSubscribeMessage({
111
+          tmplIds: ['tfuaGZ8IOk0-JDKMcr5bVhUiiqvIORJHR_74VoPuWH4'],
112
+          success(res) {},
113
+          fail(res) {},
114
+          complete(res) {
115
+            resolve(true)
116
+          }
117
+        })
118
+      })
119
+    },
108 120
     checkChange(e) {
109 121
       this.checkedIds = e.detail.value.map(x => Number(x))
110 122
       this.shoppingList = this.list.filter(item => this.checkedIds.includes(item.shopping_id))
@@ -155,6 +167,12 @@ export default {
155 167
         uni.showToast({ title: '请先选择课程', icon: 'none', duration: 1000 })
156 168
         return false
157 169
       }
170
+      //订阅消息
171
+      this.subscribeMsg().then(res => {
172
+        this.placeOrder() //下单
173
+      })
174
+    },
175
+    placeOrder() {
158 176
       uni.showLoading({
159 177
         mask: true,
160 178
         title: '加载中...'
@@ -162,7 +180,7 @@ export default {
162 180
       const order = JSON.stringify(this.shoppingList)
163 181
       let carts = deepClone(this.carts)
164 182
       const shoppingCarts = this.shoppingList.map(item => item.class_attend_id)
165
-      carts = carts.filter(item => !shoppingCarts.includes(item))
183
+      carts = carts.filter(item => !shoppingCarts.includes(item)) //购物车存储
166 184
       _createOrder({ result: order, notShowLoading: true }).then(res => {
167 185
         this.$store.dispatch('setCarts', carts)
168 186
         setTimeout(() => {

+ 30 - 12
src/pages/order/index.vue

@@ -213,6 +213,18 @@ export default {
213 213
     ...mapGetters(['ifReloadOrder'])
214 214
   },
215 215
   methods: {
216
+    subscribeMsg() {
217
+      return new Promise((resolve, reject) => {
218
+        uni.requestSubscribeMessage({
219
+          tmplIds: ['EsEmKKVj_rPTnLEDGjPTO9JRk1L3G0d9qh058FWXdJ4'],
220
+          success(res) {},
221
+          fail(res) {},
222
+          complete(res) {
223
+            resolve(true)
224
+          }
225
+        })
226
+      })
227
+    },
216 228
     refresh() {
217 229
       this.params.page = 1
218 230
       this.get_list()
@@ -271,19 +283,25 @@ export default {
271 283
     dropCourse(id) {
272 284
       const params = { order_info_id: id, refund_explanation: '', type_id: 0 }
273 285
       const _self = this
274
-      uni.showModal({
275
-        title: '提示',
276
-        content: '确定退课?',
277
-        cancelText: '取消',
278
-        confirmText: '确定',
279
-        success: res => {
280
-          if (res.confirm) {
281
-            _dropCourse(params).then(res => {
282
-              uni.showToast({ title: '已经发起退课,请耐心等待', icon: 'none' })
283
-              _self.refresh()
284
-            })
286
+      //订阅消息
287
+      this.subscribeMsg().then(res => {
288
+        //退单逻辑
289
+        uni.showModal({
290
+          title: '提示',
291
+          content: '确定退课?',
292
+          cancelText: '取消',
293
+          confirmText: '确定',
294
+          success: res => {
295
+            if (res.confirm) {
296
+              _dropCourse(params).then(rs => {
297
+                if (rs.code === 1) {
298
+                  uni.showToast({ title: '已经发起退课,请耐心等待', icon: 'none' })
299
+                  _self.refresh()
300
+                }
301
+              })
302
+            }
285 303
           }
286
-        }
304
+        })
287 305
       })
288 306
     },
289 307
     pay(id) {

+ 11 - 11
src/pages/studentcenter/works.vue

@@ -1,12 +1,11 @@
1 1
 <template>
2 2
   <view class="page">
3 3
     <cu-custom :isBack="true" title="课堂作品"></cu-custom>
4
-    <scroll-view scroll-y="true" :style="[{height:'calc(100vh - '+ topHeader+'px)'}]">
4
+    <scroll-view scroll-y="true" :style="[{ height: 'calc(100vh - ' + topHeader + 'px)' }]">
5 5
       <view class="content">
6 6
         <view class="course-img">
7
-          <swiper class="swiper" :indicator-dots="swiper.indicatorDots" :autoplay="swiper.autoplay"
8
-            :interval="swiper.interval" :duration="swiper.duration">
9
-            <swiper-item v-for="(item,index) in detail.course_data.image" :key="index">
7
+          <swiper class="swiper" :indicator-dots="swiper.indicatorDots" :autoplay="swiper.autoplay" :interval="swiper.interval" :duration="swiper.duration">
8
+            <swiper-item v-for="(item, index) in detail.course_data.image" :key="index">
10 9
               <view class="swiper-item">
11 10
                 <image :src="item" mode="widthFix"></image>
12 11
               </view>
@@ -16,13 +15,14 @@
16 15
         <view>
17 16
           <view class="title margin-top-sm">课堂作品</view>
18 17
           <view class="list">
19
-            <view class="cu-card case" v-for="(item,index) in detail.student_comment_data.data" :key="index">
18
+            <view class="cu-card case" v-for="(item, index) in detail.student_comment_data.data" :key="index">
20 19
               <view class="cu-item shadow">
21 20
                 <view class="image">
22
-                  <view v-for="(img,i) in item.images" :key="i">
23
-                    <image :src="img" v-if="checkTypes(img,'imgs')" mode="aspectFit" style="width:100%;"></image>
24
-                    <video :src="img" v-if="checkTypes(img,'video')" style="width:100%;"></video>
21
+                  <view v-for="(img, i) in item.images" :key="i">
22
+                    <image :src="img" v-if="checkTypes(img, 'imgs')" mode="aspectFit" style="width: 100%;"></image>
23
+                    <video :src="img" v-if="checkTypes(img, 'video')" style="width: 100%;"></video>
25 24
                   </view>
25
+                  <view class="margin-bottom-xs">老师点评:{{ detail.teach_review_data.data[0].msg }}</view>
26 26
                 </view>
27 27
               </view>
28 28
             </view>
@@ -36,7 +36,7 @@
36 36
 <script>
37 37
 import { checkTypes } from '@/common/utils/index'
38 38
 export default {
39
-  data () {
39
+  data() {
40 40
     return {
41 41
       topHeader: this.globalCustomBarHeight,
42 42
       detail: {},
@@ -48,12 +48,12 @@ export default {
48 48
       }
49 49
     }
50 50
   },
51
-  onLoad () {
51
+  onLoad() {
52 52
     this.init()
53 53
   },
54 54
   methods: {
55 55
     checkTypes,
56
-    init () {
56
+    init() {
57 57
       this.detail = JSON.parse(uni.getStorageSync('daily_class'))
58 58
     }
59 59
   }