Files
dvcp_v2_wxcp_app/src/project/fengdu/AppVote/voteDetail.vue

88 lines
2.3 KiB
Vue
Raw Normal View History

2022-12-29 14:35:15 +08:00
<template>
<section class="voteDetail">
2022-12-30 18:10:03 +08:00
<AiItem top-label :label="detail.videoName" :border="false" labelBold>
<u-parse class="mar-b8" :html="detail.videoIntroduction"/>
2023-01-03 10:17:47 +08:00
<video :src="detail.videoFileUrl" :poster="detail.imageFileUrl"/>
2022-12-30 18:10:03 +08:00
</AiItem>
2022-12-29 14:35:15 +08:00
<AiBottomBtn background="#fff">
<div flex class="pad-l32 pad-r16 pad-b16 pad-t16">
2022-12-30 18:10:03 +08:00
<AiHighlight class="fill color-999" content="当前票数:@v" :value="detail.voteNumber" color="#FF6900"/>
<div class="text circle mar-l16" :class="{disabled:canotVote}" @click="handleVote">投票</div>
2022-12-29 14:35:15 +08:00
</div>
</AiBottomBtn>
</section>
</template>
<script>
2022-12-29 14:49:43 +08:00
import {mapState, mapActions} from "vuex"
2022-12-29 14:35:15 +08:00
export default {
name: "voteDetail",
appName: "投票详情",
2022-12-29 14:49:43 +08:00
computed: {
...mapState(['user']),
2022-12-30 18:10:03 +08:00
wxCode: v => v.$route.query.code,
canotVote: v => v.detail.isVote == '0' && v.user.token
2022-12-29 14:49:43 +08:00
},
2022-12-29 14:35:15 +08:00
data() {
return {
detail: {}
}
},
methods: {
2022-12-29 14:49:43 +08:00
...mapActions(['getWechatToken', 'getCode']),
2022-12-29 14:35:15 +08:00
getDetail() {
2022-12-30 18:10:03 +08:00
const {id} = this.$route.query
this.$http.post("/app/appvideoinfo/queryDetailById", null, {params: {id}, withoutToken: true}).then(res => {
2022-12-29 14:35:15 +08:00
if (res?.data) {
this.detail = res.data
2022-12-30 18:10:03 +08:00
document.title = this.detail.videoName
2022-12-29 14:35:15 +08:00
}
})
},
handleVote() {
if (!this.user.token) {//未登录,获取openId和token
this.$http.get("/app/appdvcpconfig/getMpAppid", {withoutToken: true}).then(res => {
if (res?.code == 0 && res?.data) {
this.getCode({scope: "snsapi_userinfo", appid: res.data})
}
})
} else {//已登录,直接投票
2022-12-30 18:10:03 +08:00
if (!this.canotVote) {
const {id} = this.$route.query
this.$http.post("/app/appvideovoteinfo/voteByVideoId", null, {
params: {id}
}).then(res => {
if (res?.code == 0) {
this.$u.toast("投票成功!")
this.getDetail()
}
})
}
2022-12-29 14:35:15 +08:00
}
},
},
onShow() {
this.getDetail()
2022-12-29 15:39:15 +08:00
if (!!this.wxCode) {
this.getWechatToken({module: "AppVote", code: this.wxCode}).then(this.handleVote)
}
2022-12-29 14:35:15 +08:00
}
}
</script>
<style lang="scss" scoped>
.voteDetail {
background: #F3F6F9;
min-height: 100vh;
2022-12-30 18:10:03 +08:00
::v-deep.disabled {
filter: grayscale(100%);
}
::v-deep video {
width: 100%;
}
2022-12-29 14:35:15 +08:00
}
</style>