许成详 6 years ago
parent
commit
f3a2fd3389

+ 15
- 2
src/pages/user/majorProjectsDetail/index.vue View File

@@ -112,6 +112,7 @@ export default {
112 112
       message: x => x.index.message,
113 113
       project: x => x.index.project,
114 114
       cms: x => x.index.cms,
115
+      user: x => x.userCenter.userInfo
115 116
     }),
116 117
     ...mapProjectState({
117 118
       courseDetail: x => x.courseDetail
@@ -136,7 +137,7 @@ export default {
136 137
         this.courseDetail.CourseImgs.sort(this.getSortFun('asc', 'Sort'))
137 138
         this.detailImage = this.courseDetail.CourseImgs
138 139
       }
139
-      console.log(this.detailImage)
140
+      // console.log(this.detailImage)
140 141
       this.courseTimeList = arr.sort(function (a, b) { return new Date(a.BeginDate).getTime() > new Date(b.BeginDate).getTime() ? 1 : -1 })
141 142
       let nowDate = Date.now()
142 143
       let endData = new Date(this.courseDetail.EndDate).getTime()
@@ -153,6 +154,7 @@ export default {
153 154
   methods: {
154 155
     ...mapProjectActions([
155 156
       'getCourseDetailInfo',
157
+      'placeCourseOrderBefore',
156 158
     ]),
157 159
     getSortFun (order, sortBy) {
158 160
       var ordAlpah = (order == 'asc') ? '>' : '<'
@@ -184,7 +186,18 @@ export default {
184 186
       if (nowDate > endData) {
185 187
         this.$toast('该课程已过期')
186 188
       } else {
187
-        this.$router.push({ name: 'placeOrderForCourse', query: { id: this.courseDetail.CourseId } })
189
+        this.placeCourseOrderBefore({
190
+          order: {
191
+            CourseId: this.courseDetail.CourseId,
192
+            CaseId: this.courseDetail.CaseId,
193
+            CustomerId: this.user.CustomerId,
194
+            Price: this.courseDetail.Price
195
+          },
196
+          customercouponid: ''
197
+        }).then((res) => {
198
+          // console.log(JSON.stringify(res))
199
+          this.$router.push({ name: 'placeOrderForCourse', query: { id: this.courseDetail.CourseId, ordersid: res.OrdersId } })
200
+        })
188 201
       }
189 202
     },
190 203
     openMap () {

+ 5
- 7
src/pages/user/placeOrderForCourse/index.vue View File

@@ -164,6 +164,7 @@ export default {
164 164
   },
165 165
   created () {
166 166
     this.getCouponList().then((res) => {
167
+      res = res || []
167 168
       this.getCourseDetailInfo({ id: this.$route.query.id }).then((result) => {
168 169
         var arr = result.CourseDetail, caseid = result.CaseId
169 170
         // console.log(arr)
@@ -244,13 +245,10 @@ export default {
244 245
         return false
245 246
       }
246 247
       this.placeOrderForCourse({
247
-        order: {
248
-          CourseId: this.courseDetail.CourseId,
249
-          CaseId: this.courseDetail.CaseId,
250
-          CustomerId: this.user.CustomerId,
251
-          Price: this.courseDetail.Price
252
-        },
253
-        customercouponid: this.postData.customercouponid
248
+        id: this.$route.query.ordersid,
249
+        payload: {
250
+          customercouponid: this.postData.customercouponid,
251
+        }
254 252
       }).then((res) => {
255 253
         // console.log(JSON.stringify(res))
256 254
         this.$dialog.alert({

+ 20
- 3
src/store/majorProjects/majorProjects.js View File

@@ -17,10 +17,10 @@ export default {
17 17
     }
18 18
   },
19 19
   actions: {
20
-    placeOrderForCourse (context, { order, customercouponid }) { // 课程下单
20
+    placeCourseOrderBefore (context, { order, customercouponid }) { // 课程下单
21 21
       return new Promise((resolve, reject) => {
22
-        Ajax(api.majorProjects.placeCourseOrder.url, {
23
-          method: api.majorProjects.placeCourseOrder.method,
22
+        Ajax(api.majorProjects.placeCourseOrderBefore.url, {
23
+          method: api.majorProjects.placeCourseOrderBefore.method,
24 24
           data: {
25 25
             info: window.JSON.stringify(order),
26 26
             customercouponid,
@@ -32,6 +32,23 @@ export default {
32 32
         })
33 33
       })
34 34
     },
35
+    placeOrderForCourse (context, { id, payload }) { // 课程下单
36
+      return new Promise((resolve, reject) => {
37
+        Ajax(api.majorProjects.placeCourseOrder.url, {
38
+          method: api.majorProjects.placeCourseOrder.method,
39
+          urlData: {
40
+            id,
41
+          },
42
+          data: {
43
+            customercouponid: payload.customercouponid
44
+          }
45
+        }).then(res => {
46
+          resolve(res)
47
+        }).catch((err) => {
48
+          reject(err)
49
+        })
50
+      })
51
+    },
35 52
     getProjectInfo (context, { id }) { // 获取课程列表
36 53
       return new Promise((resolve) => {
37 54
         Ajax(api.majorProjects.getCourseList.url, {

+ 5
- 1
src/util/api.js View File

@@ -73,10 +73,14 @@ const $api = {
73 73
       method: 'get',
74 74
       url: `${baseUrl}${guest}/course/:id`
75 75
     },
76
-    placeCourseOrder: { // 课程下单
76
+    placeCourseOrderBefore: { // 课程下单
77 77
       method: 'post',
78 78
       url: `${baseUrl}${wechat}/order/course`
79 79
     },
80
+    placeCourseOrder: { // 课程下单
81
+      method: 'put',
82
+      url: `${baseUrl}${wechat}/order/course/:id`
83
+    },
80 84
   },
81 85
   card: {
82 86
     myCustomer: { // 我的客户