2023-05-15 10:12:22 +08:00
|
|
|
|
<template>
|
2023-05-24 15:56:32 +08:00
|
|
|
|
<view class="main-page">
|
|
|
|
|
<image :src="posterUrl" style="width:100%;height:100%;" mode="scaleToFill" v-show="posterUrl"></image>
|
|
|
|
|
<view class="spread-wrap" id="poster-wrap" v-show="!posterUrl">
|
|
|
|
|
<view class="logo-wrap">
|
|
|
|
|
<image :src="tenantInfo.logo" class="logo-image"></image>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="activity-wrap" v-show="activityList.length > 0">
|
|
|
|
|
<view class="item-wrap" :key="index" v-for="(item, index) in activityList">
|
|
|
|
|
<view class="text">办理会员{{item.gearAmount}}元</view>
|
|
|
|
|
<view class="text">可享一年返回<span>{{item.refundAmount}}元</span>话费</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="tips">
|
2023-05-24 19:01:59 +08:00
|
|
|
|
三个活动可同时参与,每个手机号仅限一次,最高可返<span>{{total}}元</span>话费!!!
|
2023-05-24 15:56:32 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view class="service-phone">{{tenantInfo.serviceMobile}}</view>
|
|
|
|
|
<view class="tenant-info-wrap">
|
|
|
|
|
<view class="info-wrap">
|
|
|
|
|
<view class="info">
|
|
|
|
|
<view class="name">{{userInfo.nickname}}</view>
|
|
|
|
|
<view class="phone">{{userInfo.mobile}}</view>
|
|
|
|
|
<view class="address">
|
|
|
|
|
{{userInfo.parentDeptName}}
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="qrcode-wrap">
|
|
|
|
|
<canvas id="qrcode" style="width:132rpx;height:132rpx;"></canvas>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<u-button class="logon" @click="downImage" v-show="!isHideBtn">生成海报</u-button>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2023-05-18 14:56:38 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2023-05-15 10:12:22 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2023-05-18 14:56:38 +08:00
|
|
|
|
import {
|
|
|
|
|
toLogin
|
|
|
|
|
} from '@/libs/login.js';
|
2023-05-24 15:56:32 +08:00
|
|
|
|
import {
|
|
|
|
|
memberGradeInfo
|
|
|
|
|
} from '@/api/member.js';
|
2023-05-18 14:56:38 +08:00
|
|
|
|
import {
|
|
|
|
|
mapGetters
|
|
|
|
|
} from "vuex";
|
2023-05-23 09:47:23 +08:00
|
|
|
|
import appConfig from '@/config/app.js'
|
2023-05-24 15:56:32 +08:00
|
|
|
|
import QRCode from 'qrcode'
|
|
|
|
|
import * as htmlToImage from 'html-to-image'
|
2023-05-18 14:56:38 +08:00
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2023-05-24 15:56:32 +08:00
|
|
|
|
activityList: [],
|
|
|
|
|
posterUrl: '',
|
|
|
|
|
isHideBtn: false
|
2023-05-18 14:56:38 +08:00
|
|
|
|
};
|
|
|
|
|
},
|
2023-05-24 19:01:59 +08:00
|
|
|
|
computed:{
|
|
|
|
|
...mapGetters(['isLogin', 'uid', 'userInfo', 'tenantId', 'tenantInfo']),
|
|
|
|
|
total: function(){
|
|
|
|
|
let _total = 0
|
|
|
|
|
for (let active of this.activityList) {
|
|
|
|
|
_total+= parseInt(active.refundAmount)
|
|
|
|
|
}
|
|
|
|
|
return _total
|
|
|
|
|
},
|
|
|
|
|
},
|
2023-05-18 14:56:38 +08:00
|
|
|
|
onLoad() {
|
2023-05-24 15:56:32 +08:00
|
|
|
|
if (!this.isLogin) {
|
|
|
|
|
toLogin()
|
2023-05-18 14:56:38 +08:00
|
|
|
|
} else {
|
2023-05-24 15:56:32 +08:00
|
|
|
|
this.getActivityInfo()
|
2023-05-18 14:56:38 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onReady() {},
|
|
|
|
|
methods: {
|
2023-05-24 16:54:06 +08:00
|
|
|
|
async downImage() {
|
2023-05-24 15:56:32 +08:00
|
|
|
|
const that = this
|
2023-05-18 14:56:38 +08:00
|
|
|
|
uni.showLoading({
|
2023-05-24 15:56:32 +08:00
|
|
|
|
title: '生成海报中',
|
2023-05-18 14:56:38 +08:00
|
|
|
|
mask: true
|
|
|
|
|
});
|
2023-05-24 15:56:32 +08:00
|
|
|
|
that.isHideBtn = true
|
2023-05-29 18:29:13 +08:00
|
|
|
|
for(let i = 0; i<2; i++){
|
2023-05-24 16:54:06 +08:00
|
|
|
|
await htmlToImage.toPng(document.getElementById('poster-wrap'), {
|
|
|
|
|
quality: 0.95,
|
|
|
|
|
cacheBust: true
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
htmlToImage.toPng(document.getElementById('poster-wrap'), {
|
2023-05-24 15:56:32 +08:00
|
|
|
|
quality: 0.95,
|
|
|
|
|
cacheBust: true
|
2023-05-18 14:56:38 +08:00
|
|
|
|
})
|
2023-05-24 15:56:32 +08:00
|
|
|
|
.then(function(dataUrl) {
|
|
|
|
|
console.log('dataUrl', dataUrl)
|
|
|
|
|
uni.hideLoading()
|
|
|
|
|
that.posterUrl = dataUrl
|
|
|
|
|
that.$util.Tips({
|
|
|
|
|
title: '生成成功,长按保存图片'
|
|
|
|
|
})
|
2023-05-25 11:23:31 +08:00
|
|
|
|
}).catch(()=>{
|
|
|
|
|
that.$util.Tips({
|
|
|
|
|
title: '生成失败'
|
|
|
|
|
})
|
|
|
|
|
that.isHideBtn = false
|
|
|
|
|
})
|
2023-05-18 14:56:38 +08:00
|
|
|
|
},
|
|
|
|
|
// 生成二维码;
|
|
|
|
|
make() {
|
|
|
|
|
let that = this;
|
2023-05-24 15:56:32 +08:00
|
|
|
|
const url =
|
|
|
|
|
`${appConfig.SPREAD_DOMAIN}${appConfig.SPREAD_LINK}?redirectUrl=${appConfig.SPREAD_DOMAIN}&tenantId=${that.tenantId}&spreadId=${that.uid}`
|
2023-05-19 17:34:57 +08:00
|
|
|
|
console.log('url', url)
|
2023-05-24 15:56:32 +08:00
|
|
|
|
QRCode.toCanvas(document.getElementById('qrcode').querySelector('canvas'), url, {
|
|
|
|
|
scale: 1.5
|
|
|
|
|
}, function(error) {
|
|
|
|
|
console.log(error)
|
2023-05-18 14:56:38 +08:00
|
|
|
|
})
|
|
|
|
|
},
|
2023-05-24 15:56:32 +08:00
|
|
|
|
// 获取活动套餐信息
|
|
|
|
|
async getActivityInfo() {
|
|
|
|
|
try {
|
|
|
|
|
uni.showLoading({
|
|
|
|
|
title: '加载中',
|
|
|
|
|
mask: true
|
|
|
|
|
});
|
|
|
|
|
const res = await memberGradeInfo()
|
|
|
|
|
this.activityList = res.data
|
|
|
|
|
// 生成二维码
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.make()
|
|
|
|
|
}, 500)
|
|
|
|
|
} catch (e) {
|
|
|
|
|
this.$util.Tips({
|
|
|
|
|
title: '获取活动信息失败'
|
|
|
|
|
})
|
|
|
|
|
} finally {
|
|
|
|
|
uni.hideLoading()
|
2023-05-18 14:56:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-15 10:12:22 +08:00
|
|
|
|
</script>
|
|
|
|
|
<style lang="scss" scoped>
|
2023-05-18 14:56:38 +08:00
|
|
|
|
page {
|
2023-05-24 15:56:32 +08:00
|
|
|
|
background-color: #F8EEEF !important;
|
|
|
|
|
height: 100vh;
|
|
|
|
|
overflow: auto;
|
2023-05-18 14:56:38 +08:00
|
|
|
|
}
|
2023-05-15 10:12:22 +08:00
|
|
|
|
|
2023-05-24 15:56:32 +08:00
|
|
|
|
.main-page{
|
2023-05-18 14:56:38 +08:00
|
|
|
|
height: 100%;
|
2023-05-24 15:56:32 +08:00
|
|
|
|
overflow: auto;
|
2023-05-18 14:56:38 +08:00
|
|
|
|
}
|
2023-05-15 10:12:22 +08:00
|
|
|
|
|
2023-05-24 15:56:32 +08:00
|
|
|
|
.spread-wrap {
|
|
|
|
|
height: 100%;
|
|
|
|
|
background: url('@/static/images/spread_bg.png') center 0 no-repeat;
|
|
|
|
|
background-size: 100% auto;
|
2023-05-18 14:56:38 +08:00
|
|
|
|
position: relative;
|
2023-05-24 15:56:32 +08:00
|
|
|
|
background-color: #F8EEEF;
|
2023-05-18 14:56:38 +08:00
|
|
|
|
}
|
2023-05-15 10:12:22 +08:00
|
|
|
|
|
2023-05-24 15:56:32 +08:00
|
|
|
|
.logo-wrap {
|
|
|
|
|
text-align: center;
|
|
|
|
|
padding-top: 53rpx;
|
2023-05-15 10:12:22 +08:00
|
|
|
|
|
2023-05-24 15:56:32 +08:00
|
|
|
|
.logo-image {
|
|
|
|
|
width: 160rpx;
|
|
|
|
|
height: 141rpx;
|
|
|
|
|
}
|
2023-05-18 14:56:38 +08:00
|
|
|
|
}
|
2023-05-15 10:12:22 +08:00
|
|
|
|
|
2023-05-24 15:56:32 +08:00
|
|
|
|
.activity-wrap {
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 460rpx;
|
|
|
|
|
left: 104rpx;
|
|
|
|
|
right: 110rpx;
|
|
|
|
|
|
|
|
|
|
.tenant-info-wrap {
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: 0;
|
|
|
|
|
right: 0;
|
|
|
|
|
top: 656rpx;
|
|
|
|
|
|
|
|
|
|
.info-wrap {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
}
|
2023-05-15 10:12:22 +08:00
|
|
|
|
|
2023-05-24 15:56:32 +08:00
|
|
|
|
.qrcode-wrap {
|
|
|
|
|
margin-left: 40rpx;
|
|
|
|
|
}
|
2023-05-15 10:12:22 +08:00
|
|
|
|
|
2023-05-24 15:56:32 +08:00
|
|
|
|
.address {
|
|
|
|
|
margin-top: 18rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.logon {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 70rpx;
|
|
|
|
|
margin: 30rpx 0;
|
|
|
|
|
color: #FFFFFF;
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
background: linear-gradient(0deg, #E63163 0%, #FF819F 100%);
|
|
|
|
|
border-radius: 44rpx;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-15 10:12:22 +08:00
|
|
|
|
|
2023-05-24 15:56:32 +08:00
|
|
|
|
.service-phone {
|
|
|
|
|
position: absolute;
|
|
|
|
|
bottom: -114rpx;
|
|
|
|
|
right: 48rpx;
|
|
|
|
|
font-size: 30rpx;
|
|
|
|
|
color: #ED387C;
|
|
|
|
|
font-style: italic;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.tips {
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
color: #000;
|
2023-05-24 16:03:59 +08:00
|
|
|
|
span{
|
|
|
|
|
color: #C80D00;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
}
|
2023-05-24 15:56:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.item-wrap {
|
|
|
|
|
font-size: 26rpx;
|
|
|
|
|
font-style: italic;
|
|
|
|
|
color: #010101;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
margin-bottom: 54rpx;
|
|
|
|
|
padding-left: 227rpx;
|
|
|
|
|
|
|
|
|
|
.text span {
|
|
|
|
|
color: #C80D00;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-18 14:56:38 +08:00
|
|
|
|
}
|
2023-05-15 10:12:22 +08:00
|
|
|
|
|
2023-05-24 15:56:32 +08:00
|
|
|
|
.canvas {
|
|
|
|
|
position: relative;
|
2023-05-18 14:56:38 +08:00
|
|
|
|
}
|
2023-05-15 10:12:22 +08:00
|
|
|
|
</style>
|