zjxpcyc 6 lat temu
rodzic
commit
9ebb4bcdb0

+ 3
- 2
src/App.vue Wyświetl plik

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

+ 58
- 43
src/components/music.vue Wyświetl plik

1
 <template>
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
     </div>
5
     </div>
13
 </template>
6
 </template>
14
 <script>
7
 <script>
15
-// import { createNamespacedHelpers } from 'vuex'
16
-// const {
17
-//   mapState: mapactivityState,
18
-// } = createNamespacedHelpers("vote");
19
 export default {
8
 export default {
20
   name:'music',
9
   name:'music',
21
-  props:['url'],
10
+  props: {
11
+    url: String,
12
+    theme: String
13
+  },
22
   data() {
14
   data() {
23
     return {
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
   methods: {
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
       } else {
51
       } else {
39
-        music.pause(); // 暂停音乐
52
+        this.play()
40
       }
53
       }
41
     }
54
     }
42
   }
55
   }
44
 </script>
57
 </script>
45
 
58
 
46
 <style lang="scss" scoped>
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
   .musicbox {
69
   .musicbox {
56
     position: fixed;
70
     position: fixed;
57
     top: 0.09rem;
71
     top: 0.09rem;
58
     right: 0.09rem;
72
     right: 0.09rem;
59
-    width: 0.5rem;
60
-    height: 0.5rem;
73
+    width: 0.35rem;
74
+    height: 0.35rem;
61
     border-radius: 50%;
75
     border-radius: 50%;
62
     z-index: 10;
76
     z-index: 10;
63
 
77
 
64
-    .play {
78
+    .on {
79
+      animation: rotate 3s linear infinite;
80
+    }
81
+
82
+    img {
65
       width: 100%;
83
       width: 100%;
66
       height: 100%;
84
       height: 100%;
67
-
68
-      img {
69
-        width: 100%;
70
-        height: 100%;
71
-      }
72
     }
85
     }
73
   }
86
   }
87
+
88
+
74
 </style>
89
 </style>
75
 
90
 
76
 
91
 

+ 4
- 4
src/views/vote/detail.vue Wyświetl plik

66
   mounted() {
66
   mounted() {
67
     this.actid = this.$route.params.actid;
67
     this.actid = this.$route.params.actid;
68
     if(this.actid==1){
68
     if(this.actid==1){
69
- this.coverImgUrl = true;
70
- this.desc = true;
69
+      this.coverImgUrl = true;
70
+      this.desc = true;
71
     }else if(this.actid==2){
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
     this.memberid = this.$route.params.memberid;
75
     this.memberid = this.$route.params.memberid;
76
     this.getActivity({
76
     this.getActivity({

+ 12
- 4
src/views/vote/list.vue Wyświetl plik

62
         </van-tabs>
62
         </van-tabs>
63
       </div>
63
       </div>
64
     </div>
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
     <toast v-if="show" :url="activity.AfterVote" @close="close" @confirmbtn="tolink"></toast>
66
     <toast v-if="show" :url="activity.AfterVote" @close="close" @confirmbtn="tolink"></toast>
67
   </div>
67
   </div>
68
 </template>
68
 </template>
130
       topList: x => x.toplist,
130
       topList: x => x.toplist,
131
       user: x => x.user,
131
       user: x => x.user,
132
       theme: x => x.theme,
132
       theme: x => x.theme,
133
+      myprofile: x => x.myprofile,
133
     }),
134
     }),
134
   },
135
   },
135
   created() {
136
   created() {
159
     })
160
     })
160
     this.getMine({
161
     this.getMine({
161
       actid: this.actid,
162
       actid: this.actid,
163
+      openid: this.user.openid,
162
     })
164
     })
163
 
165
 
164
     // 列表数据的初始化 放到下拉组件中了
166
     // 列表数据的初始化 放到下拉组件中了
286
       })
288
       })
287
     },
289
     },
288
     signup() {
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
     gotovotingdetails(memberid) {
301
     gotovotingdetails(memberid) {
294
       this.$router.push({
302
       this.$router.push({

+ 17
- 23
src/views/vote/signup.vue Wyświetl plik

6
         <span :class="desc?desc1:desc2">上传您认为最美的全家福照片</span>
6
         <span :class="desc?desc1:desc2">上传您认为最美的全家福照片</span>
7
       </div>
7
       </div>
8
       <van-uploader :after-read="onRead">
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
       </van-uploader>
11
       </van-uploader>
11
       <div class="WriteWord" v-if="writeword">
12
       <div class="WriteWord" v-if="writeword">
12
         <img :src="img?yttjpen:yjspen">
13
         <img :src="img?yttjpen:yjspen">
103
   },
104
   },
104
   computed: {
105
   computed: {
105
     ...mapVoteState({
106
     ...mapVoteState({
106
-      user: x => x.user
107
+      user: x => x.user,
108
+      theme: x => x.theme,
107
     })
109
     })
108
   },
110
   },
109
   created() {
111
   created() {
110
     this.actid = this.$route.params.actid;
112
     this.actid = this.$route.params.actid;
113
+     this.getActivity({
114
+      actid: this.actid,
115
+    })
111
     if (this.actid == 1) {
116
     if (this.actid == 1) {
112
       this.coverImgUrl = true;
117
       this.coverImgUrl = true;
113
       this.img = true;
118
       this.img = true;
128
     }
133
     }
129
   },
134
   },
130
   methods: {
135
   methods: {
131
-    ...mapVoteActions(["voteMember"]),
136
+    ...mapVoteActions(["voteMember", "getActivity"]),
132
     onRead(file) {
137
     onRead(file) {
133
-      console.log(file);
134
       let that = this;
138
       let that = this;
135
       this.isLoading = true;
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
     messageWrite() {
150
     messageWrite() {
157
       this.messagenum = this.postData.message.length;
151
       this.messagenum = this.postData.message.length;