许成详 6 年之前
父節點
當前提交
c836ca7d0a

+ 28
- 25
src/pages/user/coupons/index.vue 查看文件

2
   <div class="mainPage">
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='list' :pullUpLoad='pullUpLoadObj' :startY='parseInt(startY)' @pullingUp='getList'>
4
       <div class="box">
4
       <div class="box">
5
-        <discounts v-for="(item,index) in list" :key='index' @toUse='toUse' :data='item'></discounts>
5
+        <router-link tag="div" v-for="(item,index) in list" :key='index' :to="{name: 'couponsDetail', query: {id: item.customercouponid}}">
6
+          <discounts @toUse='toUse' :data='item'></discounts>
7
+        </router-link>
6
         <noMore v-if="hasPic"></noMore>
8
         <noMore v-if="hasPic"></noMore>
7
       </div>
9
       </div>
8
     </scroll>
10
     </scroll>
19
 import scroll from '../../../components/scroll/scroll'
21
 import scroll from '../../../components/scroll/scroll'
20
 import noMore from '../../../components/noMore/noMore'
22
 import noMore from '../../../components/noMore/noMore'
21
 import discounts from '../../../components/discounts/discounts'
23
 import discounts from '../../../components/discounts/discounts'
24
+import { mapState, createNamespacedHelpers } from 'vuex'
25
+const { mapActions: caseTableActions } = createNamespacedHelpers('placeOrderForCoffee')
26
+
22
 export default {
27
 export default {
23
   data () {
28
   data () {
24
     return {
29
     return {
32
       isloading: true,
37
       isloading: true,
33
       hasPic: false,
38
       hasPic: false,
34
       hasMore: true,
39
       hasMore: true,
35
-      list: [
36
-        {
37
-          title: '小小外交官体验卡',
38
-          desc: '凭此体验券可让一位小朋友体验一次 适用于小小外交官课程',
39
-          time: '2018年02月17日',
40
-          useType: '未使用',
41
-          tag: '共享'
42
-        },
43
-        {
44
-          title: '小小外交官体验卡',
45
-          desc: '凭此体验券可让一位小朋友体验一次 适用于小小外交官课程',
46
-          time: '2018年02月17日',
47
-          useType: '已使用',
48
-          tag: '商品'
49
-        },
50
-        {
51
-          title: '小小外交官体验卡',
52
-          desc: '凭此体验券可让一位小朋友体验一次 适用于小小外交官课程',
53
-          time: '2018年02月17日',
54
-          useType: '已失效',
55
-          tag: '商品'
56
-        }
57
-      ],
40
+      list: [],
58
       line
41
       line
59
     }
42
     }
60
   },
43
   },
76
         : false
59
         : false
77
     }
60
     }
78
   },
61
   },
62
+  created () {
63
+    this.getCouponList().then((res) => {
64
+      // console.log(JSON.stringify(res))
65
+      // console.log(JSON.stringify(this.couponList))
66
+      for (var n = 0; n < res.length; n++) {
67
+        this.list.push({
68
+          title: res[n].Coupon.CouponName,
69
+          desc: res[n].Coupon.Share.UseInstruction,
70
+          time: this.toolClass.dateFormat(res[n].EndDate),
71
+          useType: res[n].Status === 1 ? '未使用' : '已使用',
72
+          tag: res[n].Coupon.CouponType === 'coupon' ? '课程' : '商品',
73
+          customercouponid: res[n].CustomerCouponId,
74
+          couponid: res[n].Coupon.CouponId
75
+        })
76
+      }
77
+    })
78
+  },
79
   methods: {
79
   methods: {
80
+    ...caseTableActions([
81
+      'getCouponList',
82
+    ]),
80
     change (item, index) {
83
     change (item, index) {
81
       this.active = index
84
       this.active = index
82
     },
85
     },
91
 </script>
94
 </script>
92
 
95
 
93
 <style lang="scss" scoped>
96
 <style lang="scss" scoped>
94
-@import "page.scss";
97
+@import 'page.scss';
95
 </style>
98
 </style>

+ 21
- 18
src/pages/user/couponsDetail/index.vue 查看文件

1
 <template>
1
 <template>
2
   <div class="mainPage">
2
   <div class="mainPage">
3
     <div class="title">体验券详情</div>
3
     <div class="title">体验券详情</div>
4
-    <div class="content">
4
+    <div class="content" v-if="info !== null">
5
       <div class="message">
5
       <div class="message">
6
         <div>
6
         <div>
7
-          <span>体验券名称:小小外交官体验券</span>
7
+          <span>体验券名称:{{info.CustomerCouponName}}</span>
8
         </div>
8
         </div>
9
         <div>
9
         <div>
10
           <span>有效时间:</span>
10
           <span>有效时间:</span>
11
-          <div class="time">{{time}}</div>
11
+          <div class="time">{{toolClass.dateFormat(info.EndDate)}}</div>
12
         </div>
12
         </div>
13
       </div>
13
       </div>
14
       <div class="rule">
14
       <div class="rule">
16
         <div>1. 此卡不可兑换现金,不可与其他优惠活动同时使用。 </div>
16
         <div>1. 此卡不可兑换现金,不可与其他优惠活动同时使用。 </div>
17
         <div>2. 此卡不可多人使用,一人记一次。 </div>
17
         <div>2. 此卡不可多人使用,一人记一次。 </div>
18
         <div>3. 非会员可凭此卡享受对应课程。 </div>
18
         <div>3. 非会员可凭此卡享受对应课程。 </div>
19
-        <div>4. 截止日期至{{time}}。 </div>
19
+        <div>4. 截止日期至{{toolClass.dateFormat(info.EndDate)}}。 </div>
20
       </div>
20
       </div>
21
       <div class="line">
21
       <div class="line">
22
         <img :src="Artboard" alt="" width="100%">
22
         <img :src="Artboard" alt="" width="100%">
23
       </div>
23
       </div>
24
-      <div class="qr-code" style="margin-top:.1rem;">
25
-        <div class="number">核销编码: 3423487682734</div>
26
-        <qrCode :msg='msg'></qrCode>
27
-      </div>
28
     </div>
24
     </div>
29
   </div>
25
   </div>
30
 </template>
26
 </template>
31
 
27
 
32
 <script>
28
 <script>
33
-import qrCode from '../../../components/qrCodeCard/qrCodeCard'
34
 import Artboard from '../../../common/icon/Artboard.png'
29
 import Artboard from '../../../common/icon/Artboard.png'
30
+import { mapState, createNamespacedHelpers } from 'vuex'
31
+const { mapActions: caseTableActions } = createNamespacedHelpers('placeOrderForCoffee')
35
 export default {
32
 export default {
36
   data () {
33
   data () {
37
     return {
34
     return {
38
-      msg: {
39
-        course_type: 800
40
-      },
35
+      msg: 'sdsdssdsdsdsds',
41
       Artboard,
36
       Artboard,
42
-      time: '2018年3月17日'
37
+      time: '2018年3月17日',
38
+      info: null,
43
     }
39
     }
44
   },
40
   },
41
+  created () {
42
+    this.getCouponInfo({
43
+      id: this.$route.query.id
44
+    }).then((res) => {
45
+      // console.log(JSON.stringify(res))
46
+      this.info = res
47
+    })
48
+  },
45
   methods: {
49
   methods: {
46
-
50
+    ...caseTableActions([
51
+      'getCouponInfo',
52
+    ]),
47
   },
53
   },
48
-  components: {
49
-    qrCode
50
-  }
51
 }
54
 }
52
 </script>
55
 </script>
53
 
56
 
54
 <style lang="scss" scoped>
57
 <style lang="scss" scoped>
55
-@import "page.scss";
58
+@import 'page.scss';
56
 </style>
59
 </style>

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

124
       for (var n = 0; n < res.length; n++) {
124
       for (var n = 0; n < res.length; n++) {
125
         if (res[n].Coupon.CouponType === 'goods' && res[n].Status === 1) {
125
         if (res[n].Coupon.CouponType === 'goods' && res[n].Status === 1) {
126
           if (res[n].Coupon.IsAll) {
126
           if (res[n].Coupon.IsAll) {
127
-            this.couponList.push(res[n])
127
+            this.couponList.push({
128
+              title: res[n].Coupon.CouponName,
129
+              desc: res[n].Coupon.Share.UseInstruction,
130
+              time: this.toolClass.dateFormat(res[n].EndDate),
131
+              useType: '未使用',
132
+              tag: '商品',
133
+              id: res[n].CustomerCouponId,
134
+              select: false,
135
+            })
128
           } else {
136
           } else {
129
             for (var a = 0; a < res[n].Coupon.Targets.length; a++) {
137
             for (var a = 0; a < res[n].Coupon.Targets.length; a++) {
130
               if (res[n].Coupon.Targets[a].TargetId === id && nowDate >= new Date(res[n].StartDate).getTime() && nowDate < new Date(res[n].EndDate).getTime()) {
138
               if (res[n].Coupon.Targets[a].TargetId === id && nowDate >= new Date(res[n].StartDate).getTime() && nowDate < new Date(res[n].EndDate).getTime()) {

+ 92
- 29
src/pages/user/placeOrderForCourse/index.vue 查看文件

54
                     <span>优惠信息</span>
54
                     <span>优惠信息</span>
55
                   </div>
55
                   </div>
56
                 </div>
56
                 </div>
57
-                <span>{{postData.CouponId == '' ? '暂未选择优惠券' : postData.CouponName}}</span>
57
+                <span>{{postData.customercouponid == '' ? '暂未选择优惠券' : '已选择优惠券'}}</span>
58
                 <i class="iconfont icon-jiantou-right"></i>
58
                 <i class="iconfont icon-jiantou-right"></i>
59
               </div>
59
               </div>
60
               <div class="flex-h">
60
               <div class="flex-h">
63
                     <span>优惠券</span>
63
                     <span>优惠券</span>
64
                   </div>
64
                   </div>
65
                 </div>
65
                 </div>
66
-                <span>{{columns.length > 1 ? (columns.length-1) + '张可用优惠券' : '暂无优惠券'}}</span>
66
+                <span>{{couponList.length ? couponList.length + '张可用优惠券' : '暂无优惠券'}}</span>
67
               </div>
67
               </div>
68
             </div>
68
             </div>
69
             <div class="agreement">
69
             <div class="agreement">
98
     </div>
98
     </div>
99
     <div class="layer" :class="{'show': showLayer}"> 
99
     <div class="layer" :class="{'show': showLayer}"> 
100
       <div>
100
       <div>
101
-        <van-picker
102
-          show-toolbar
103
-          title="选择优惠券"
104
-          :columns="columns"
105
-          @cancel="onCancel"
106
-          @confirm="onConfirm"
107
-          value-key="value"
108
-        />
101
+        <div class="top">
102
+          <i class="iconfont icon-guanbi"></i>
103
+        </div>
104
+        <div class="body flex-h">
105
+          <div class="flex-item">
106
+            <div>
107
+              <ul>
108
+                <li v-for="(item,index) in couponList" :key="index" @click="selectCouponItem(item)" :class="{'active':item.select}">
109
+                  <i class="iconfont icon-gouxuan"></i>
110
+                  <discounts :data="item"></discounts>
111
+                </li>
112
+              </ul>
113
+            </div>
114
+          </div>
115
+        </div>
116
+        <a @click="sureSelectCoupon">确定</a>
109
       </div>
117
       </div>
110
     </div>
118
     </div>
111
   </div>
119
   </div>
114
 <script>
122
 <script>
115
 import { mapState, createNamespacedHelpers } from 'vuex'
123
 import { mapState, createNamespacedHelpers } from 'vuex'
116
 const { mapActions: mapProjectActions, mapState: mapProjectState } = createNamespacedHelpers('majorProjects')
124
 const { mapActions: mapProjectActions, mapState: mapProjectState } = createNamespacedHelpers('majorProjects')
125
+const { mapActions: caseTableActions } = createNamespacedHelpers('placeOrderForCoffee')
126
+import discounts from '../../../components/discounts/discounts'
117
 
127
 
118
 export default {
128
 export default {
119
   name: '',
129
   name: '',
120
   data () {
130
   data () {
121
     return {
131
     return {
132
+      couponList: [],
133
+      getCouponOff: false,
122
       agreementOff: false, // 是否同意协议
134
       agreementOff: false, // 是否同意协议
123
       courseTimeList: [],
135
       courseTimeList: [],
124
       postData: {
136
       postData: {
125
         CouponId: '',
137
         CouponId: '',
126
         CouponName: '',
138
         CouponName: '',
139
+        customercouponid: ''
127
       },
140
       },
128
       showLayer: false, // 显隐选择优惠券弹窗
141
       showLayer: false, // 显隐选择优惠券弹窗
129
-      columns: [{ // 优惠券列表
130
-        value: '不选择优惠券',
131
-        id: '',
132
-      }, {
133
-        value: '优惠券1',
134
-        id: '1',
135
-      }, {
136
-        value: '优惠券2',
137
-        id: '2',
138
-      }, {
139
-        value: '优惠券3',
140
-        id: '3',
141
-      }],
142
     }
142
     }
143
   },
143
   },
144
+  components: {
145
+    discounts,
146
+  },
144
   computed: {
147
   computed: {
145
     ...mapState({
148
     ...mapState({
146
       orgid: x => x.app.orgId,
149
       orgid: x => x.app.orgId,
156
     }),
159
     }),
157
   },
160
   },
158
   created () {
161
   created () {
159
-    this.getCourseDetailInfo({ id: this.$route.query.id }).then((res) => {
160
-      var arr = res.CourseDetail
161
-      this.courseTimeList = arr.sort(function (a, b) { return new Date(a.BeginDate).getTime() > new Date(b.BeginDate).getTime() ? 1 : -1 })
162
+    this.getCouponList().then((res) => {
163
+      this.getCourseDetailInfo({ id: this.$route.query.id }).then((res) => {
164
+        var arr = res.CourseDetail
165
+        this.courseTimeList = arr.sort(function (a, b) { return new Date(a.BeginDate).getTime() > new Date(b.BeginDate).getTime() ? 1 : -1 })
166
+      })
167
+      var id = this.$route.query.id, arr = [], nowDate = Date.now()
168
+      for (var n = 0; n < res.length; n++) {
169
+        if (res[n].Coupon.CouponType === 'coupon' && res[n].Status === 1) {
170
+          if (res[n].Coupon.IsAll) {
171
+            this.couponList.push({
172
+              title: res[n].Coupon.CouponName,
173
+              desc: res[n].Coupon.Share.UseInstruction,
174
+              time: this.toolClass.dateFormat(res[n].EndDate),
175
+              useType: '未使用',
176
+              tag: '课程',
177
+              id: res[n].CustomerCouponId,
178
+              select: false,
179
+            })
180
+          } else {
181
+            for (var a = 0; a < res[n].Coupon.Targets.length; a++) {
182
+              if (res[n].Coupon.Targets[a].TargetId === id && nowDate >= new Date(res[n].StartDate).getTime() && nowDate < new Date(res[n].EndDate).getTime()) {
183
+                this.couponList.push({
184
+                  title: res[n].Coupon.CouponName,
185
+                  desc: res[n].Coupon.Share.UseInstruction,
186
+                  time: this.toolClass.dateFormat(res[n].EndDate),
187
+                  useType: '未使用',
188
+                  tag: '课程',
189
+                  id: res[n].CustomerCouponId,
190
+                  select: false,
191
+                })
192
+              }
193
+            }
194
+          }
195
+        }
196
+      }
197
+      this.getCouponOff = true
198
+      // console.log(JSON.stringify(this.couponList))
162
     })
199
     })
163
   },
200
   },
164
   methods: {
201
   methods: {
202
+    ...caseTableActions([
203
+      'getCouponList',
204
+    ]),
205
+    sureSelectCoupon () {
206
+      var bool = false
207
+      for (var n = 0; n < this.couponList.length; n++) {
208
+        if (this.couponList[n].select) {
209
+          bool = true
210
+          this.postData.customercouponid = this.couponList[n].id
211
+        }
212
+      }
213
+      if (!bool) {
214
+        this.postData.customercouponid = ''
215
+      }
216
+      this.showLayer = false
217
+    },
218
+    selectCouponItem (item) { // 选择优惠券
219
+      if (!item.select) {
220
+        for (var n = 0; n < this.couponList.length; n++) {
221
+          this.couponList[n].select = false
222
+        }
223
+        item.select = true
224
+      } else {
225
+        item.select = false
226
+      }
227
+    },
165
     placeOrder () { // 下单
228
     placeOrder () { // 下单
166
-      if(!this.agreementOff){
229
+      if (!this.agreementOff) {
167
         this.$toast('请先阅读服务协议并同意')
230
         this.$toast('请先阅读服务协议并同意')
168
         return false
231
         return false
169
       }
232
       }
174
           CustomerId: this.user.CustomerId,
237
           CustomerId: this.user.CustomerId,
175
           Price: this.courseDetail.Price
238
           Price: this.courseDetail.Price
176
         },
239
         },
177
-        coupons: []
240
+        customercouponid: this.postData.customercouponid
178
       }).then((res) => {
241
       }).then((res) => {
179
         // console.log(JSON.stringify(res))
242
         // console.log(JSON.stringify(res))
180
         this.$dialog.alert({
243
         this.$dialog.alert({
218
 
281
 
219
 <!-- Add "scoped" attribute to limit CSS to this component only -->
282
 <!-- Add "scoped" attribute to limit CSS to this component only -->
220
 <style lang="scss" scoped>
283
 <style lang="scss" scoped>
221
-@import "page.scss";
284
+@import 'page.scss';
222
 </style>
285
 </style>

+ 64
- 0
src/pages/user/placeOrderForCourse/page.scss 查看文件

195
       left: 0;
195
       left: 0;
196
       bottom: 0;
196
       bottom: 0;
197
       overflow: hidden;
197
       overflow: hidden;
198
+      background: #fff;
199
+      border-radius: .1rem .1rem 0 0;
200
+      .top{
201
+        width: 100%;
202
+        position: relative;
203
+        overflow: hidden;
204
+        text-align: right;
205
+        margin-top: .1rem;
206
+        padding-bottom: .1rem;
207
+        i{
208
+          margin-right: .1rem;
209
+          font-size: .2rem;
210
+          color: #666;
211
+        }
212
+      }
213
+      >.body{
214
+        width: 100%;
215
+        position: relative;
216
+        overflow: visible;
217
+        >div{
218
+          margin: 0 .2rem;
219
+          position: relative;
220
+          overflow: visible;
221
+          >div{
222
+            width: 100%;
223
+            max-height: 3rem;
224
+            position: relative;
225
+            overflow-x: visible;
226
+            overflow-y: scroll;
227
+            -webkit-overflow-scrolling: touch;
228
+            transform: translateZ(0);
229
+            -webkit-transform: translateZ(0);
230
+            ul{
231
+              li{
232
+                margin: .1rem auto 0;
233
+                position: relative;
234
+                >i{
235
+                  display: none;
236
+                  font-size: .2rem;
237
+                  color: #fd684a;
238
+                  position: absolute;
239
+                  right: .1rem;
240
+                  top: .1rem;
241
+                  z-index: 110;
242
+                }
243
+                &.active{
244
+                  >i{
245
+                    display: block;
246
+                  }
247
+                }
248
+              }
249
+            }
250
+          }
251
+        }
252
+      }
253
+      >a{
254
+        width: 100%;
255
+        display: block;
256
+        line-height: .5rem;
257
+        text-align: center;
258
+        color: #fff;
259
+        font-size: .15rem;
260
+        background: #fc6243;
261
+      }
198
     }
262
     }
199
   }
263
   }
200
 }
264
 }

+ 2
- 2
src/store/majorProjects/majorProjects.js 查看文件

17
     }
17
     }
18
   },
18
   },
19
   actions: {
19
   actions: {
20
-    placeOrderForCourse (context, { order, coupons = [] }) { // 课程下单
20
+    placeOrderForCourse (context, { order, customercouponid }) { // 课程下单
21
       return new Promise((resolve, reject) => {
21
       return new Promise((resolve, reject) => {
22
         Ajax(api.majorProjects.placeCourseOrder.url, {
22
         Ajax(api.majorProjects.placeCourseOrder.url, {
23
           method: api.majorProjects.placeCourseOrder.method,
23
           method: api.majorProjects.placeCourseOrder.method,
24
           data: {
24
           data: {
25
             info: window.JSON.stringify(order),
25
             info: window.JSON.stringify(order),
26
-            coupons: window.JSON.stringify(coupons),
26
+            customercouponid,
27
           }
27
           }
28
         }).then(res => {
28
         }).then(res => {
29
           resolve(res)
29
           resolve(res)

+ 12
- 0
src/store/placeOrderForCoffee/index.js 查看文件

86
         })
86
         })
87
       })
87
       })
88
     },
88
     },
89
+    getCouponInfo (context, { id }) { // 获取优惠券详情
90
+      return new Promise((resolve) => {
91
+        Ajax(api.caseForCoffee.getCouponInfo.url, {
92
+          method: api.caseForCoffee.getCouponInfo.method,
93
+          urlData: {
94
+            id,
95
+          },
96
+        }).then(res => {
97
+          resolve(res)
98
+        })
99
+      })
100
+    },
89
   }
101
   }
90
 }
102
 }

+ 5
- 1
src/util/api.js 查看文件

52
       method: 'get',
52
       method: 'get',
53
       url: `${baseUrl}${wechat}/customer/coupon`
53
       url: `${baseUrl}${wechat}/customer/coupon`
54
     },
54
     },
55
+    getCouponInfo: { // 获取优惠券详情
56
+      method: 'get',
57
+      url: `${baseUrl}${wechat}/customer/coupon/:id`
58
+    },
55
   },
59
   },
56
   majorProjects: { // 项目专题
60
   majorProjects: { // 项目专题
57
     getCourseList: { // 获取课程列表
61
     getCourseList: { // 获取课程列表
110
       method: 'get',
114
       method: 'get',
111
       url: `${baseUrl}${wechat}/gymcard`
115
       url: `${baseUrl}${wechat}/gymcard`
112
     },
116
     },
113
-    gymCardDetail: { // 获取健身卡列表
117
+    gymCardDetail: { // 获取健身卡详情
114
       method: 'get',
118
       method: 'get',
115
       url: `${baseUrl}${wechat}/gymcard/:customerGymId`
119
       url: `${baseUrl}${wechat}/gymcard/:customerGymId`
116
     },
120
     },