wangfei 6 년 전
부모
커밋
4aead07faa
6개의 변경된 파일163개의 추가작업 그리고 29개의 파일을 삭제
  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 파일 보기

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

+ 2
- 2
src/router.js 파일 보기

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

+ 67
- 2
src/store/vote.js 파일 보기

5
   namespaced: true,
5
   namespaced: true,
6
   state: {
6
   state: {
7
     activity: {},
7
     activity: {},
8
+    user: '3',
9
+    detail: {},
8
   },
10
   },
9
   mutations: {
11
   mutations: {
10
     updateActivity (state, data) {
12
     updateActivity (state, data) {
11
       state.activity = data || {}
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
   actions: {
22
   actions: {
15
     getActivity ({ commit }, {actid}) {
23
     getActivity ({ commit }, {actid}) {
16
       return new Promise((resolve, reject) => {
24
       return new Promise((resolve, reject) => {
17
         ajax({
25
         ajax({
18
-          ...api.getactivity,
26
+          ...api.voteing.info,
19
           urlData: {
27
           urlData: {
20
             actid: actid,
28
             actid: actid,
21
           }
29
           }
25
         }).catch(reject)
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 파일 보기

7
       url: `${baseUrl}/file`
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
 export default $api
37
 export default $api

+ 41
- 10
src/views/vote/detail.vue 파일 보기

1
 <template>
1
 <template>
2
   <div class="context">
2
   <div class="context">
3
     <div class="ContextbBox">
3
     <div class="ContextbBox">
4
-      <span class="personnumber">NO.20000</span>
4
+      <span class="personnumber">NO.{{detail.MemberId}}</span>
5
       <span class="votelist">投票列表</span>
5
       <span class="votelist">投票列表</span>
6
-      <img :src="AudioPlay">
6
+      <img :src="detail.Photo">
7
       <div class="detailinformation">
7
       <div class="detailinformation">
8
         <div class="nameinformation">
8
         <div class="nameinformation">
9
-          <span class="information">璐璐</span>
9
+          <span class="information">{{detail.Name}}</span>
10
           <span class="information">姓名</span>
10
           <span class="information">姓名</span>
11
         </div>
11
         </div>
12
         <span class="line"></span>
12
         <span class="line"></span>
13
         <div class="nameinformation">
13
         <div class="nameinformation">
14
-          <span class="informationnum">221800</span>
14
+          <span class="informationnum">{{detail.Vote}}</span>
15
           <span class="information">当前票数</span>
15
           <span class="information">当前票数</span>
16
         </div>
16
         </div>
17
         <span class="line"></span>
17
         <span class="line"></span>
18
         <div class="nameinformation">
18
         <div class="nameinformation">
19
-          <span class="information">120名</span>
19
+          <span class="information">{{detail.Rank}}名</span>
20
           <span class="information">排名</span>
20
           <span class="information">排名</span>
21
         </div>
21
         </div>
22
       </div>
22
       </div>
23
     </div>
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
       <span class="dashedline"></span>
26
       <span class="dashedline"></span>
27
-      <span class="writeword">寄语:加油!非常有爱的一个家庭,希望能抽中大奖! 希望大家多多支持,多多投票~希望能抽中大奖!</span>
27
+      <span class="writeword">寄语:{{detail.Message}}</span>
28
     </div>
28
     </div>
29
   </div>
29
   </div>
30
 </template>
30
 </template>
31
 <script>
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
 export default {
35
 export default {
34
   name: "votingdetails",
36
   name: "votingdetails",
35
   data() {
37
   data() {
36
     return {
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
 </script>
71
 </script>
41
 <style lang="scss" scoped>
72
 <style lang="scss" scoped>

+ 23
- 4
src/views/vote/signup.vue 파일 보기

27
       <input placeholder="输入姓名" v-model="postData.name"/>
27
       <input placeholder="输入姓名" v-model="postData.name"/>
28
       <!-- <textarea class="addressarea" placeholder="所在社区"></textarea> -->
28
       <!-- <textarea class="addressarea" placeholder="所在社区"></textarea> -->
29
       <div class="btn">
29
       <div class="btn">
30
-          <button class="SubmitBtn">提交</button>
30
+          <button class="SubmitBtn" @click="SubmitBtn">提交</button>
31
       </div>
31
       </div>
32
     </div>
32
     </div>
33
   </div>
33
   </div>
49
         name: '',
49
         name: '',
50
         addr: '',
50
         addr: '',
51
         message: '',
51
         message: '',
52
-      }
52
+      },
53
+      actid: '',
53
     };
54
     };
54
   },
55
   },
55
   computed: {
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
   methods: {
68
   methods: {
58
     ...mapVoteActions([
69
     ...mapVoteActions([
59
-      '',
70
+      'voteMember',
60
     ]),
71
     ]),
61
     onRead (file) {
72
     onRead (file) {
62
       let that = this
73
       let that = this
82
       this.messagenum = this.postData.message.length
93
       this.messagenum = this.postData.message.length
83
     },
94
     },
84
     SubmitBtn () {
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
 };