hengmei-one/pagesB/personalPoster/personalPoster.vue

135 lines
4.0 KiB
Vue

<template>
<view>
<!-- 状态栏 -->
<status-nav :titleVal="'二维码海报'" :statusTitle="true"></status-nav>
<!-- 自定义二级分类 -->
<!-- 列表 -->
<view :style="{paddingTop: statusHNH+'px'}" class="pad-zy36 pad-x20">
<view v-show="imgSrc!=''">
<view class="mar-s20">
<image class="width100 radius20" :src="imgSrc" mode="widthFix" lazy-load></image>
</view>
<!-- 分享按钮 -->
<view v-if="showBtn" @tap="shareEv" class="disjcac radius20 posir" style="height: 90rpx;margin: 20rpx 80rpx 0 80rpx;background-color: #38CE51;line-height: 90rpx;">
<view class="disac">
<image src="/static/public/sharef.png" style="width: 54rpx;height: 54rpx;" mode=""></image>
<view class="fon40 bold colf mar-z10">分享给好友</view>
</view>
</view>
</view>
<view v-show="imgSrc==''" class="disjcac fc" style="margin-top: 50%;">
<image class="zanw-img mar-x50" src="/static/public/zanwn.png" mode="aspectFill"></image>
<view class="fon24 col3 mar-s50" style="margin-top: 30%;">暂无内容</view>
</view>
</view>
<!-- 弹框 -->
<pu-po :isShowT="imgSrc==''" :contentVal="'立即生成创意海报'" :clearVal="'暂不生成'" :comfrimVal="'立即生成'" @comfirmev="comfirmev" @cancleev="cancleev"></pu-po>
<!-- 底部客服 -->
<public-customer :nbottom="100"></public-customer>
<!-- 弹框授权 -->
<empower @buttonH="buttonH" :vision="vision" :isWhere="2"></empower>
<!-- -->
<auth-phone v-if="isShowP"></auth-phone>
</view>
</template>
<script>
import {base64ToPath} from '@/jsFile/base64-src.js';
export default {
data() {
return {
statusHNH:uni.getStorageSync('statusHNH'),
publicColor:uni.getStorageSync('publicColor'),//主题颜色
isShowT:true,
imgSrc:uni.getStorageSync('imgSrcP'),
isHaib:false,
showBtn:false,
vision:false,
isShowP:false,
}
},
onShow() {
this.$toolAll.tools.isLogin()
},
onLoad(options) {
if(uni.getStorageSync('is_active')!=1){this.vision = true;}
if(options.invite_code!='' && options.invite_code!=undefined){
this.loginEv(options.invite_code);
} else if(options.source_code!='' && options.source_code!=undefined){
this.loginEv('',options.source_code,options.channel);
}
//如果还没有生成海报
this.imgSrc = uni.getStorageSync('imgSrcP')//弹框关闭
if(this.imgSrc!='') {
setTimeout(()=>{
this.showBtn = true
},500)
}
},
methods: {
loginEv(invite_code='',source='',channel=''){
uni.login({
provider: 'weixin',
success: (res)=> {
if (res.code) {
var params = {
code:res.code,
invite_code:invite_code,//用户邀请码
source_code:source,
channel:channel
}
this.$requst.post('user/login',params).then(res => {
if(res.data.token!=''){
if(res.data.is_active==0) {
this.vision = true;
}
}
},error => {})
}
},
});
},
buttonH(e){//授权成功
if(e) {
this.vision = false
this.isShowP = true
}
},
shareEv(){
wx.showShareImageMenu({
path: this.imgSrc
})
this.$requst.post('user/record',{type:'other',action:'share',id:''}).then(res=>{console.log('分享成功:',res);},error=>{})
let maiOjb = {
e:4,//内容分享
t:new Date().getTime()//当前时间戳
}
this.$toolAll.tools.maiDian(maiOjb)
},
comfirmev(){//立即生成事件
this.$toolAll.tools.showToast('生成中...')
this.isShowT = false
this.$requst.get('user/personal-poster').then(res=>{
// console.log('生成个人海报成功:',res);
if(res.code==0){
this.imgSrc = res.data.poster
uni.hideToast()
this.$toolAll.tools.showToast('生成海报成功')
base64ToPath(this.imgSrc).then(path => {
this.imgSrc = path
this.showBtn = true
uni.setStorageSync('imgSrcP',path)
}).catch(error => {})
}
},error=>{})
},
cancleev(){//暂不生成事件
uni.navigateBack({delta:1})
}
}
}
</script>
<style>
</style>