| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- <template>
- <view :style="vuex_skin">
- <u-popup v-model="show" mode="bottom" width="100%" height="750" border-radius="15" :closeable="true">
- <view class="padding-30">
- <view class="padding-top-20 text-bold text-xl">投票助力</view>
- <view
- style="color: #888888;font-size: 22rpx;font-family: PingFang-SC-Medium;line-height: 36rpx;padding: 20rpx 0;">
- {{voteContent()}}
- </view>
- <scroll-view style="white-space: nowrap;" :scroll-x="true">
- <view v-for="(item,index) in gitfs" :key="index" class="gift-item">
- <view @click.stop="selected = index;count = index" class="padding-20"
- :class="{'icon-box': true,'selected': index == selected}">
- <image mode="aspectFit" class="gift-img" :src="item.imgUrl"></image>
- <view class="gift-name text-cut-1">{{item.name}}</view>
- </view>
- <view style="color: #999999;font-size: 20rpx;text-align: center;padding-top: 10rpx;">
- {{item.activeVote== -1 ? '不限次数' : '剩余次数:' + item.remainCount}}
- </view>
- </view>
- </scroll-view>
- <view class="handle-bar">
- <block v-if="voteText === '移动积分'">
- <view v-if="pointNum>=0" class="text-center padding-bottom-20" style="color: #0A9FEF;">您目前的移动积分:
- {{pointNum}}
- </view>
- <view v-else class="text-center padding-bottom-20" style="color: #0A9FEF;">您目前的移动积分 <u-loading
- style="margin: 10rpx;" mode="circle"></u-loading>
- </view>
- </block>
- <view class="button-bar">
- <view class="button-r">
- <u-count-to v-if="show" :color="vuex_theme.bgColor" start-val="0" :end-val="voteText === '元' ? gitfs[selected].amount : gitfs[selected].point"
- :duration="500" :decimals="voteText === '元' ? 2 : 0"></u-count-to>
- <span class="info">{{voteText}}</span>
- </view>
- <view class="button-f" @click="toVote">点击投票</view>
- </view>
- </view>
- </view>
- </u-popup>
- <toast ref="toast"></toast>
- <point-auth ref="pointAuth"></point-auth>
- <!-- #ifdef MP-WEIXIN -->
- <loading ref="loading" type="3" />
- <!-- #endif -->
- </view>
- </template>
- <script>
- import pointAuth from '../../components/alert/pointAuth.vue'
- import config from "@/assets/http/config.js"
- export default {
- name: "votePopup",
- components: {
- pointAuth
- },
- data() {
- return {
- productId: 0,
- show: false,
- selected: 0,
- count: 0,
- pointNum: 0,
- gitfs: [],
- };
- },
- computed: {
- voteContent() {
- return data => {
- if (this.gitfs[this.selected] && this.gitfs[this.selected].content) {
- return this.gitfs[this.selected].content
- }
- return ''
- }
- },
- voteText: {
- get() {
- if(this.gitfs[this.selected] && this.gitfs[this.selected].payType === 'CASH_EXCHANGE_GOODS'){
- return "元"
- }
- return "移动积分"
- }
- }
- },
- methods: {
- hideLoading() {
- // #ifdef MP-WEIXIN
- this.$refs.loading.hide()
- // #endif
- // #ifndef MP-WEIXIN
- uni.hideLoading()
- // #endif
- },
- showLoading() {
- // #ifdef MP-WEIXIN
- this.$refs.loading.showLoading("礼物获取中")
- // #endif
- // #ifndef MP-WEIXIN
- this.$dialog.showLoading('礼物获取中')
- // #endif
- },
- async pointAuthClose() {
- this.hideLoading()
- await this.fetchGiftsData()
- this.show = true
- console.log(this.gitfs[this.selected].point);
- },
- async showVote(mobile, productId, activeId) {
- this.productId = productId
- this.activeId = activeId
- this.showLoading()
- let params = {
- mobile
- }
- let isCmcc = await this.checkIsCmcc()
- if (isCmcc) {
- const queryRes = (await this.$api.CMCC.queryCmccPoint(this.$u.queryParams(params)));
- if (queryRes.data.data.resultCode == '0001') {
- //去授权,保存作品id,方便跳转回来
- this.$cache.put('productId', this.productId)
- this.$refs.pointAuth.showAuth(queryRes.data.data.data);
- this.hideLoading()
- return;
- }
- const pointDetail = JSON.parse(queryRes.data.data.data);
- this.pointNum = pointDetail['points'];
- }
- await this.fetchGiftsData()
- this.hideLoading()
- this.show = true;
- },
- async checkIsCmcc() {
- if (this.$isEmpty(this.vuex_phone)) {
- return
- }
- let params = {
- phone: this.vuex_phone
- }
- // #ifdef MP-WEIXIN
- let res = await this.$api.CMCC.isCMCC(params)
- // #endif
- // #ifdef H5
- let res = await this.$api.CMCC.h5IsCMCC(params)
- // #endif
- console.log(res, "res....");
- return res.data.data
- },
- async fetchGiftsData() {
- let data = {
- activeId: this.activeId,
- productId: this.productId,
- userId: this.vuex_userId,
- }
- const res = await this.$api.activity.getGiftList(data);
- if(this.$isNotEmpty(res.data.data)){
- if(config.baseURL === 'http://vote-back.guosen-fumao.cn/api'){
- this.gitfs = [];
- //测试环境,过滤掉现金道具
- for(let i = 0; i < res.data.data.length; i++){
- if(res.data.data[i].payType === 'POINT_EXCHANGE_GOODS'){
- this.gitfs.push(res.data.data[i])
- }
- }
- }else{
- //正式环境,返回所有道具(包括现金道具)
- this.gitfs = res.data.data;
- }
- }else{
- this.$dialog.showModal('暂无助力道具',false,this.vuex_theme.bgColor)
- }
- },
- hideVote() {
- this.show = false;
- },
- toVote() {
- let item = this.gitfs[this.selected]
- if (this.pointNum == 0 && item.point != 0 && this.gitfs[this.selected].payType == 'POINT_EXCHANGE_GOODS') {
- this.$u.toast('您无可用移动积分')
- return
- }
- if (item.remainCount == 0) {
- uni.showToast({
- duration: 2300,
- title: "您今日的助力票数已用完,每天0点后恢复。请继续助力您喜爱的作品!",
- icon: "none"
- })
- return
- }
- this.$emit('toVote', this.gitfs[this.selected])
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .gift-item {
- width: 174rpx;
- height: 250rpx;
- margin: 12rpx;
- // box-shadow: 0rpx 2rpx 2rpx 2rpx #DDDDDD;
- // background: #007AFF;
- display: inline-block;
- .icon-box {
- width: 174rpx;
- height: 200rpx;
- border: 1rpx solid #DDDDDD;
- box-shadow: 3rpx 3rpx 4rpx rgba(26, 26, 26, 0.2);
- border-radius: 10rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- .gift-img {
- width: 100rpx;
- height: 100rpx;
- border: 1rpx dashed #DDDDDD;
- padding: 10rpx;
- transition: border 0.5s;
- border: 0 solid transparent;
- }
- .selected {
- border: 2rpx solid var(--bgColor);
- position: relative;
- }
- .selected::before {
- content: "";
- position: absolute;
- bottom: 0;
- right: -2rpx;
- border-radius: 10rpx 0 10rpx 0;
- height: 30rpx;
- width: 30rpx;
- background: url(../../static/icon/selected.png) no-repeat center/22rpx var(--bgColor);
- }
- .gift-name {
- font-size: 22rpx;
- color: #353535;
- padding-top: 10rpx;
- }
- }
- .handle-bar {
- position: absolute;
- width: 100%;
- bottom: 0;
- left: 0;
- padding-bottom: 80rpx;
- .button-bar {
- width: 80%;
- height: 80rpx;
- border: 2rpx solid var(--bgColor);
- margin: auto;
- border-radius: 100rpx;
- display: flex;
- .button-f {
- flex-basis: 50%;
- color: white;
- display: flex;
- font-size: 30rpx;
- justify-content: center;
- align-items: center;
- background: var(--bgColor);
- border-radius: 0 100rpx 100rpx 0;
- }
- .button-r {
- color: var(--bgColor);
- font-weight: 800;
- flex-basis: 50%;
- display: flex;
- font-size: 40rpx;
- justify-content: center;
- align-items: center;
- .info {
- color: #AAAAAA;
- font-weight: 500;
- margin-left: 15rpx;
- font-size: 22rpx;
- }
- }
- }
- }
- </style>
|