Browse Source

Merge branch '2.1.0' of http://git.ycjcjy.com/SpaceOfCheng/wechat into 2.1.0

yuantianjiao 6 years ago
parent
commit
22a98b04be

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

112
       message: x => x.index.message,
112
       message: x => x.index.message,
113
       project: x => x.index.project,
113
       project: x => x.index.project,
114
       cms: x => x.index.cms,
114
       cms: x => x.index.cms,
115
+      user: x => x.userCenter.userInfo
115
     }),
116
     }),
116
     ...mapProjectState({
117
     ...mapProjectState({
117
       courseDetail: x => x.courseDetail
118
       courseDetail: x => x.courseDetail
136
         this.courseDetail.CourseImgs.sort(this.getSortFun('asc', 'Sort'))
137
         this.courseDetail.CourseImgs.sort(this.getSortFun('asc', 'Sort'))
137
         this.detailImage = this.courseDetail.CourseImgs
138
         this.detailImage = this.courseDetail.CourseImgs
138
       }
139
       }
139
-      console.log(this.detailImage)
140
+      // console.log(this.detailImage)
140
       this.courseTimeList = arr.sort(function (a, b) { return new Date(a.BeginDate).getTime() > new Date(b.BeginDate).getTime() ? 1 : -1 })
141
       this.courseTimeList = arr.sort(function (a, b) { return new Date(a.BeginDate).getTime() > new Date(b.BeginDate).getTime() ? 1 : -1 })
141
       let nowDate = Date.now()
142
       let nowDate = Date.now()
142
       let endData = new Date(this.courseDetail.EndDate).getTime()
143
       let endData = new Date(this.courseDetail.EndDate).getTime()
153
   methods: {
154
   methods: {
154
     ...mapProjectActions([
155
     ...mapProjectActions([
155
       'getCourseDetailInfo',
156
       'getCourseDetailInfo',
157
+      'placeCourseOrderBefore',
156
     ]),
158
     ]),
157
     getSortFun (order, sortBy) {
159
     getSortFun (order, sortBy) {
158
       var ordAlpah = (order == 'asc') ? '>' : '<'
160
       var ordAlpah = (order == 'asc') ? '>' : '<'
184
       if (nowDate > endData) {
186
       if (nowDate > endData) {
185
         this.$toast('该课程已过期')
187
         this.$toast('该课程已过期')
186
       } else {
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
     openMap () {
203
     openMap () {

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

164
   },
164
   },
165
   created () {
165
   created () {
166
     this.getCouponList().then((res) => {
166
     this.getCouponList().then((res) => {
167
+      res = res || []
167
       this.getCourseDetailInfo({ id: this.$route.query.id }).then((result) => {
168
       this.getCourseDetailInfo({ id: this.$route.query.id }).then((result) => {
168
         var arr = result.CourseDetail, caseid = result.CaseId
169
         var arr = result.CourseDetail, caseid = result.CaseId
169
         // console.log(arr)
170
         // console.log(arr)
244
         return false
245
         return false
245
       }
246
       }
246
       this.placeOrderForCourse({
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
       }).then((res) => {
252
       }).then((res) => {
255
         // console.log(JSON.stringify(res))
253
         // console.log(JSON.stringify(res))
256
         this.$dialog.alert({
254
         this.$dialog.alert({

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

17
     }
17
     }
18
   },
18
   },
19
   actions: {
19
   actions: {
20
-    placeOrderForCourse (context, { order, customercouponid }) { // 课程下单
20
+    placeCourseOrderBefore (context, { order, customercouponid }) { // 课程下单
21
       return new Promise((resolve, reject) => {
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
           data: {
24
           data: {
25
             info: window.JSON.stringify(order),
25
             info: window.JSON.stringify(order),
26
             customercouponid,
26
             customercouponid,
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
     getProjectInfo (context, { id }) { // 获取课程列表
52
     getProjectInfo (context, { id }) { // 获取课程列表
36
       return new Promise((resolve) => {
53
       return new Promise((resolve) => {
37
         Ajax(api.majorProjects.getCourseList.url, {
54
         Ajax(api.majorProjects.getCourseList.url, {

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

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