wangfei 6 anni fa
parent
commit
baa6f7a5b7
5 ha cambiato i file con 72 aggiunte e 45 eliminazioni
  1. 5
    2
      src/store/vote.js
  2. 8
    3
      src/util/api.js
  3. 0
    16
      src/util/util.js
  4. 1
    4
      src/views/vote/list.vue
  5. 58
    20
      src/views/vote/signup.vue

+ 5
- 2
src/store/vote.js Vedi File

@@ -12,7 +12,7 @@ export default {
12 12
     },
13 13
   },
14 14
   actions: {
15
-    getActivity (context, {actid}) {
15
+    getActivity ({ commit }, {actid}) {
16 16
       return new Promise((resolve, reject) => {
17 17
         ajax({
18 18
           ...api.getactivity,
@@ -20,10 +20,13 @@ export default {
20 20
             actid: actid,
21 21
           }
22 22
         }).then((res) => {
23
-          context.commit('updateActivity', res)
23
+          commit('updateActivity', res)
24 24
           resolve(res)
25 25
         }).catch(reject)
26 26
       })
27 27
     },
28
+    voteMember ({ commit }, payload) {
29
+
30
+    },
28 31
   }
29 32
 }

+ 8
- 3
src/util/api.js Vedi File

@@ -1,13 +1,18 @@
1 1
 const baseUrl = '/api'
2
-const common = ''
3 2
 
4 3
 const $api = {
4
+  file: {
5
+    image: { // 图片上传
6
+      method: 'post',
7
+      url: `${baseUrl}/file`
8
+    },
9
+  },
5 10
   getactivity: {
6
-    url: '/api/voting/:actid',
11
+    url: `${baseUrl}/voting/:actid`,
7 12
     method: 'get',
8 13
   },
9 14
   getactivitylist:{
10
-    url: '/api/voting',
15
+    url: `${baseUrl}/voting`,
11 16
     method: 'get',
12 17
   }
13 18
 }

+ 0
- 16
src/util/util.js Vedi File

@@ -60,22 +60,6 @@ const toolClass = {
60 60
       }).catch(reject)
61 61
     })
62 62
   },
63
-  uploadBase64 (base64) {
64
-    return new Promise((resolve, reject) => {
65
-      Ajax({
66
-        ...api.file.base64,
67
-        queryData: {
68
-          namestr: base64.namestr
69
-        },
70
-        data: { base64str: base64.base64str },
71
-      }).then((res) => {
72
-        let result = {
73
-          result: res
74
-        }
75
-        resolve(result)
76
-      }).catch(reject)
77
-    })
78
-  }
79 63
 }
80 64
 
81 65
 export default toolClass

+ 1
- 4
src/views/vote/list.vue Vedi File

@@ -111,10 +111,7 @@ export default {
111 111
     },
112 112
     signup() {
113 113
       this.$router.push({
114
-        name: "signup",
115
-        query: {
116
-          actid: this.$route.query.actid,
117
-        }
114
+        path: `/vote/signup/${this.actid}`,
118 115
       });
119 116
     },
120 117
     gotovotingdetails() {

+ 58
- 20
src/views/vote/signup.vue Vedi File

@@ -2,55 +2,93 @@
2 2
   <div class="context">
3 3
     <div class="ContextBox">
4 4
       <div class="uploadimg">
5
-        <img :src="FamilyPortraitIcon">
5
+        <img src="https://spaceofcheng.oss-cn-beijing.aliyuncs.com/voting/yttj_icon_love.png">
6 6
         <span>上传您认为最美的全家福照片</span>
7 7
       </div>
8
-      <img class="uploadimgbox" :src="uploadimg">
8
+      <van-uploader :after-read="onRead">
9
+        <img class="uploadimgbox" :src="uploadimg">
10
+      </van-uploader>
9 11
       <div class="WriteWord">
10
-        <img :src="WriteWordIcon">
12
+        <img src="https://spaceofcheng.oss-cn-beijing.aliyuncs.com/voting/yttj_icon_pen.png">
11 13
         <span>寄语</span>
12 14
       </div>
13 15
       <div class="input_content">
14
-        <textarea id="textArea" class="content_txt" maxlength="200"></textarea>
16
+        <textarea id="textArea" @input="messageWrite" maxlength="200" v-model="postData.message" class="content_txt" ></textarea>
15 17
         <span class="number">
16
-          <span id="textNum">0</span>
18
+          <span id="textNum">{{messagenum}}</span>
17 19
           <span class="totalnum" >/200</span>
18 20
         </span>
19 21
       </div>
20 22
       <div class="ContactInformation">
21
-          <img :src="ContactInformationIcon"/>
23
+          <img src="https://spaceofcheng.oss-cn-beijing.aliyuncs.com/voting/yttj_icon_phone.png"/>
22 24
           <span>联系方式</span>
23 25
       </div>
24
-      <input placeholder="输入手机号"/>
25
-      <input placeholder="输入姓名"/>
26
+      <input placeholder="输入手机号" v-model="postData.phone"/>
27
+      <input placeholder="输入姓名" v-model="postData.name"/>
26 28
       <!-- <textarea class="addressarea" placeholder="所在社区"></textarea> -->
27 29
       <div class="btn">
28 30
           <button class="SubmitBtn">提交</button>
29 31
       </div>
30
-      
31 32
     </div>
32 33
   </div>
33 34
 </template>
34 35
 
35 36
 <script>
36
-// import FamilyPortraitIcon from "../../common/icon/xin.png";
37
-// import WriteWordIcon from "../../common/icon/xiegenjin.png";
38
-// import ContactInformationIcon from "../../common/icon/dianhua.png"
39
-// import uploadimg from "../../images/uploadimg.png";
37
+import { createNamespacedHelpers } from 'vuex';
38
+const {mapState: mapVoteState, mapActions: mapVoteActions} = createNamespacedHelpers('vote')
40 39
 export default {
41
-  name: "signup",
40
+  name: 'signup',
42 41
   data() {
43 42
     return {
44
-      // FamilyPortraitIcon,
45
-      // WriteWordIcon,
46
-      // uploadimg,
47
-      // ContactInformationIcon,
43
+      isLoading: false,
44
+      uploadimg: 'https://spaceofcheng.oss-cn-beijing.aliyuncs.com/voting/uploadimg.png',
45
+      messagenum: 0,
46
+      postData: {
47
+        photo: '',
48
+        phone: '',
49
+        name: '',
50
+        addr: '',
51
+        message: '',
52
+      }
48 53
     };
49
-  }
54
+  },
55
+  computed: {
56
+  },
57
+  methods: {
58
+    ...mapVoteActions([
59
+      '',
60
+    ]),
61
+    onRead (file) {
62
+      let that = this
63
+      this.isLoading = true
64
+      let reader = new FileReader();
65
+      reader.readAsDataURL(file.file);
66
+      reader.onload = function (e) {
67
+        let data = e.target.result;
68
+        //加载图片获取图片真实宽度和高度
69
+        let image = new Image();
70
+        image.src = data;
71
+        image.onload = function () {
72
+          that.toolClass.upload(file).then((res) => {
73
+            that.uploadimg = res.result.url
74
+            that.postData.photo = res.result.url
75
+          }).catch(() => {
76
+            that.isLoading = false
77
+          })
78
+        };
79
+      };
80
+    },
81
+    messageWrite () {
82
+      this.messagenum = this.postData.message.length
83
+    },
84
+    SubmitBtn () {
85
+
86
+    },
87
+  },
50 88
 };
51 89
 </script>
52 90
 
53
-<style lang="scss" scoped>
91
+<style lang='scss' scoped>
54 92
 .context {
55 93
   width: 100%;
56 94
   height: 100%;