许成详 6 年前
父节点
当前提交
304bdc0233
共有 4 个文件被更改,包括 82 次插入101 次删除
  1. 38
    68
      src/pages/user/lessonOrder/index.vue
  2. 1
    1
      src/pages/user/majorProjectsDetail/index.vue
  3. 35
    32
      src/store/userCenter/userCenter.js
  4. 8
    0
      src/util/api.js

+ 38
- 68
src/pages/user/lessonOrder/index.vue 查看文件

@@ -1,20 +1,20 @@
1 1
 <template>
2 2
   <div class="mainPage">
3
-    <scroll ref='scroll' :isloading='isloading' class='wrapper' :data='list' :pullUpLoad='pullUpLoadObj' :startY='parseInt(startY)' @pullingUp='getList'>
3
+    <scroll ref='scroll' :isloading='isloading' class='wrapper' :data='courseOrderList.list' :pullUpLoad='pullUpLoadObj' :startY='parseInt(startY)' @pullingUp='getList'>
4 4
       <div class="box">
5
-        <div class="order-card flex-h" v-for="(item,index) in list" :key='index' :class="{'opacity' : item.useType == '已失效'}" @click="toDetail(item)">
5
+        <div class="order-card flex-h" v-for="(item,index) in courseOrderList.list" :key='index' :class="{'opacity' : item.status === 1}" @click="toDetail(item)">
6 6
           <div class="card-pic">
7
-            <div :class="{'gray-location' : item.useType == '已失效'}"><span>{{item.LocationName}}</span></div>
7
+            <div :class="{'gray-location' : item.status === 1}"><span>{{item.LocationName}}</span></div>
8 8
             <img src="" class="cover" width="100%" height="100%" alt="">
9 9
           </div>
10 10
           <div class="card-msg">
11
-            <div class="title">{{item.title}}</div>
12
-            <div class="text">付款方式:{{item.payType}}</div>
13
-            <div class="text">下单时间:{{item.time}}</div>
11
+            <div class="title">{{item.CourseName}}</div>
12
+            <div class="text">付款方式:{{item.CourseObtaimType === 'cheng-coin' ? '城币支付' : '优惠券抵用'}}</div>
13
+            <div class="text">下单时间:{{toolClass.dateFormat(item.CreateDate)}}</div>
14 14
           </div>
15 15
           <div class="card-price">
16
-            <div class="price">¥ {{item.price}}</div>
17
-            <div class="type" :class="{'un-use' : item.useType == '未使用'}">{{item.useType}}</div>
16
+            <div class="price" style="white-space: nowrap;">¥ {{item.Price}}</div>
17
+            <div class="type" :class="{'un-use' : item.IsDone === 0}">{{item.IsDone === 0 ? '未使用' : '已使用'}}</div>
18 18
           </div>
19 19
         </div>
20 20
         <!-- <noMore v-if="hasPic"></noMore> -->
@@ -27,6 +27,8 @@
27 27
 // 上拉加载组件
28 28
 import scroll from '../../../components/scroll/scroll'
29 29
 import noMore from '../../../components/noMore/noMore'
30
+import { mapState, createNamespacedHelpers } from 'vuex'
31
+const { mapActions: mapUserActions, mapState: mapUserState } = createNamespacedHelpers('userCenter')
30 32
 export default {
31 33
   data () {
32 34
     return {
@@ -34,65 +36,28 @@ export default {
34 36
       pullUpLoad: true,
35 37
       pullUpLoadThreshold: 40,
36 38
       startY: 0,
39
+      page: 1,
37 40
       isloading: true,
38 41
       hasMore: true,
39
-      list: [
40
-        {
41
-          LocationName: '社交',
42
-          title: '小小外交官课程',
43
-          payType: '优惠券抵用',
44
-          time: '2018-7-18 12:19',
45
-          price: 199,
46
-          useType: '未使用'
47
-        },
48
-        {
49
-          LocationName: '社交',
50
-          title: '小小外交官课程',
51
-          payType: '优惠券抵用',
52
-          time: '2018-7-18 12:19',
53
-          price: 199,
54
-          useType: '已使用'
55
-        },
56
-        {
57
-          LocationName: '社交',
58
-          title: '小小外交官课程',
59
-          payType: '优惠券抵用',
60
-          time: '2018-7-18 12:19',
61
-          price: 199,
62
-          useType: '已失效'
63
-        },
64
-        {
65
-          LocationName: '社交',
66
-          title: '小小外交官课程',
67
-          payType: '优惠券抵用',
68
-          time: '2018-7-18 12:19',
69
-          price: 199,
70
-          useType: '已失效'
71
-        },
72
-        {
73
-          LocationName: '社交',
74
-          title: '小小外交官课程',
75
-          payType: '优惠券抵用',
76
-          time: '2018-7-18 12:19',
77
-          price: 199,
78
-          useType: '已失效'
79
-        },
80
-        {
81
-          LocationName: '社交',
82
-          title: '小小外交官课程',
83
-          payType: '优惠券抵用',
84
-          time: '2018-7-18 12:19',
85
-          price: 199,
86
-          useType: '已失效'
87
-        }
88
-      ]
42
+      list: []
89 43
     }
90 44
   },
91 45
   components: {
92 46
     scroll,
93 47
     noMore
94 48
   },
49
+  created () {
50
+    var _that = this
51
+    this.getCourseLocationList().then((res) => {
52
+      console.log(JSON.stringify(res))
53
+      this.getCourseOrderList({ page: this.page })
54
+    })
55
+  },
95 56
   computed: {
57
+    ...mapUserState({
58
+      courseOrderList: x => x.courseOrderList,
59
+      courseLocationList: x => x.courseLocationList,
60
+    }),
96 61
     pullUpLoadObj: function () {
97 62
       return this.pullUpLoad
98 63
         ? {
@@ -106,17 +71,22 @@ export default {
106 71
     }
107 72
   },
108 73
   methods: {
74
+    ...mapUserActions([
75
+      'getCourseOrderList',
76
+      'getCourseLocationList',
77
+    ]),
109 78
     getList () {
110
-      this.list.length <= 8 ? this.hasMore = true : this.hasMore = false
79
+      var _that = this
80
+      Math.ceil(this.courseOrderList.pagenum / this.courseOrderList.pagesize) > this.page ? this.hasMore = true : this.hasMore = false
81
+      // this.list.length <= 8 ? this.hasMore = true : this.hasMore = false
111 82
       if (this.hasMore) {
112 83
         setTimeout(() => {
113
-          this.list.push({
114
-            LocationName: '社交',
115
-            title: '小小外交官课程',
116
-            payType: '优惠券抵用',
117
-            time: '2018-7-18 12:19',
118
-            price: 199,
119
-            useType: '已失效'
84
+          this.getCourseOrderList({
85
+            page: _that.page + 1
86
+          }).then((res) => {
87
+            if(res.list.length){
88
+              _that.page += 1
89
+            }
120 90
           })
121 91
         }, 1000)
122 92
       } else {
@@ -125,12 +95,12 @@ export default {
125 95
       }
126 96
     },
127 97
     toDetail () {
128
-      this.$router.push({name: 'lessonDetail'})
98
+      this.$router.push({ name: 'lessonDetail' })
129 99
     }
130 100
   }
131 101
 }
132 102
 </script>
133 103
 
134 104
 <style lang="scss" scoped>
135
-@import "page.scss";
105
+@import 'page.scss';
136 106
 </style>

+ 1
- 1
src/pages/user/majorProjectsDetail/index.vue 查看文件

@@ -113,7 +113,7 @@ export default {
113 113
     this.getCourseDetailInfo({ id: this.$route.query.id }).then((res) => {
114 114
       var arr = res.CourseDetail
115 115
       this.courseTimeList = arr.sort(function (a, b) { return new Date(a.BeginDate).getTime() > new Date(b.BeginDate).getTime() ? 1 : -1 })
116
-      console.log(JSON.stringify(this.courseTimeList))
116
+      // console.log(JSON.stringify(res))
117 117
     })
118 118
   },
119 119
   methods: {

+ 35
- 32
src/store/userCenter/userCenter.js 查看文件

@@ -73,38 +73,10 @@ http.submitData = (data) => { // 绑定手机号
73 73
 export default {
74 74
   namespaced: true,
75 75
   state: {
76
-    userInfo: {
77
-      AccountInfo: {
78
-        "city": "CITY",
79
-        "country": "COUNTRY",
80
-        "headimgurl": "http://thirdwx.qlogo.cn/mmopen/g3MonUZtNHkdmzicIlibx6iaFqAc56vxLSUfpb6n5WKSYVY0ChQKkiaJSgQ1dZuTOgvLLrhJbERQQ4eMsv84eavHiaiceqxibJxCfHe/46",
81
-        "nickname": "NICKNAME",
82
-        "openid": "OPENID",
83
-        "province": "PROVINCE",
84
-        "sex": "1",
85
-        "unionid": "o6_bmasdasdsad6_2sgVt7hMZOPfL"
86
-      },
87
-      AccountType: "wechat",
88
-      CreateDate: "0001-01-01T00:00:00Z",
89
-      CustomerId: "1",
90
-      CustomerName: "测试",
91
-      Headimgurl: "",
92
-      MapUser: "",
93
-      MappingId: "1",
94
-      Name: "测试",
95
-      Openid: "OPENID",
96
-      OrgId: "1",
97
-      Phone: "13823838438",
98
-      Points: 0,
99
-      RecommendCase: "1",
100
-      RecommendId: "0",
101
-      RecommendName: "",
102
-      Sex: 1,
103
-      Status: 1,
104
-      UserType: "customer",
105
-      Uuid: "",
106
-    },
107
-    caseInfo: {}
76
+    userInfo: {},
77
+    caseInfo: {},
78
+    courseOrderList: {},
79
+    courseLocationList: [],
108 80
   },
109 81
   mutations: {
110 82
     setUserInfo (state, data) {
@@ -112,9 +84,40 @@ export default {
112 84
     },
113 85
     setCaseInfo (state, data) {
114 86
       state.caseInfo = data
87
+    },
88
+    setCourseLocationList (state, data) { // 设置课程类型列表
89
+      state.courseLocationList = data
90
+    },
91
+    setCourseOrder (state, { res, page }) { // 设置我的课程订单信息
92
+      if (page === 1) {
93
+        state.courseOrderList = res
94
+      } else {
95
+        state.courseOrderList = {...res, list: [...state.courseOrderList.list, res.list]}
96
+      }
115 97
     }
116 98
   },
117 99
   actions: {
100
+    getCourseLocationList (context) { // 获取课程类型列表
101
+      return new Promise((resolve) => {
102
+        Ajax(api.user.getCourseLoactionList.url, {
103
+          method: api.user.getCourseLoactionList.method,
104
+        }).then(res => {
105
+          context.commit('setCourseLocationList')
106
+          resolve(res)
107
+        })
108
+      })
109
+    },
110
+    getCourseOrderList (context, payload) { // 获取我的课程订单信息
111
+      return new Promise((resolve) => {
112
+        Ajax(api.user.getCourseOrderList.url, {
113
+          method: api.user.getCourseOrderList.method,
114
+          queryData: {...payload}
115
+        }).then(res => {
116
+          context.commit('setCourseOrder', { res, page: payload.page })
117
+          resolve(res)
118
+        })
119
+      })
120
+    },
118 121
     getUserInfo (context, data) {
119 122
       return new Promise((resolve) => {
120 123
         http.getUserInfo(data).then((res) => {

+ 8
- 0
src/util/api.js 查看文件

@@ -80,6 +80,14 @@ const $api = {
80 80
       method: 'get',
81 81
       url: `${baseUrl}${guest}/case`
82 82
     },
83
+    getCourseOrderList: { // 获取我的课程订单信息
84
+      method: 'get',
85
+      url: `${baseUrl}${wechat}/course/user`
86
+    },
87
+    getCourseLoactionList: { // 获取课程类型列表
88
+      method: 'get',
89
+      url: `${baseUrl}${guest}/cms/location`
90
+    },
83 91
   },
84 92
   login:{ // 主管、销售端登陆
85 93
     login: {