zjxpcyc 6 年前
父节点
当前提交
9ebb4bcdb0
共有 5 个文件被更改,包括 94 次插入76 次删除
  1. 3
    2
      src/App.vue
  2. 58
    43
      src/components/music.vue
  3. 4
    4
      src/views/vote/detail.vue
  4. 12
    4
      src/views/vote/list.vue
  5. 17
    23
      src/views/vote/signup.vue

+ 3
- 2
src/App.vue 查看文件

@@ -1,7 +1,7 @@
1 1
 <template>
2 2
   <div id="app" v-if="showPage">
3 3
     <router-view/>
4
-    <music :url="activity.Music"></music>
4
+    <music :url="activity.Music" :theme="theme"></music>
5 5
   </div>
6 6
 </template>
7 7
 
@@ -23,7 +23,8 @@ export default {
23 23
   },
24 24
   computed: {
25 25
     ...mapactivityState({
26
-      activity: s => s.activity || {}
26
+      activity: s => s.activity || {},
27
+      theme: s => `${s.theme}`,
27 28
     })
28 29
   },
29 30
   created() {

+ 58
- 43
src/components/music.vue 查看文件

@@ -1,42 +1,55 @@
1 1
 <template>
2
-    <div class="musicbox">
3
-      <!-- 播放 -->
4
-      <div class="play" v-if="audioPlayShow" @click="audioState">
5
-        <img  src="https://spaceofcheng.oss-cn-beijing.aliyuncs.com/voting/yttj_icon_music_open.png">
6
-      </div>
7
-      <!-- 暂停-->
8
-      <div class="play" v-else @click="audioState">
9
-         <img  src="https://spaceofcheng.oss-cn-beijing.aliyuncs.com/voting/yttj_icon_music_close.png" >
10
-      </div>
11
-      <audio ref="player" :src="url" autoplay preload loop="loop"></audio>
2
+    <div class="musicbox" @click="troggle">
3
+      <img :class="playing" :src="icons[theme][playing]" alt="">
4
+      <audio ref="player" :src="url" preload loop="loop"></audio>
12 5
     </div>
13 6
 </template>
14 7
 <script>
15
-// import { createNamespacedHelpers } from 'vuex'
16
-// const {
17
-//   mapState: mapactivityState,
18
-// } = createNamespacedHelpers("vote");
19 8
 export default {
20 9
   name:'music',
21
-  props:['url'],
10
+  props: {
11
+    url: String,
12
+    theme: String
13
+  },
22 14
   data() {
23 15
     return {
24
-      yttjmusicopen:'https://spaceofcheng.oss-cn-beijing.aliyuncs.com/voting/yttj_icon_music_open.png',
25
-      yjsmusicopen:'https://spaceofcheng.oss-cn-beijing.aliyuncs.com/voting/yinyueon.png',
26
-      yttjmusicoff:'https://spaceofcheng.oss-cn-beijing.aliyuncs.com/voting/yttj_icon_music_close.png',
27
-      yjsmusicoff:'https://spaceofcheng.oss-cn-beijing.aliyuncs.com/voting/yinyueoff.png',
28
-      audioPlayShow: true,
16
+      playing: 'off',
17
+
18
+      icons: {
19
+        '1': {
20
+          'on': 'https://spaceofcheng.oss-cn-beijing.aliyuncs.com/voting/yttj_icon_music_open.png',
21
+          'off': 'https://spaceofcheng.oss-cn-beijing.aliyuncs.com/voting/yttj_icon_music_close.png',
22
+        },
23
+        '2': {
24
+          'on': 'https://spaceofcheng.oss-cn-beijing.aliyuncs.com/voting/yinyueon.png',
25
+          'off': 'https://spaceofcheng.oss-cn-beijing.aliyuncs.com/voting/yinyueoff.png',
26
+        },
27
+      }
29 28
     };
30 29
   },
30
+  watch: {
31
+    url: function(n) {
32
+      if (this.playing === 'off' && n) {
33
+        window.setTimeout(this.play, 1000)
34
+      }
35
+    }
36
+  },
31 37
   methods: {
32
-    // 点击播放暂停按钮时间
33
-    audioState() {
34
-      this.audioPlayShow = !this.audioPlayShow; // 更改播放暂停按钮状态
35
-      const music = this.$refs.player; // 音频所在对象
36
-      if (this.audioPlayShow) {
37
-        music.play(); // 播放音乐
38
+    play() {
39
+      if (this.url) {
40
+        this.$refs.player.play()
41
+        this.playing = 'on'
42
+      }
43
+    },
44
+    stop() {
45
+      this.$refs.player.pause()
46
+      this.playing = 'off'
47
+    },
48
+    troggle() {
49
+      if (this.playing === 'on') {
50
+        this.stop()
38 51
       } else {
39
-        music.pause(); // 暂停音乐
52
+        this.play()
40 53
       }
41 54
     }
42 55
   }
@@ -44,33 +57,35 @@ export default {
44 57
 </script>
45 58
 
46 59
 <style lang="scss" scoped>
47
-// @keyframes changDeg{
48
-// 			0%{
49
-// 				transform: rotate(0deg);
50
-// 			}
51
-// 			100%{
52
-// 				transform: rotate(360deg);
53
-// 			}
54
-// 		}
60
+  @keyframes rotate{
61
+    0%{
62
+      transform: rotate(0deg);
63
+    }
64
+    100%{
65
+      transform: rotate(360deg);
66
+    }
67
+  }
68
+
55 69
   .musicbox {
56 70
     position: fixed;
57 71
     top: 0.09rem;
58 72
     right: 0.09rem;
59
-    width: 0.5rem;
60
-    height: 0.5rem;
73
+    width: 0.35rem;
74
+    height: 0.35rem;
61 75
     border-radius: 50%;
62 76
     z-index: 10;
63 77
 
64
-    .play {
78
+    .on {
79
+      animation: rotate 3s linear infinite;
80
+    }
81
+
82
+    img {
65 83
       width: 100%;
66 84
       height: 100%;
67
-
68
-      img {
69
-        width: 100%;
70
-        height: 100%;
71
-      }
72 85
     }
73 86
   }
87
+
88
+
74 89
 </style>
75 90
 
76 91
 

+ 4
- 4
src/views/vote/detail.vue 查看文件

@@ -66,11 +66,11 @@ export default {
66 66
   mounted() {
67 67
     this.actid = this.$route.params.actid;
68 68
     if(this.actid==1){
69
- this.coverImgUrl = true;
70
- this.desc = true;
69
+      this.coverImgUrl = true;
70
+      this.desc = true;
71 71
     }else if(this.actid==2){
72
-this.coverImgUrl = false;
73
-this.desc = false;
72
+      this.coverImgUrl = false;
73
+      this.desc = false;
74 74
     }
75 75
     this.memberid = this.$route.params.memberid;
76 76
     this.getActivity({

+ 12
- 4
src/views/vote/list.vue 查看文件

@@ -62,7 +62,7 @@
62 62
         </van-tabs>
63 63
       </div>
64 64
     </div>
65
-    <button :class="signupBtn?'signupBtnOne':'signupBtnTwo'" @click="signup">我要报名</button>
65
+    <button :class="signupBtn?'signupBtnOne':'signupBtnTwo'" @click="signup">{{ myprofile && myprofile.MemberId ? '我的上传' : '投TA一票' }}</button>
66 66
     <toast v-if="show" :url="activity.AfterVote" @close="close" @confirmbtn="tolink"></toast>
67 67
   </div>
68 68
 </template>
@@ -130,6 +130,7 @@ export default {
130 130
       topList: x => x.toplist,
131 131
       user: x => x.user,
132 132
       theme: x => x.theme,
133
+      myprofile: x => x.myprofile,
133 134
     }),
134 135
   },
135 136
   created() {
@@ -159,6 +160,7 @@ export default {
159 160
     })
160 161
     this.getMine({
161 162
       actid: this.actid,
163
+      openid: this.user.openid,
162 164
     })
163 165
 
164 166
     // 列表数据的初始化 放到下拉组件中了
@@ -286,9 +288,15 @@ export default {
286 288
       })
287 289
     },
288 290
     signup() {
289
-      this.$router.push({
290
-        path: `/vote/signup/${this.actid}`
291
-      });
291
+      if (this.myprofile && this.myprofile.MemberId) {
292
+        this.$router.push({
293
+          path: `/detail/${this.actid}/${this.myprofile.MemberId}`
294
+        });
295
+      } else {
296
+        this.$router.push({
297
+          path: `/vote/signup/${this.actid}`
298
+        });
299
+      }
292 300
     },
293 301
     gotovotingdetails(memberid) {
294 302
       this.$router.push({

+ 17
- 23
src/views/vote/signup.vue 查看文件

@@ -6,7 +6,8 @@
6 6
         <span :class="desc?desc1:desc2">上传您认为最美的全家福照片</span>
7 7
       </div>
8 8
       <van-uploader :after-read="onRead">
9
-        <img class="uploadimgbox" :src="desc?uploadimg1:uploadimg2">
9
+        <img v-if="postData.photo" class="uploadimgbox" :src="postData.photo" alt="">
10
+        <img v-else class="uploadimgbox" :src="theme == 1? uploadimg1 : uploadimg2">
10 11
       </van-uploader>
11 12
       <div class="WriteWord" v-if="writeword">
12 13
         <img :src="img?yttjpen:yjspen">
@@ -103,11 +104,15 @@ export default {
103 104
   },
104 105
   computed: {
105 106
     ...mapVoteState({
106
-      user: x => x.user
107
+      user: x => x.user,
108
+      theme: x => x.theme,
107 109
     })
108 110
   },
109 111
   created() {
110 112
     this.actid = this.$route.params.actid;
113
+     this.getActivity({
114
+      actid: this.actid,
115
+    })
111 116
     if (this.actid == 1) {
112 117
       this.coverImgUrl = true;
113 118
       this.img = true;
@@ -128,30 +133,19 @@ export default {
128 133
     }
129 134
   },
130 135
   methods: {
131
-    ...mapVoteActions(["voteMember"]),
136
+    ...mapVoteActions(["voteMember", "getActivity"]),
132 137
     onRead(file) {
133
-      console.log(file);
134 138
       let that = this;
135 139
       this.isLoading = true;
136
-      let reader = new FileReader();
137
-      reader.readAsDataURL(file.file);
138
-      reader.onload = function(e) {
139
-        let data = e.target.result;
140
-        //加载图片获取图片真实宽度和高度
141
-        let image = new Image();
142
-        image.src = data;
143
-        image.onload = function() {
144
-          that.toolClass
145
-            .upload(file)
146
-            .then(res => {
147
-              that.uploadimg = res.result.url;
148
-              that.postData.photo = res.result.url;
149
-            })
150
-            .catch(() => {
151
-              that.isLoading = false;
152
-            });
153
-        };
154
-      };
140
+      that.toolClass
141
+        .upload(file)
142
+        .then(res => {
143
+          that.uploadimg = res.result.url;
144
+          that.postData.photo = res.result.url;
145
+        })
146
+        .catch(() => {
147
+          that.isLoading = false;
148
+        });
155 149
     },
156 150
     messageWrite() {
157 151
       this.messagenum = this.postData.message.length;