yuantianjiao 6 years ago
parent
commit
f9973e7987

+ 1
- 1
public/index.html View File

@@ -6,7 +6,7 @@
6 6
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
7 7
   <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
8 8
     charset="utf-8" />
9
-  <link rel="stylesheet" href="//at.alicdn.com/t/font_775069_fqsik3e9to7.css">
9
+  <link rel="stylesheet" href="//at.alicdn.com/t/font_775069_q841vrk4ihm.css">
10 10
   <link rel="icon" href="<%= BASE_URL %>favicon.ico">
11 11
   <title>
12 12
     <%= htmlWebpackPlugin.options.title %>

+ 29
- 7
src/pages/sales/cardAndCouponNum/index.vue View File

@@ -50,7 +50,7 @@
50 50
               <span>用户领取</span>
51 51
             </li>
52 52
             <li class="flex-h" v-for="(item,index) in data.CustomerCard" :key="index">
53
-              <span>{{item.SalesName}}</span>
53
+              <span>{{salesData(item).name}}</span>
54 54
               <div class="flex-item">
55 55
                 <div>
56 56
                   <span>{{salesData(item).receive}}</span>
@@ -101,17 +101,39 @@ export default {
101 101
   methods: {
102 102
     ...mapForbidActions(['getCardNum', 'getCouponNum', 'getSales']),
103 103
     salesData (item) {
104
-      let receive
105
-      let used
104
+      let receive = 0
105
+      let used = 0
106
+      let name
106 107
       if (this.$route.query.type === 'card') {
107
-        receive = this.salesList.filter(x => x.UserId === item.UserId).length > 0 ? this.salesList.filter(x => x.UserId === item.UserId) : 0
108
-        used = this.salesList.filter(x => x.UserId === item.UserId && item.VerifyStatus === '已核销').length > 0 ? this.salesList.filter(x => x.UserId === item.UserId && item.VerifyStatus === '已核销').length : 0
108
+        for (let i = 0; i < this.salesList.length; i++) {
109
+          this.salesList[i].CustomerCard = this.salesList[i].CustomerCard || []
110
+          for (let j = 0; j < this.salesList[i].CustomerCard.length; j++) {
111
+            if (this.salesList[i].CustomerCard[j].SalesId === item.SalesId) {
112
+              name = this.salesList[i].RealName
113
+              receive++
114
+              if (!item.VerifyStatus) {
115
+                used++
116
+              }
117
+            }
118
+          }
119
+        }
109 120
       } else {
110
-        receive = this.salesList.filter(x => x.UserId === item.UserId).length > 0 ? this.salesList.filter(x => x.UserId === item.UserId) : 0
111
-        used = this.salesList.filter(x => x.UserId === item.UserId && item.VerifyStatus === '已核销').length > 0 ? this.salesList.filter(x => x.UserId === item.UserId && item.VerifyStatus === '已核销').length : 0
121
+        for (let i = 0; i < this.salesList.length; i++) {
122
+          this.salesList[i].CustomerCoupon = this.salesList[i].CustomerCoupon || []
123
+          for (let j = 0; j < this.salesList[i].CustomerCoupon.length; j++) {
124
+            if (this.salesList[i].CustomerCoupon[j].SalesId === item.SalesId) {
125
+              name = this.salesList[i].RealName
126
+              receive++
127
+              if (!item.VerifyStatus) {
128
+                used++
129
+              }
130
+            }
131
+          }
132
+        }
112 133
       }
113 134
 
114 135
       return {
136
+        'name': name,
115 137
         'receive': receive,
116 138
         'used': used
117 139
       }

+ 17
- 15
src/pages/user/mainPage/index.vue View File

@@ -5,7 +5,7 @@
5 5
         <router-view></router-view>
6 6
       </div>
7 7
     </div>
8
-    <nav class="flex-h">
8
+    <nav class="flex-h" v-if="!userInfo.CustomerId">
9 9
       <router-link :to="{name:item.pathName,query:{}}" class="flex-item" active-class="active" v-for="(item, index) in tabBar" :key="index">
10 10
         <div>
11 11
           <img v-if="index==0" class="centerLabel" src="../../../common/icon/tabBar-icon-1.png" alt="">
@@ -19,39 +19,41 @@
19 19
 </template>
20 20
 
21 21
 <script>
22
-
22
+import { mapState } from 'vuex'
23 23
 export default {
24 24
   name: '',
25 25
   data () {
26 26
     return {
27 27
       tabBar: [{
28
-        pathName:'indexPage',
29
-        name:'会所'
30
-      },{
31
-        pathName:'coffeeIndex',
32
-        name:'城咖啡'
33
-      },{
34
-        pathName:'userCenter',
35
-        name:'会员'
28
+        pathName: 'indexPage',
29
+        name: '会所'
30
+      }, {
31
+        pathName: 'coffeeIndex',
32
+        name: '城咖啡'
33
+      }, {
34
+        pathName: 'userCenter',
35
+        name: '会员'
36 36
       }]
37 37
     }
38 38
   },
39 39
   computed: {
40
-    
40
+    ...mapState({
41
+      userInfo: x => x.userCenter.userInfo
42
+    })
41 43
   },
42 44
   components: {
43
-    
45
+
44 46
   },
45 47
   created () {
46
-    
48
+
47 49
   },
48 50
   methods: {
49
-    
51
+
50 52
   }
51 53
 }
52 54
 </script>
53 55
 
54 56
 <!-- Add "scoped" attribute to limit CSS to this component only -->
55 57
 <style lang="scss" scoped>
56
-@import "page.scss";
58
+@import 'page.scss';
57 59
 </style>

+ 105
- 16
src/pages/user/receive/index.vue View File

@@ -1,38 +1,43 @@
1 1
 <template>
2 2
   <div class="mainPage">
3
-    <div v-if='video' class="logo">
4
-      <img :src="logo" alt="">
3
+    <!-- <div class="residue">
4
+      <i class="iconfont icon-gantanhao"></i>
5
+      <span>仅剩{{data.TotalCount - data.UsedCount}}张券可以领取!</span>
5 6
     </div>
7
+    <div class="logo">
8
+      <img :src="logo" alt="">
9
+    </div> -->
6 10
     <div class="banner"  v-if="!video">
7
-      <img src="" alt="" width="100%" height="100%">
11
+      <img :src="data.CoverUrl" alt="" width="100%" height="100%">
8 12
     </div>
9 13
     <div class="content">
10
-      <div class="title">彻天彻地童玩探险乐园家庭套餐</div>
14
+      <div class="title">{{data.CardName}}</div>
11 15
       <div class="video" v-if='video'>
12
-        <video src="http://jingcheng-h5temp.oss-cn-shanghai.aliyuncs.com/c395af03fd02acc07edcea5b21e5a3231536905593.mp4" width="100%" height="100%"></video>
16
+        <video :src="data.VideoUrl" width="100%" height="100%"></video>
13 17
       </div>
14 18
       <div class="text">
15 19
         <div>
16 20
           <i class="icon-shuoming iconfont"></i>
17 21
           <span>卡券使用说明</span>
18 22
         </div>
19
-        <pre>1. 本券不兑现金,不找零; 2. 票券仅作为门票费用,不能抵扣其他消费; 3. 营业时间:周一、二闭馆,周三、四(9:30-17:00),周五、六、日(9:30-20:00) 4. 咨询电话:0571-89008367</pre>
23
+        <pre>{{data.Share.CardUseInstruction}}</pre>
20 24
       </div>
21 25
       <div class="text">
22 26
         <div>
23 27
           <i class="icon-kaquan iconfont"></i>
24 28
           <span>卡券有效期</span>
25 29
         </div>
26
-        <pre>有效期至2018年10月1号,请在有效期结束前使用, 过期作废;</pre>
30
+        <pre>有效期至{{toolClass.dateFormat(data.EndDate)}},请在有效期结束前使用, 过期作废;</pre>
27 31
       </div>
28
-      <div class="text" v-if="video">
32
+      <div class="text">
29 33
         <div>
30 34
           <i class="icon-dingwei iconfont"></i>
31 35
           <span>服务网点</span>
32 36
         </div>
33
-        <pre>银城G99门店 地址:金马路230号</pre>
37
+        <pre>{{data.address}}</pre>
34 38
       </div>
35
-      <div class="submit">确认领取</div>
39
+      <div class="submit" v-if="button" @click="receive">确认领取</div>
40
+      <div class="submit" v-else>点击右上角分享给客户</div>
36 41
     </div>
37 42
   </div>
38 43
 </template>
@@ -40,20 +45,104 @@
40 45
 <script>
41 46
 import wxsdk from '../../../util/share'
42 47
 import logo from '../../../common/icon/logoTop.png'
48
+import { createNamespacedHelpers } from 'vuex'
49
+const { mapState: mapShareState, mapActions: mapShareActions } = createNamespacedHelpers('share')
50
+const { mapState: mapAppState, mapActions: mapAppActions } = createNamespacedHelpers('app')
51
+
43 52
 export default {
44 53
   data () {
45 54
     return {
46 55
       logo,
47
-      video: true
56
+      video: true,
57
+      button: true,
58
+      data: {
59
+        Share: {}
60
+      }
48 61
     }
49 62
   },
63
+  computed: {
64
+    ...mapShareState({
65
+      cardShare: x => x.cardShare,
66
+      couponShare: x => x.couponShare
67
+    }),
68
+    ...mapAppState({
69
+      caseList: x => x.CaseList
70
+    })
71
+  },
50 72
   created () {
51
-    wxsdk({ url: encodeURIComponent(window.location.href.split('#')[0]) }, {
52
-      title: '悦见山,金秋送好礼',
53
-      desc: '扫码分享,免费抽取赢森林音乐节门票,机会有限,速来参加',
54
-      link: `${window.location.origin}${window.location.pathname}`,
55
-      thu_image: `${window.location.origin}${window.location.pathname}${logo}`
73
+    if (this.$route.params) {
74
+      let that = this
75
+      Object.keys(this.$route.params).forEach(function (key) {
76
+        that.$route.query[key] = that.$route.params[key]
77
+      })
78
+    }
79
+
80
+
81
+    if (this.$route.query.shareType === 'share') {
82
+      this.button = false
83
+    }
84
+    this.getCaseList().then(() => {
85
+      this.init()
56 86
     })
87
+  },
88
+  methods: {
89
+    ...mapShareActions(['getCardShare', 'getCouponShare', 'setCardShare', 'setCouponShare']),
90
+    ...mapAppActions(['getCaseList']),
91
+    init () {
92
+      if (this.$route.query.type === 'card') {
93
+        this.getCardShare({ id: this.$route.query.id }).then(() => {
94
+          this.data = this.cardShare.Card
95
+          this.data.address = this.caseList.filter(x => x.CaseId === this.data.CaseId)[0].CaseAddress
96
+          if (!this.data.VideoUrl) {
97
+            this.video = false
98
+          }
99
+          this.sdk()
100
+        })
101
+      } else {
102
+        this.getCouponShare({ id: this.$route.query.id }).then(() => {
103
+          this.data = this.cardShare.Card
104
+          this.data.address = this.caseList.filter(x => x.CaseId === this.data.CaseId)[0].CaseAddress
105
+          if (!this.data.VideoUrl) {
106
+            this.video = false
107
+          }
108
+          this.sdk()
109
+        })
110
+      }
111
+    },
112
+    receive () {
113
+      if (this.$route.query.type === 'card') {
114
+        this.setCardShare({ id: this.$route.query.id, salesid: this.$route.query.salesid, serialcode: this.random() }).then(() => {
115
+          this.$router.push({ name: 'receiveResults', query: { type: 'success' } })
116
+        }).catch((err) => {
117
+          this.$router.push({ name: 'receiveResults', query: { type: 'fail' } })
118
+          console.log(err)
119
+        })
120
+      } else {
121
+        this.setCouponShare({ id: this.$route.query.id, salesid: this.$route.query.salesid, serialcode: this.random() }).then(() => {
122
+          this.$router.push({ name: 'receiveResults', query: { type: 'success' } })
123
+        }).catch((err) => {
124
+          this.$router.push({ name: 'receiveResults', query: { type: 'fail' } })
125
+          console.log(err)
126
+        })
127
+      }
128
+    },
129
+    random () {
130
+      let rnd = ''
131
+      for (let i = 0; i < 5; i++) {
132
+        rnd += Math.floor(Math.random() * 10)
133
+      }
134
+      let timestamp = new Date().valueOf()
135
+      return `${rnd}${timestamp}`
136
+    },
137
+    sdk () {
138
+      let logo = this.logo.substring(2, this.logo.length)
139
+      wxsdk({ url: encodeURIComponent(window.location.href.split('#')[0]) }, {
140
+        title: '领取卡券',
141
+        desc: this.data.Share.CardShareInfo,
142
+        link: `${window.location.origin}${window.location.pathname}#/receiveShared/${this.$route.query.id}/${this.$route.query.salesid}/${this.$route.query.type}/receive`,
143
+        thu_image: `${window.location.origin}${window.location.pathname}${logo}`
144
+      })
145
+    }
57 146
   }
58 147
 }
59 148
 </script>

+ 13
- 1
src/pages/user/receive/page.scss View File

@@ -1,4 +1,15 @@
1 1
 .mainPage{
2
+  .residue{
3
+    height: .35rem;
4
+    display: flex;
5
+    align-items: center;
6
+    background: rgba(0, 0, 0, .6);
7
+    padding-left: .2rem;
8
+    span,i{
9
+      color: rgba(221,143,1,1);
10
+      padding-right: .05rem;
11
+    }
12
+  }
2 13
   .logo{
3 14
     img{
4 15
       width: 1.05rem;
@@ -26,10 +37,11 @@
26 37
       padding-bottom: .2rem;
27 38
       >div:nth-of-type(1){
28 39
         display: flex;
29
-        align-items: center;
40
+        align-items: baseline;
30 41
         padding-bottom: .1rem;
31 42
         i,span{
32 43
           color: rgba(168,182,200,1);
44
+          padding-right: .05rem;
33 45
         }
34 46
       }
35 47
       pre{

+ 152
- 0
src/pages/user/receiveChannel/index.vue View File

@@ -0,0 +1,152 @@
1
+<template>
2
+  <div class="mainPage">
3
+    <div class="residue">
4
+      <i class="iconfont icon-gantanhao"></i>
5
+      <span>仅剩{{data.TotalCount - data.UsedCount}}张券可以领取!</span>
6
+    </div>
7
+    <div class="logo">
8
+      <img :src="logo" alt="">
9
+    </div>
10
+    <div class="banner"  v-if="!video">
11
+      <img :src="data.CoverUrl" alt="" width="100%" height="100%">
12
+    </div>
13
+    <div class="content">
14
+      <div class="title">{{data.CardName}}</div>
15
+      <div class="video" v-if='video'>
16
+        <video :src="data.VideoUrl" width="100%" height="100%"></video>
17
+      </div>
18
+      <div class="text">
19
+        <div>
20
+          <i class="icon-shuoming iconfont"></i>
21
+          <span>卡券使用说明</span>
22
+        </div>
23
+        <pre>{{data.Share.CardUseInstruction}}</pre>
24
+      </div>
25
+      <div class="text">
26
+        <div>
27
+          <i class="icon-kaquan iconfont"></i>
28
+          <span>卡券有效期</span>
29
+        </div>
30
+        <pre>有效期至{{toolClass.dateFormat(data.EndDate)}},请在有效期结束前使用, 过期作废;</pre>
31
+      </div>
32
+      <div class="text">
33
+        <div>
34
+          <i class="icon-dingwei iconfont"></i>
35
+          <span>服务网点</span>
36
+        </div>
37
+        <pre>{{data.address}}</pre>
38
+      </div>
39
+      <div class="submit" v-if="button" @click="receive">确认领取</div>
40
+      <div class="submit" v-else>点击右上角分享给客户</div>
41
+    </div>
42
+  </div>
43
+</template>
44
+
45
+<script>
46
+import wxsdk from '../../../util/share'
47
+import logo from '../../../common/icon/logoTop.png'
48
+import { createNamespacedHelpers } from 'vuex'
49
+const { mapState: mapShareState, mapActions: mapShareActions } = createNamespacedHelpers('share')
50
+const { mapState: mapAppState, mapActions: mapAppActions } = createNamespacedHelpers('app')
51
+
52
+export default {
53
+  data () {
54
+    return {
55
+      logo,
56
+      video: true,
57
+      button: true,
58
+      data: {
59
+        Share: {}
60
+      }
61
+    }
62
+  },
63
+  computed: {
64
+    ...mapShareState({
65
+      cardShare: x => x.cardShare,
66
+      couponShare: x => x.couponShare
67
+    }),
68
+    ...mapAppState({
69
+      caseList: x => x.CaseList
70
+    })
71
+  },
72
+  created () {
73
+    if (this.$route.params) {
74
+      let that = this
75
+      Object.keys(this.$route.params).forEach(function (key) {
76
+        that.$route.query[key] = that.$route.params[key]
77
+      })
78
+    }
79
+
80
+
81
+    if (this.$route.query.shareType === 'share') {
82
+      this.button = false
83
+    }
84
+    this.getCaseList().then(() => {
85
+      this.init()
86
+    })
87
+  },
88
+  methods: {
89
+    ...mapShareActions(['getCardShare', 'getCouponShare', 'setChannelCardShare', 'setChannelCouponShare']),
90
+    ...mapAppActions(['getCaseList']),
91
+    init () {
92
+      if (this.$route.query.type === 'card') {
93
+        this.getCardShare({ id: this.$route.query.id }).then(() => {
94
+          this.data = this.cardShare.Card
95
+          this.data.address = this.caseList.filter(x => x.CaseId === this.data.CaseId)[0].CaseAddress
96
+          if (!this.data.VideoUrl) {
97
+            this.video = false
98
+          }
99
+          this.sdk()
100
+        })
101
+      } else {
102
+        this.getCouponShare({ id: this.$route.query.id }).then(() => {
103
+          this.data = this.cardShare.Card
104
+          this.data.address = this.caseList.filter(x => x.CaseId === this.data.CaseId)[0].CaseAddress
105
+          if (!this.data.VideoUrl) {
106
+            this.video = false
107
+          }
108
+          this.sdk()
109
+        })
110
+      }
111
+    },
112
+    receive () {
113
+      if (this.$route.query.type === 'card') {
114
+        this.setChannelCardShare({ id: this.$route.query.id }).then(() => {
115
+          this.$router.push({ name: 'receiveResults', query: { type: 'success' } })
116
+        }).catch((err) => {
117
+          this.$router.push({ name: 'receiveResults', query: { type: 'fail' } })
118
+          console.log(err)
119
+        })
120
+      } else {
121
+        this.setChannelCouponShare({ id: this.$route.query.id }).then(() => {
122
+          this.$router.push({ name: 'receiveResults', query: { type: 'success' } })
123
+        }).catch((err) => {
124
+          this.$router.push({ name: 'receiveResults', query: { type: 'fail' } })
125
+          console.log(err)
126
+        })
127
+      }
128
+    },
129
+    random () {
130
+      let rnd = ''
131
+      for (let i = 0; i < 5; i++) {
132
+        rnd += Math.floor(Math.random() * 10)
133
+      }
134
+      let timestamp = new Date().valueOf()
135
+      return `${rnd}${timestamp}`
136
+    },
137
+    sdk () {
138
+      let logo = this.logo.substring(2, this.logo.length)
139
+      wxsdk({ url: encodeURIComponent(window.location.href.split('#')[0]) }, {
140
+        title: '领取卡券',
141
+        desc: this.data.Share.CardShareInfo,
142
+        link: `${window.location.origin}${window.location.pathname}#/receiveShared/${this.$route.query.id}/${this.$route.query.salesid}/${this.$route.query.type}/receive`,
143
+        thu_image: `${window.location.origin}${window.location.pathname}${logo}`
144
+      })
145
+    }
146
+  }
147
+}
148
+</script>
149
+
150
+<style lang="scss" scoped>
151
+@import 'page.scss';
152
+</style>

+ 63
- 0
src/pages/user/receiveChannel/page.scss View File

@@ -0,0 +1,63 @@
1
+.mainPage{
2
+  .residue{
3
+    height: .35rem;
4
+    display: flex;
5
+    align-items: center;
6
+    background: rgba(0, 0, 0, .6);
7
+    padding-left: .2rem;
8
+    span,i{
9
+      color: rgba(221,143,1,1);
10
+      padding-right: .05rem;
11
+    }
12
+  }
13
+  .logo{
14
+    img{
15
+      width: 1.05rem;
16
+    }
17
+  }
18
+  .banner{
19
+    width: 100%;
20
+    height: 1.8rem;
21
+  }
22
+  .content{
23
+    padding: .2rem;
24
+    box-sizing: border-box;
25
+    .video{
26
+      width: 100%;
27
+      height: 1.8rem;
28
+      box-sizing: border-box;
29
+      padding: .15rem;
30
+      margin-bottom: .15rem;
31
+    }
32
+    .title{
33
+      font-size: .18rem;
34
+      padding-bottom: .2rem;
35
+    }
36
+    .text{
37
+      padding-bottom: .2rem;
38
+      >div:nth-of-type(1){
39
+        display: flex;
40
+        align-items: baseline;
41
+        padding-bottom: .1rem;
42
+        i,span{
43
+          color: rgba(168,182,200,1);
44
+          padding-right: .05rem;
45
+        }
46
+      }
47
+      pre{
48
+        color: #323232;
49
+        white-space: pre-wrap;
50
+        word-wrap: break-word;
51
+      }
52
+    }
53
+    .submit{
54
+      height: .46rem;
55
+      background: rgba(252,98,67,1);
56
+      border-radius: .25rem;
57
+      text-align: center;
58
+      line-height: .46rem;
59
+      font-size: .16rem;
60
+      color: #fff;
61
+    }
62
+  }
63
+}

+ 18
- 4
src/pages/user/receiveResults/index.vue View File

@@ -3,9 +3,11 @@
3 3
     <div class="contenr">
4 4
       <i class="iconfont icon-ziyuan" v-if="status === 'success'"></i>
5 5
       <i class="iconfont icon-shibai fail" v-else></i>
6
-      <span>领取成功!</span>
7
-      <span>快去个人中心查看我的体验券</span>
8
-      <div class="back" v-if="status === 'success'">查看我的体验券</div>
6
+      <span v-if="status === 'success'">领取成功</span>
7
+      <span v-else>领取失败</span>
8
+      <span v-if="status === 'success'">快去个人中心查看我的体验券</span>
9
+      <span v-else>{{msg}}</span>
10
+      <div class="back" v-if="status === 'success'" @click="back">查看我的体验券</div>
9 11
       <div v-else></div>
10 12
       <img :src="logo">
11 13
     </div>
@@ -14,6 +16,8 @@
14 16
 
15 17
 <script>
16 18
 import logo from '../../../common/icon/logoTop.png'
19
+import { createNamespacedHelpers } from 'vuex'
20
+const { mapState: mapShareState } = createNamespacedHelpers('share')
17 21
 export default {
18 22
   data () {
19 23
     return {
@@ -21,8 +25,18 @@ export default {
21 25
       status: 'fail'
22 26
     }
23 27
   },
28
+  computed: {
29
+    ...mapShareState({
30
+      msg: x => x.msg
31
+    })
32
+  },
24 33
   created () {
25
-
34
+    this.status = this.$route.query.type
35
+  },
36
+  methods: {
37
+    back () {
38
+      this, $router.push({ name: 'userCenter' })
39
+    }
26 40
   }
27 41
 }
28 42
 </script>

+ 14
- 0
src/pages/user/router.js View File

@@ -23,6 +23,7 @@ import gymCardDetail from './gymCardDetail/index' // 健身卡详情
23 23
 import couponsDetail from './couponsDetail/index' // 体验券详情
24 24
 import receive from './receive/index' // 领取页面
25 25
 import receiveResults from './receiveResults/index' // 领取结果页面
26
+import receiveChannel from './receiveChannel/index' // 渠道领取页面
26 27
 
27 28
 Vue.use(Router)
28 29
 
@@ -137,6 +138,19 @@ const router = new Router({
137 138
     name: 'receiveResults',
138 139
     component: receiveResults,
139 140
     children: []
141
+  }, { // 卡券领取(带参数,分享后的路径)
142
+    path: '/receiveShared/:id/:salesid/:type/:sharetype',
143
+    name: 'receive',
144
+    component: receive
145
+  }, { // 渠道卡券领取
146
+    path: '/receiveChannel',
147
+    name: 'receiveChannel',
148
+    component: receiveChannel,
149
+    children: []
150
+  }, { // 渠道卡券领取(带参数,分享后的路径)
151
+    path: '/receiveChannelShared/:id/:type/:sharetype',
152
+    name: 'receiveChannel',
153
+    component: receiveChannel
140 154
   }],
141 155
   linkActiveClass: 'active',
142 156
 })

+ 1
- 0
src/store/index.js View File

@@ -23,6 +23,7 @@ export const modules = {
23 23
   myCard: () => require('./myCard/index').default,
24 24
   card: () => require('./card/index').default,
25 25
   forbid: () => require('./forbid/index').default,
26
+  share: () => require('./share/index').default,
26 27
 }
27 28
 
28 29
 Object.keys(modules).forEach((modKey) => {

+ 123
- 0
src/store/share/index.js View File

@@ -0,0 +1,123 @@
1
+import Ajax from '../../util/ajax'
2
+import api from '../../util/api'
3
+
4
+// 请求数据
5
+export default {
6
+  namespaced: true,
7
+  state: {
8
+    cardShare: {},
9
+    couponShare: {},
10
+    msg: ''
11
+  },
12
+  mutations: {
13
+    setCardShare (state, data) {
14
+      state.cardShare = data || {}
15
+    },
16
+    setCouponShare (state, data) {
17
+      state.couponShare = data || {}
18
+    },
19
+    setMsg (state, msg) {
20
+      state.msg = msg || ''
21
+    }
22
+  },
23
+  actions: {
24
+    getCardShare (context, data) {
25
+      return new Promise((resolve, reject) => {
26
+        Ajax({
27
+          ...api.share.card,
28
+          urlData: {
29
+            id: data.id
30
+          }
31
+        }).then(res => {
32
+          context.commit('setCardShare', res)
33
+          resolve(res)
34
+        }).catch((err) => {
35
+          reject(err)
36
+        })
37
+      })
38
+    },
39
+    getCouponShare (context, data) {
40
+      return new Promise((resolve, reject) => {
41
+        Ajax({
42
+          ...api.share.coupon,
43
+          urlData: {
44
+            id: data.id
45
+          }
46
+        }).then(res => {
47
+          context.commit('setCouponShare', res)
48
+          resolve(res)
49
+        }).catch((err) => {
50
+          reject(err)
51
+        })
52
+      })
53
+    },
54
+    setCardShare (context, data) {
55
+      return new Promise((resolve, reject) => {
56
+        Ajax({
57
+          ...api.share.setCard,
58
+          urlData: {
59
+            id: data.id
60
+          },
61
+          data: {
62
+            saleid: data.salesid,
63
+            serialcode: data.serialcode
64
+          }
65
+        }).then(res => {
66
+          resolve(res)
67
+        }).catch((err) => {
68
+          context.commit('setMsg', err)
69
+          reject(err)
70
+        })
71
+      })
72
+    },
73
+    setCouponShare (context, data) {
74
+      return new Promise((resolve, reject) => {
75
+        Ajax({
76
+          ...api.share.setCoupon,
77
+          urlData: {
78
+            id: data.id
79
+          },
80
+          data: {
81
+            saleid: data.salesid,
82
+            serialcode: data.serialcode
83
+          }
84
+        }).then(res => {
85
+          resolve(res)
86
+        }).catch((err) => {
87
+          context.commit('setMsg', err)
88
+          reject(err)
89
+        })
90
+      })
91
+    },
92
+    setChannelCardShare (context, data) {
93
+      return new Promise((resolve, reject) => {
94
+        Ajax({
95
+          ...api.share.setChannelCard,
96
+          urlData: {
97
+            id: data.id
98
+          }
99
+        }).then(res => {
100
+          resolve(res)
101
+        }).catch((err) => {
102
+          context.commit('setMsg', err)
103
+          reject(err)
104
+        })
105
+      })
106
+    },
107
+    setChannelCouponShare (context, data) {
108
+      return new Promise((resolve, reject) => {
109
+        Ajax({
110
+          ...api.share.setChannelCoupon,
111
+          urlData: {
112
+            id: data.id
113
+          }
114
+        }).then(res => {
115
+          resolve(res)
116
+        }).catch((err) => {
117
+          context.commit('setMsg', err)
118
+          reject(err)
119
+        })
120
+      })
121
+    }
122
+  }
123
+}

+ 1
- 0
src/util/ajax.js View File

@@ -82,6 +82,7 @@ const ajax = (...args) => {
82 82
           forbidClick: true, // 禁用背景点击
83 83
           message: message
84 84
         })
85
+        reject(message)
85 86
       }
86 87
     }).catch(reject)
87 88
   })

+ 24
- 0
src/util/api.js View File

@@ -189,6 +189,30 @@ const $api = {
189 189
     share: {
190 190
       method: 'get',
191 191
       url: `${baseUrl}${guest}/wechat/jssdk/signature/:url`
192
+    },
193
+    card: {
194
+      method: 'get',
195
+      url: `${baseUrl}${wechat}/card/:id`
196
+    },
197
+    coupon: {
198
+      method: 'get',
199
+      url: `${baseUrl}${wechat}/coupon/:id`
200
+    },
201
+    setCard: {
202
+      method: 'post',
203
+      url: `${baseUrl}${wechat}/card/:id`
204
+    },
205
+    setCoupon: {
206
+      method: 'post',
207
+      url: `${baseUrl}${wechat}/coupon/:id`
208
+    },
209
+    setChannelCard: {
210
+      method: 'post',
211
+      url: `${baseUrl}${wechat}/channel/card/:id`
212
+    },
213
+    setChannelCoupon: {
214
+      method: 'post',
215
+      url: `${baseUrl}${wechat}/channel/coupon/:id`
192 216
     }
193 217
   }
194 218
 }