yuantianjiao hace 6 años
padre
commit
d2fc7dc7c0

+ 3
- 2
package.json Ver fichero

@@ -23,7 +23,8 @@
23 23
     "node-sass": "^4.9.0",
24 24
     "sass-loader": "^7.0.1",
25 25
     "vant": "^1.4.8",
26
-    "vue-template-compiler": "^2.5.17"
26
+    "vue-template-compiler": "^2.5.17",
27
+    "weixin-js-sdk": "^1.4.0-test"
27 28
   },
28 29
   "eslintConfig": {
29 30
     "root": true,
@@ -51,4 +52,4 @@
51 52
     "last 2 versions",
52 53
     "not ie <= 8"
53 54
   ]
54
-}
55
+}

+ 1
- 1
src/store/index.js Ver fichero

@@ -10,7 +10,7 @@ const store = new Vuex.Store({
10 10
   }
11 11
 })
12 12
 export const modules = {
13
-  login: () => require('./main').default,
13
+  main: () => require('./main').default,
14 14
 }
15 15
 
16 16
 Object.keys(modules).forEach((modKey) => {

+ 97
- 11
src/store/main.js Ver fichero

@@ -4,26 +4,112 @@ import api from '../util/api'
4 4
 export default {
5 5
   namespaced: true,
6 6
   state: {
7
-    userInfo: {}
7
+    gameid: '1',
8
+    game: {},
9
+    userInfo: {
10
+      Address: "江苏省,南京市,玄武区",
11
+      CreateDate: "2018-12-08T19:06:15+08:00",
12
+      CustomerId: "1",
13
+      CustomerName: "kini",
14
+      HeadImg: "",
15
+      Name: "袁天骄",
16
+      Openid: "123",
17
+      Phone: "13776975175",
18
+      Sex: 0
19
+    },
20
+    recordInfo: {},
21
+    supports: []
8 22
   },
9 23
   mutations: {
10
-    updateMenu (state, data) {
11
-      state.menuData = data || []
24
+    updateGame (state, data) {
25
+      state.game = data || {}
26
+    },
27
+    updateUserInfo (state, data) {
28
+      state.userInfo = data || {}
29
+    },
30
+    updateRecordInfo (state, data) {
31
+      state.recordInfo = data.record || {}
32
+      state.supports = data.supports || []
12 33
     }
13 34
   },
14 35
   actions: {
15
-    login (context, data) {
16
-      context
36
+    getGame (context) {
17 37
       return new Promise((resolve, reject) => {
18 38
         ajax({
19
-          ...api.common.login,
20
-          data: {
21
-            ...data,
39
+          ...api.game,
40
+          urlData: {
41
+            gameid: context.state.gameid,
42
+            customerid: context.state.userInfo.CustomerId
22 43
           }
23
-        }).then(() => {
24
-          resolve()
44
+        }).then((res) => {
45
+          context.commit('updateGame', res)
46
+          resolve(res)
25 47
         }).catch(reject)
26 48
       })
27
-    }
49
+    },
50
+    customer (context, data) {
51
+      return new Promise((resolve, reject) => {
52
+        ajax({
53
+          ...api.customer,
54
+          urlData: {
55
+            code: data
56
+          }
57
+        }).then((res) => {
58
+          context.commit('updateUserInfo', res)
59
+          resolve(res)
60
+        }).catch(reject)
61
+      })
62
+    },
63
+    signUp (context, data) {
64
+      return new Promise((resolve, reject) => {
65
+        ajax({
66
+          ...api.signup,
67
+          urlData: {
68
+            customerid: context.state.userInfo.customerid
69
+          },
70
+          data: data
71
+        }).then((res) => {
72
+          resolve(res)
73
+        }).catch(reject)
74
+      })
75
+    },
76
+    setRecord (context) {
77
+      return new Promise((resolve, reject) => {
78
+        ajax({
79
+          ...api.setRecord,
80
+          urlData: {
81
+            customerid: context.state.userInfo.CustomerId,
82
+            gameid: context.state.gameid
83
+          }
84
+        }).then((res) => {
85
+          resolve(res)
86
+        }).catch(reject)
87
+      })
88
+    },
89
+    getRecord (context, data) {
90
+      return new Promise((resolve, reject) => {
91
+        ajax({
92
+          ...api.getRecord,
93
+          urlData: {
94
+            recordid: data
95
+          }
96
+        }).then((res) => {
97
+          context.commit('updateRecordInfo', res)
98
+          resolve(res)
99
+        }).catch(reject)
100
+      })
101
+    },
102
+    setSupport (context, data) {
103
+      return new Promise((resolve, reject) => {
104
+        ajax({
105
+          ...api.setSupport,
106
+          urlData: {
107
+            ...data
108
+          }
109
+        }).then((res) => {
110
+          resolve(res)
111
+        }).catch(reject)
112
+      })
113
+    },
28 114
   }
29 115
 }

+ 24
- 9
src/util/api.js Ver fichero

@@ -1,15 +1,30 @@
1
-// const baseUrl = '/api-v2'
2 1
 const baseUrl = '/api'
3
-const wechat = '/wechat/:org'
4
-const guest = '/guest/:org'
5
-const common = '/common/:org'
2
+const common = ''
6 3
 
7 4
 const $api = {
8
-  file: {
9
-    image: { // 图片上传
10
-      method: 'post',
11
-      url: `${baseUrl}${common}/file`
12
-    }
5
+  game: { // 助力详情
6
+    method: 'get',
7
+    url: `${baseUrl}${common}/game/:gameid/:customerid`
8
+  },
9
+  customer: { // 用户信息
10
+    method: 'get',
11
+    url: `${baseUrl}${common}/customer/:code`
12
+  },
13
+  signup: { // 注册
14
+    method: 'post',
15
+    url: `${baseUrl}${common}/signup/:customerid`
16
+  },
17
+  setRecord: { // 报名
18
+    method: 'post',
19
+    url: `${baseUrl}${common}/record/:customerid/:gameid`
20
+  },
21
+  getRecord: { // 获取活动详情
22
+    method: 'get',
23
+    url: `${baseUrl}${common}/record/:recordid`
24
+  },
25
+  setSupport: { // 助力
26
+    method: 'post',
27
+    url: `${baseUrl}${common}/support/:customerid/:recordid`
13 28
   }
14 29
 }
15 30
 export default $api

+ 117
- 30
src/views/supportDetail/supportDetail.vue Ver fichero

@@ -1,20 +1,20 @@
1 1
 <template>
2
-  <div class="pageContent">
2
+  <div class="pageContent" v-if="showPage">
3 3
     <div class="mainPage">
4 4
       <div class="top">
5 5
         <img :src="topImg">
6 6
         <div class="top-div" v-if="status<4">
7
-          <div class="countdown" :class="{'on':status ===1,'off':status===2}" v-html="countdown()"></div>
7
+          <div class="countdown" :class="{'on':status < 3,'off':status == 3}" v-html="countdown"></div>
8 8
           <div class="userInfo">
9 9
             <div class="avatars">
10
-              <img class="cover" src>
10
+              <img class="cover" :src="userInfo.HeadImg">
11 11
             </div>
12 12
             <div class="info">
13
-              <p>&nbsp;匿名</p>
13
+              <p>&nbsp;{{userInfo.Name}}</p>
14 14
               <p>
15 15
                 已有
16
-                <span class="marked">0</span> 位好友帮TA砍价了,共砍掉
17
-                <span class="marked">¥0</span> 元
16
+                <span class="marked">{{list.length}}</span> 位好友帮TA砍价了,共砍掉
17
+                <span class="marked">¥{{list.length*29.6}}</span> 元
18 18
               </p>
19 19
             </div>
20 20
           </div>
@@ -33,12 +33,12 @@
33 33
       <div class="active" v-if="status<4">
34 34
         <h2>悦见山全家福拍摄助力砍价活动</h2>
35 35
         <div class="price">
36
-          <span class="price">砍后价:¥260</span>
36
+          <span :class="{'off':status == 3}">砍后价:¥{{888-list.length*29.6}}</span>
37 37
           <span>最多砍至0元</span>
38 38
         </div>
39 39
         <div class="desc">
40 40
           <span>原价2888元, 悦见山亲情价¥888</span>
41
-          <span>仅剩0个名额</span>
41
+          <span>仅剩{{game.note.LeftNum}}个名额</span>
42 42
         </div>
43 43
       </div>
44 44
       <div class="list">
@@ -61,7 +61,8 @@
61 61
         </div>
62 62
       </div>
63 63
     </div>
64
-    <div class="dailog" v-if="showDailog" @click="showDailog = false">
64
+    <!-- <div class="dailog" v-if="showDailog" @click="showDailog = false"> -->
65
+    <div class="dailog" v-if="showDailog">
65 66
       <div class="dailog-box" @click.stop="1+1">
66 67
         <img :src="popBg">
67 68
         <div class="log1">
@@ -70,31 +71,31 @@
70 71
             29.6
71 72
             <span>元</span>
72 73
           </div>
73
-          <div>
74
+          <div @click="toLuckDraw()">
74 75
             您有一份福利待领取!去领取
75 76
             <i class="iconfont icon-you"></i>
76 77
           </div>
77 78
           <img class="present" :src="presentClose">
78
-          <img class="btn" :src="btn">
79
+          <img class="btn" :src="btn" @click="$router.push({name:'supportMain'})">
79 80
         </div>
80 81
       </div>
81 82
     </div>
82
-    <div class="other-end" v-if="status === 5">
83
+    <div class="other-end" v-if="status == 5">
83 84
       <div class="box">
84 85
         <p>您的好友已砍价至0元,</p>
85 86
         <p>获得免费拍照机会!</p>
86
-        <div>我也要报名</div>
87
+        <div @click="$router.push({name:'supportMain'})">我也要报名</div>
87 88
       </div>
88 89
     </div>
89
-    <div class="today-end" v-if="status === 6">
90
+    <div class="today-end" v-if="status == 6">
90 91
       <div class="box">
91 92
         <img :src="kulian">
92 93
         <p>今日的主力活动已结束,</p>
93 94
         <p>明天再来吧!</p>
94 95
       </div>
95 96
     </div>
96
-    <div class="bottom">
97
-      <div :class="{'on':status === 1,'off':status !== 1}">{{btnText}}</div>
97
+    <div class="bottom" v-if="status < 4">
98
+      <div :class="{'on':status < 3,'off':status == 3}" @click="support()">{{btnText}}</div>
98 99
     </div>
99 100
   </div>
100 101
 </template>
@@ -106,8 +107,10 @@ import popBg from '@/assets/pop-bg.png'
106 107
 import presentClose from '@/assets/presentClose.png'
107 108
 import btn from '@/assets/btn.png'
108 109
 import kulian from '@/assets/kulian.png'
110
+import wxsdk from '@/util/share'
109 111
 import { createNamespacedHelpers } from 'vuex'
110 112
 const { mapState: mapIndexState, mapActions: mapIndexActions } = createNamespacedHelpers('main')
113
+// const wx = require('weixin-js-sdk')
111 114
 export default {
112 115
   data () {
113 116
     return {
@@ -117,29 +120,110 @@ export default {
117 120
       presentClose,
118 121
       btn,
119 122
       kulian,
120
-      status: 4,
123
+      status: 1,
121 124
       btnText: '邀请好友助力',
122 125
       showDailog: false,
123
-      list: [1, 1, 1, 1, 1, 2]
126
+      showPage: false,
127
+      seconds: 0,
128
+      time: 0
124 129
     }
125 130
   },
126 131
   computed: {
127 132
     ...mapIndexState({
128
-      userInfo: item => item.userInfo
133
+      userInfo: item => item.userInfo,
134
+      game: item => item.game,
135
+      recordInfo: item => item.recordInfo,
136
+      list: item => item.supports
137
+    }),
138
+    countdown () {
139
+      if (this.status != 3 && this.time >= 0) {
140
+        let hour = 23 - new Date().getHours()
141
+        let minutes = 59 - new Date().getMinutes()
142
+        let seconds = 59 - new Date().getSeconds()
143
+        return `<span style='color:#fff;'>砍价倒计时</span>
144
+        <span style='padding: 0 0.03rem;background: #5e5e5e;color: #fff;border-radius:4px;'>${hour > 9 ? hour : '0' + hour}</span>
145
+        <span style='color:#fff;'>:</span>
146
+        <span style='padding: 0 0.03rem;background: #5e5e5e;color: #fff;border-radius:4px;'>${minutes > 9 ? minutes : '0' + minutes}</span>
147
+        <span style='color:#fff;'>:</span>
148
+        <span style='padding: 0 0.03rem;background: rgba(255, 66, 28, 1);color: #fff;border-radius:4px;'>${seconds > 9 ? seconds : '0' + seconds}</span>`
149
+      } else {
150
+        let hour = '00'
151
+        let minutes = '00'
152
+        let seconds = '00'
153
+        return `<span style='color:#fff;'>活动已结束</span>
154
+        <span style='padding: 0 0.03rem;background: #5e5e5e;color: #fff;border-radius:4px;'>${hour}</span>
155
+        <span style='color:#fff;'>:</span>
156
+        <span style='padding: 0 0.03rem;background: #5e5e5e;color: #fff;border-radius:4px;'>${minutes}</span>
157
+        <span style='color:#fff;'>:</span>
158
+        <span style='padding: 0 0.03rem;background: rgba(255, 66, 28, 1);color: #fff;border-radius:4px;'>${seconds}</span>`
159
+      }
160
+    }
161
+  },
162
+  created () {
163
+    this.getGame().then(() => {
164
+      if (!this.$route.query.recordid) {
165
+        this.getRecord(this.game.record.RecordId).then(() => {
166
+          this.checkStatus()
167
+          // this.share(this.game.record.RecordId)
168
+        })
169
+      } else {
170
+        this.getRecord(this.game.record.RecordId).then(() => {
171
+          // this.share(this.$route.query.recordid)
172
+          this.checkStatus()
173
+        })
174
+      }
129 175
     })
176
+    setInterval(() => {
177
+      this.time = new Date().getSeconds()
178
+    }, 1000)
130 179
   },
131 180
   methods: {
132
-    ...mapIndexActions(['setUserInfo']),
133
-    countdown () {
134
-      let hour = 20
135
-      let minutes = 40
136
-      let seconds = 30
137
-      return `<span style='color:#fff;'>砍价倒计时</span>
138
-      <span style='padding: 0 0.03rem;background: #5e5e5e;color: #fff;border-radius:4px;'>${hour}</span>
139
-      <span style='color:#fff;'>:</span>
140
-      <span style='padding: 0 0.03rem;background: #5e5e5e;color: #fff;border-radius:4px;'>${minutes}</span>
141
-      <span style='color:#fff;'>:</span>
142
-      <span style='padding: 0 0.03rem;background: rgba(255, 66, 28, 1);color: #fff;border-radius:4px;'>${seconds}</span>`
181
+    ...mapIndexActions(['getGame', 'getRecord', 'setSupport']),
182
+    checkStatus () {
183
+      if (this.$route.query.other === 'other') {
184
+        this.status = 2
185
+        this.btnText = '立即助力TA'
186
+        if (this.list.length >= this.game.game.UserNum) {
187
+          this.status = 5
188
+        }
189
+      } else {
190
+        if (this.list.length >= this.game.game.UserNum) {
191
+          this.status = 4
192
+        }
193
+      }
194
+      let end = new Date(this.game.game.EndDate).valueOf()
195
+      let now = new Date().valueOf()
196
+      if (now > end) {
197
+        this.status = 3
198
+        this.btnText = '立即助力TA'
199
+      } else if (this.game.note.LeftNum <= 0 && !this.$route.query.other) {
200
+        this.status = 6
201
+      }
202
+      this.showPage = true
203
+    },
204
+    share (recordid) {
205
+      wxsdk({ url: encodeURIComponent(window.location.href.split('#')[0]) }, {
206
+        title: '城的空间',
207
+        desc: '城的空间',
208
+        link: `${window.location.origin}${window.location.pathname}#/supportDetail?other=other&recordid=${recordid}`,
209
+        thu_image: `https://spaceofcheng.oss-cn-beijing.aliyuncs.com/indexlogo.jpg?x-oss-process=style/wxicon`
210
+      })
211
+    },
212
+    support () {
213
+      if (this.status === 1) {
214
+        this.$toast('微信右上角分享,让好友帮你助力哦!')
215
+      } else if (this.status === 2) {
216
+        this.setSupport({ customerid: this.userInfo.CustomerId, recordid: this.$route.query.recordid }).then(() => {
217
+          this.showDailog = true
218
+        }).catch(() => {
219
+          this.showDailog = true
220
+        })
221
+      } else if (this.status === 3) {
222
+        this.$toast('活动已结束')
223
+      }
224
+    },
225
+    toLuckDraw () {
226
+
143 227
     }
144 228
   }
145 229
 }
@@ -359,6 +443,9 @@ export default {
359 443
       margin-right: 0.2rem;
360 444
       font-size: 0.13rem;
361 445
     }
446
+    .off {
447
+      background: #b8b8b8;
448
+    }
362 449
   }
363 450
   .desc {
364 451
     display: flex;

+ 100
- 17
src/views/supportMain/supportMain.vue Ver fichero

@@ -1,11 +1,11 @@
1 1
 <template>
2
-  <div class="pageContent">
2
+  <div class="pageContent" v-if="showPage">
3 3
     <div class="mainPage">
4 4
       <div class="top">
5 5
         <img :src="topImg">
6 6
         <div class="top-div">
7
-          <b>悦见山全家福拍摄助力砍价活动</b>
8
-          <p>时间: 2018年12月17日-12月25日</p>
7
+          <b>{{game.game.GameName}}</b>
8
+          <p>时间: {{`${this.toolClass.dateFormat(game.game.BeginDate,'yyyy年MM月dd日')} ~ ${this.toolClass.dateFormat(game.game.EndDate,'yyyy年MM月dd日')}`}}</p>
9 9
           <p>地点: 南京悦见山G99</p>
10 10
         </div>
11 11
       </div>
@@ -26,10 +26,13 @@
26 26
       </div>
27 27
     </div>
28 28
     <div class="bottom">
29
-      <div :class="{'on':btn.status === 1,'off':btn.status !== 1}">{{btn.text}}</div>
29
+      <div
30
+        :class="{'on':btn.status === 1 || btn.status === 3,'off':btn.status === 0 || btn.status === 2}"
31
+        @click="submit()"
32
+      >{{btn.text}}</div>
30 33
     </div>
31
-    <div class="login" v-if="login">
32
-      <div class="box">
34
+    <div class="login" v-if="login" @click="login=false">
35
+      <div class="box" @click.stop="1+1">
33 36
         <div class="item">
34 37
           <label for="name">姓名</label>
35 38
           <input type="text" v-model="name">
@@ -40,13 +43,20 @@
40 43
         </div>
41 44
         <div class="item">
42 45
           <label for="address">住址</label>
43
-          <input type="text" v-model="address">
46
+          <div @click="showArea = true">{{address}}</div>
44 47
         </div>
45 48
         <textarea name="addressDetail" rows="5" placeholder="详细地址" v-model="adderssDetail"></textarea>
46
-        <div class="submit">提交</div>
49
+        <div class="submit" @click="sign()">提交</div>
47 50
       </div>
48 51
     </div>
49
-    <van-area :area-list="area" @confirm="confirm" @cancel="cancel"/>
52
+    <van-area
53
+      class="area"
54
+      :value="'320100'"
55
+      :area-list="area"
56
+      @confirm="confirm"
57
+      @cancel="cancel"
58
+      v-if="showArea"
59
+    />
50 60
   </div>
51 61
 </template>
52 62
 
@@ -65,33 +75,103 @@ export default {
65 75
         status: 1
66 76
       },
67 77
       login: false,
78
+      showArea: false,
68 79
       name: '',
69 80
       phone: '',
70 81
       address: '',
71
-      adderssDetail: ''
82
+      adderssDetail: '',
83
+      showPage: false
72 84
     }
73 85
   },
74 86
   created () {
75
-    console.log(area)
87
+    this.getGame().then(() => {
88
+      if (this.game.record.CustomerId) {
89
+        this.btn.text = '我的助力'
90
+        this.btn.status = 3
91
+      } else {
92
+        let start = new Date(this.game.game.BeginDate).valueOf()
93
+        let end = new Date(this.game.game.EndDate).valueOf()
94
+        let now = new Date().valueOf()
95
+        if (now < start) {
96
+          this.btn.text = '活动未开始'
97
+          this.btn.status = 0
98
+        } else if (start <= now && now <= end) {
99
+          this.btn.text = '立即报名'
100
+          this.btn.status = 1
101
+        } else if (now > end) {
102
+          this.btn.text = '活动已结束'
103
+          this.btn.status = 2
104
+        }
105
+      }
106
+      this.showPage = true
107
+    })
76 108
   },
77 109
   computed: {
78 110
     ...mapIndexState({
79
-      userInfo: item => item.userInfo
111
+      userInfo: item => item.userInfo,
112
+      game: item => item.game,
80 113
     })
81 114
   },
82 115
   methods: {
83
-    ...mapIndexActions(['setUserInfo']),
84
-    confirm () {
85
-
116
+    ...mapIndexActions(['getGame', 'signUp', 'setRecord']),
117
+    confirm (val) {
118
+      this.address = `${val[0].name},${val[1].name},${val[2].name}`
119
+      this.showArea = false
86 120
     },
87 121
     cancel () {
88
-
122
+      this.showArea = false
123
+    },
124
+    submit () {
125
+      if (this.userInfo.Phone) {
126
+        this.record()
127
+      } else {
128
+        this.login = true
129
+      }
130
+    },
131
+    sign () {
132
+      if (!this.name) {
133
+        this.$toast('姓名为必填项')
134
+        return
135
+      } else if (!this.phone) {
136
+        this.$toast('手机号为必填项')
137
+        return
138
+      } else if (!this.address) {
139
+        this.$toast('地址为必填项')
140
+        return
141
+      } else if (!this.adderssDetail) {
142
+        this.$toast('详细地址为必填项')
143
+        return
144
+      }
145
+      let data = {
146
+        name: this.name,
147
+        phone: this.phone,
148
+        address: this.address + this.adderssDetail
149
+      }
150
+      this.signUp(data).then(() => {
151
+        this.record()
152
+      })
153
+    },
154
+    record () {
155
+      if (this.btn.status === 1) {
156
+        this.setRecord().then(() => {
157
+          this.$router.push({ name: 'supportDetail' })
158
+        })
159
+      } else if (this.btn.status === 3) {
160
+        this.$router.push({ name: 'supportDetail' })
161
+      }
89 162
     }
90 163
   }
91 164
 }
92 165
 </script>
93 166
 
94 167
 <style lang="scss" scoped>
168
+.area {
169
+  position: fixed;
170
+  bottom: 0;
171
+  left: 0;
172
+  z-index: 1001;
173
+  width: 100%;
174
+}
95 175
 .top {
96 176
   img {
97 177
     width: 100%;
@@ -165,11 +245,14 @@ export default {
165 245
         width: 0.5rem;
166 246
         color: rgba(168, 182, 200, 1);
167 247
       }
168
-      input {
248
+      input,
249
+      div {
169 250
         height: 100%;
170 251
         flex: 1;
171 252
         border-radius: 4px;
172 253
         border: 1px solid rgba(168, 182, 200, 0.2);
254
+        line-height: 0.28rem;
255
+        padding-left: 0.05rem;
173 256
       }
174 257
     }
175 258
     textarea {

+ 2
- 2
vue.config.js Ver fichero

@@ -6,8 +6,8 @@ module.exports = {
6 6
   devServer: {
7 7
     proxy: {
8 8
       '/api': {
9
-        target: 'http://wechatconfigdev.ycjcjy.com',
10
-        // target: 'http://192.168.0.62:8080', // wf
9
+        // target: 'http://wechatconfigdev.ycjcjy.com',
10
+        target: 'http://192.168.0.62:8080', // wf
11 11
         // target: 'http://192.168.0.102:8080', // hyq
12 12
         // target: 'http://192.168.0.11', // zys
13 13
         // target: 'http://dev.ycjcjy.com', // frp