wangfei 6 yıl önce
ebeveyn
işleme
4aead07faa
6 değiştirilmiş dosya ile 163 ekleme ve 29 silme
  1. 5
    4
      src/App.vue
  2. 2
    2
      src/router.js
  3. 67
    2
      src/store/vote.js
  4. 25
    7
      src/util/api.js
  5. 41
    10
      src/views/vote/detail.vue
  6. 23
    4
      src/views/vote/signup.vue

+ 5
- 4
src/App.vue Dosyayı Görüntüle

@@ -7,7 +7,7 @@
7 7
 <script>
8 8
 import './assets/css/reset.css'
9 9
 import { createNamespacedHelpers } from 'vuex'
10
-const { mapActions: mapIndexActions } = createNamespacedHelpers('main')
10
+const { mapActions: mapIndexActions } = createNamespacedHelpers('vote')
11 11
 export default {
12 12
   data () {
13 13
     return {
@@ -23,15 +23,16 @@ export default {
23 23
     //     this.toolClass.getCode('wx32e2e8c81f66070e')
24 24
     //   } else {
25 25
     //     localStorage.setItem('code', this.code)
26
-    //     // this.customer(this.code).then(() => {
27
-    //     this.showPage = true
28
-    //     // })
26
+    //     this.customer(this.code).then(() => {
27
+    //       this.showPage = true
28
+    //     })
29 29
     //   }
30 30
     // } else {
31 31
     //   this.toolClass.getCode('wx32e2e8c81f66070e')
32 32
     // }
33 33
   },
34 34
   methods: {
35
+    ...mapIndexActions(['user'])
35 36
   }
36 37
 }
37 38
 </script>

+ 2
- 2
src/router.js Dosyayı Görüntüle

@@ -16,12 +16,12 @@ export default new Router({
16 16
       component: () => import('./views/vote/list.vue')
17 17
     },
18 18
     {
19
-      path: '/detail/:id',
19
+      path: '/detail/:actid/:memberid',
20 20
       name: 'voteDetail',
21 21
       component: () => import('./views/vote/detail.vue')
22 22
     },
23 23
     {
24
-      path: '/vote/signup/:id',
24
+      path: '/vote/signup/:actid',
25 25
       name: 'signUp',
26 26
       component: () => import('./views/vote/signup.vue')
27 27
     }

+ 67
- 2
src/store/vote.js Dosyayı Görüntüle

@@ -5,17 +5,25 @@ export default {
5 5
   namespaced: true,
6 6
   state: {
7 7
     activity: {},
8
+    user: '3',
9
+    detail: {},
8 10
   },
9 11
   mutations: {
10 12
     updateActivity (state, data) {
11 13
       state.activity = data || {}
12 14
     },
15
+    updateUser (state, data) {
16
+      state.user = data
17
+    },
18
+    updateDetail (state, data) {
19
+      state.detail = data || {}
20
+    }
13 21
   },
14 22
   actions: {
15 23
     getActivity ({ commit }, {actid}) {
16 24
       return new Promise((resolve, reject) => {
17 25
         ajax({
18
-          ...api.getactivity,
26
+          ...api.voteing.info,
19 27
           urlData: {
20 28
             actid: actid,
21 29
           }
@@ -25,8 +33,65 @@ export default {
25 33
         }).catch(reject)
26 34
       })
27 35
     },
28
-    voteMember ({ commit }, payload) {
36
+    getMember ({ commit }, payload) {
37
+      return new Promise((resolve, reject) => {
38
+        ajax({
39
+          ...api.voteing.detail,
40
+          urlData: {
41
+            actid: payload.actid,
42
+            memberid: payload.memberid,
43
+          },
44
+        }).then((res) => {
45
+          commit('updateDetail', res)
46
+          resolve(res)
47
+        }).catch(reject)
48
+      })
49
+    },
50
+    vote (m, payload) {
51
+      return new Promise((resolve, reject) => {
52
+        ajax({
53
+          ...api.voteing.vote,
54
+          urlData: {
55
+            actid: payload.actid,
56
+            memberid: payload.memberid,
57
+          },
58
+          queryData: {
59
+            openid: payload.openid,
60
+          }
61
+        }).then((res) => {
29 62
 
63
+          resolve(res)
64
+        }).catch(reject)
65
+      })
30 66
     },
67
+    voteMember ({ commit }, payload) {
68
+      return new Promise((resolve, reject) => {
69
+        ajax({
70
+          ...api.voteing.registe,
71
+          urlData: {
72
+            actid: payload.actid,
73
+          },
74
+          queryData: {
75
+            ...payload,
76
+          }
77
+        }).then((res) => {
78
+          commit('updateDetail', res)
79
+          resolve(res)
80
+        }).catch(reject)
81
+      })
82
+    },
83
+    getUser ({ commit }, { code }) {
84
+      return new Promise((resolve, reject) => {
85
+        ajax({
86
+          ...api.voteing.user,
87
+          urlData: {
88
+            code: code,
89
+          },
90
+        }).then((res) => {
91
+          commit('updateUser', res)
92
+          resolve(res)
93
+        }).catch(reject)
94
+      })
95
+    }
31 96
   }
32 97
 }

+ 25
- 7
src/util/api.js Dosyayı Görüntüle

@@ -7,13 +7,31 @@ const $api = {
7 7
       url: `${baseUrl}/file`
8 8
     },
9 9
   },
10
-  getactivity: {
11
-    url: `${baseUrl}/voting/:actid`,
12
-    method: 'get',
13
-  },
14
-  getactivitylist:{
15
-    url: `${baseUrl}/voting`,
16
-    method: 'get',
10
+  voteing: {
11
+    info: {
12
+      url: `${baseUrl}/voting/:actid`,
13
+      method: 'get',
14
+    },
15
+    list: {
16
+      url: `${baseUrl}/voting`,
17
+      method: 'get',
18
+    },
19
+    user: {
20
+      url: `${baseUrl}/wechat/user/:code`,
21
+      method: 'get',
22
+    },
23
+    detail: {
24
+      url: `${baseUrl}/voting/:actid/:memberid`,
25
+      method: 'get',
26
+    },
27
+    registe: {
28
+      url: `${baseUrl}/voting/:actid`,
29
+      method: 'post',
30
+    },
31
+    vote: {
32
+      url: `${baseUrl}/voting/:actid/:memberid`,
33
+      method: 'post',
34
+    }
17 35
   }
18 36
 }
19 37
 export default $api

+ 41
- 10
src/views/vote/detail.vue Dosyayı Görüntüle

@@ -1,41 +1,72 @@
1 1
 <template>
2 2
   <div class="context">
3 3
     <div class="ContextbBox">
4
-      <span class="personnumber">NO.20000</span>
4
+      <span class="personnumber">NO.{{detail.MemberId}}</span>
5 5
       <span class="votelist">投票列表</span>
6
-      <img :src="AudioPlay">
6
+      <img :src="detail.Photo">
7 7
       <div class="detailinformation">
8 8
         <div class="nameinformation">
9
-          <span class="information">璐璐</span>
9
+          <span class="information">{{detail.Name}}</span>
10 10
           <span class="information">姓名</span>
11 11
         </div>
12 12
         <span class="line"></span>
13 13
         <div class="nameinformation">
14
-          <span class="informationnum">221800</span>
14
+          <span class="informationnum">{{detail.Vote}}</span>
15 15
           <span class="information">当前票数</span>
16 16
         </div>
17 17
         <span class="line"></span>
18 18
         <div class="nameinformation">
19
-          <span class="information">120名</span>
19
+          <span class="information">{{detail.Rank}}名</span>
20 20
           <span class="information">排名</span>
21 21
         </div>
22 22
       </div>
23 23
     </div>
24
-    <button class="votebtn">投TA一票</button>
25
-    <div class="showorhide">
24
+    <button class="votebtn" @click="Vote">投TA一票</button>
25
+    <div class="showorhide" v-if="detail.Message != ''">
26 26
       <span class="dashedline"></span>
27
-      <span class="writeword">寄语:加油!非常有爱的一个家庭,希望能抽中大奖! 希望大家多多支持,多多投票~希望能抽中大奖!</span>
27
+      <span class="writeword">寄语:{{detail.Message}}</span>
28 28
     </div>
29 29
   </div>
30 30
 </template>
31 31
 <script>
32
-// import AudioPlay from "../../images/audio_play.png";
32
+import { createNamespacedHelpers } from 'vuex';
33
+const {mapState: mapVoteState, mapActions: mapVoteActions} = createNamespacedHelpers('vote')
34
+
33 35
 export default {
34 36
   name: "votingdetails",
35 37
   data() {
36 38
     return {
39
+      actid: '',
40
+      memberid: '',
37 41
     };
38
-  }
42
+  },
43
+  mounted() {
44
+    this.actid = this.$route.params.actid;
45
+    this.memberid = this.$route.params.memberid;
46
+    this.getMember({
47
+      actid: this.actid,
48
+      memberid: this.memberid,
49
+    })
50
+  },
51
+  computed: {
52
+    ...mapVoteState({
53
+      detail: x => x.detail,
54
+      user: x => x.user,
55
+    })
56
+  },
57
+  methods: {
58
+    ...mapVoteActions([
59
+      'getMember',
60
+      'vote',
61
+    ]),
62
+    Vote() {
63
+      this.vote({
64
+        actid: this.actid,
65
+        memberid: this.memberid,
66
+        openid: this.user,
67
+      })
68
+    }
69
+  },
39 70
 };
40 71
 </script>
41 72
 <style lang="scss" scoped>

+ 23
- 4
src/views/vote/signup.vue Dosyayı Görüntüle

@@ -27,7 +27,7 @@
27 27
       <input placeholder="输入姓名" v-model="postData.name"/>
28 28
       <!-- <textarea class="addressarea" placeholder="所在社区"></textarea> -->
29 29
       <div class="btn">
30
-          <button class="SubmitBtn">提交</button>
30
+          <button class="SubmitBtn" @click="SubmitBtn">提交</button>
31 31
       </div>
32 32
     </div>
33 33
   </div>
@@ -49,14 +49,25 @@ export default {
49 49
         name: '',
50 50
         addr: '',
51 51
         message: '',
52
-      }
52
+      },
53
+      actid: '',
53 54
     };
54 55
   },
55 56
   computed: {
57
+    ...mapVoteState({
58
+      user: x => x.user
59
+    })
60
+  },
61
+  created () {
62
+    if(this.$route.params.actid != '') {
63
+      this.actid = this.$route.params.actid
64
+    } else {
65
+      alert("不存在对应的活动信息!")
66
+    }
56 67
   },
57 68
   methods: {
58 69
     ...mapVoteActions([
59
-      '',
70
+      'voteMember',
60 71
     ]),
61 72
     onRead (file) {
62 73
       let that = this
@@ -82,7 +93,15 @@ export default {
82 93
       this.messagenum = this.postData.message.length
83 94
     },
84 95
     SubmitBtn () {
85
-
96
+      this.voteMember({
97
+        actid: this.actid,
98
+        openid: this.user,
99
+        ...this.postData,
100
+      }).then((res) => {
101
+        this.$router.push({
102
+          path: `/detail/${this.actid}/${res.MemberId}`
103
+        })
104
+      })
86 105
     },
87 106
   },
88 107
 };