许成详 6 vuotta sitten
vanhempi
commit
c836ca7d0a

+ 28
- 25
src/pages/user/coupons/index.vue Näytä tiedosto

@@ -2,7 +2,9 @@
2 2
   <div class="mainPage">
3 3
     <scroll ref='scroll' :isloading='isloading' class='wrapper' :data='list' :pullUpLoad='pullUpLoadObj' :startY='parseInt(startY)' @pullingUp='getList'>
4 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 8
         <noMore v-if="hasPic"></noMore>
7 9
       </div>
8 10
     </scroll>
@@ -19,6 +21,9 @@ import failure from '../../../common/icon/inv.png'
19 21
 import scroll from '../../../components/scroll/scroll'
20 22
 import noMore from '../../../components/noMore/noMore'
21 23
 import discounts from '../../../components/discounts/discounts'
24
+import { mapState, createNamespacedHelpers } from 'vuex'
25
+const { mapActions: caseTableActions } = createNamespacedHelpers('placeOrderForCoffee')
26
+
22 27
 export default {
23 28
   data () {
24 29
     return {
@@ -32,29 +37,7 @@ export default {
32 37
       isloading: true,
33 38
       hasPic: false,
34 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 41
       line
59 42
     }
60 43
   },
@@ -76,7 +59,27 @@ export default {
76 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 79
   methods: {
80
+    ...caseTableActions([
81
+      'getCouponList',
82
+    ]),
80 83
     change (item, index) {
81 84
       this.active = index
82 85
     },
@@ -91,5 +94,5 @@ export default {
91 94
 </script>
92 95
 
93 96
 <style lang="scss" scoped>
94
-@import "page.scss";
97
+@import 'page.scss';
95 98
 </style>

+ 21
- 18
src/pages/user/couponsDetail/index.vue Näytä tiedosto

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

+ 9
- 1
src/pages/user/placeOrderDetail/index.vue Näytä tiedosto

@@ -124,7 +124,15 @@ export default {
124 124
       for (var n = 0; n < res.length; n++) {
125 125
         if (res[n].Coupon.CouponType === 'goods' && res[n].Status === 1) {
126 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 136
           } else {
129 137
             for (var a = 0; a < res[n].Coupon.Targets.length; a++) {
130 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 Näytä tiedosto

@@ -54,7 +54,7 @@
54 54
                     <span>优惠信息</span>
55 55
                   </div>
56 56
                 </div>
57
-                <span>{{postData.CouponId == '' ? '暂未选择优惠券' : postData.CouponName}}</span>
57
+                <span>{{postData.customercouponid == '' ? '暂未选择优惠券' : '已选择优惠券'}}</span>
58 58
                 <i class="iconfont icon-jiantou-right"></i>
59 59
               </div>
60 60
               <div class="flex-h">
@@ -63,7 +63,7 @@
63 63
                     <span>优惠券</span>
64 64
                   </div>
65 65
                 </div>
66
-                <span>{{columns.length > 1 ? (columns.length-1) + '张可用优惠券' : '暂无优惠券'}}</span>
66
+                <span>{{couponList.length ? couponList.length + '张可用优惠券' : '暂无优惠券'}}</span>
67 67
               </div>
68 68
             </div>
69 69
             <div class="agreement">
@@ -98,14 +98,22 @@
98 98
     </div>
99 99
     <div class="layer" :class="{'show': showLayer}"> 
100 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 117
       </div>
110 118
     </div>
111 119
   </div>
@@ -114,33 +122,28 @@
114 122
 <script>
115 123
 import { mapState, createNamespacedHelpers } from 'vuex'
116 124
 const { mapActions: mapProjectActions, mapState: mapProjectState } = createNamespacedHelpers('majorProjects')
125
+const { mapActions: caseTableActions } = createNamespacedHelpers('placeOrderForCoffee')
126
+import discounts from '../../../components/discounts/discounts'
117 127
 
118 128
 export default {
119 129
   name: '',
120 130
   data () {
121 131
     return {
132
+      couponList: [],
133
+      getCouponOff: false,
122 134
       agreementOff: false, // 是否同意协议
123 135
       courseTimeList: [],
124 136
       postData: {
125 137
         CouponId: '',
126 138
         CouponName: '',
139
+        customercouponid: ''
127 140
       },
128 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 147
   computed: {
145 148
     ...mapState({
146 149
       orgid: x => x.app.orgId,
@@ -156,14 +159,74 @@ export default {
156 159
     }),
157 160
   },
158 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 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 228
     placeOrder () { // 下单
166
-      if(!this.agreementOff){
229
+      if (!this.agreementOff) {
167 230
         this.$toast('请先阅读服务协议并同意')
168 231
         return false
169 232
       }
@@ -174,7 +237,7 @@ export default {
174 237
           CustomerId: this.user.CustomerId,
175 238
           Price: this.courseDetail.Price
176 239
         },
177
-        coupons: []
240
+        customercouponid: this.postData.customercouponid
178 241
       }).then((res) => {
179 242
         // console.log(JSON.stringify(res))
180 243
         this.$dialog.alert({
@@ -218,5 +281,5 @@ export default {
218 281
 
219 282
 <!-- Add "scoped" attribute to limit CSS to this component only -->
220 283
 <style lang="scss" scoped>
221
-@import "page.scss";
284
+@import 'page.scss';
222 285
 </style>

+ 64
- 0
src/pages/user/placeOrderForCourse/page.scss Näytä tiedosto

@@ -195,6 +195,70 @@
195 195
       left: 0;
196 196
       bottom: 0;
197 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 Näytä tiedosto

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

+ 12
- 0
src/store/placeOrderForCoffee/index.js Näytä tiedosto

@@ -86,5 +86,17 @@ export default {
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 Näytä tiedosto

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