8.6(邀请二维码

This commit is contained in:
Hong
2024-08-06 14:47:21 +08:00
parent fcb47bc7b8
commit 8c9e7910d1
3 changed files with 83 additions and 50 deletions

View File

@@ -35,35 +35,35 @@
<!-- 分享 -->
<view class="share-type flex justify-around">
<!-- #ifdef MP-WEIXIN -->
<view class="share-type-cont" style="position:relative;">
<image :src="`${config.aliyunOssUrl}/static/images/app/config/weixin.png`" mode=""></image>
<view>微信好友</view>
<button id="shareBtn" open-type="share" @click="shareBtnInfo(1)"></button>
</view>
<!-- @click="shareBtnInfo" -->
<view class="share-type-cont" style="position:relative;" @click="shareBtnInfo(2)">
<image :src="`${config.aliyunOssUrl}/static/images/app/config/pengyouquan.png`" mode=""></image>
<view>朋友圈</view>
<!-- <button id="shareBtn" open-type="share" @click="shareBtnInfo(2)"></button> -->
</view>
<view class="share-type-cont" @click="savePoster">
<image :src="`${config.aliyunOssUrl}/static/images/app/config/save.png`" mode=""></image>
<view>保存海报</view>
</view>
<view class="share-type-cont" style="position:relative;">
<image :src="`${config.aliyunOssUrl}/static/images/app/config/weixin.png`" mode=""></image>
<view>微信好友</view>
<button id="shareBtn" open-type="share" @click="shareBtnInfo(1)"></button>
</view>
<!-- @click="shareBtnInfo" -->
<view class="share-type-cont" style="position:relative;" @click="shareBtnInfo(2)">
<image :src="`${config.aliyunOssUrl}/static/images/app/config/pengyouquan.png`" mode=""></image>
<view>朋友圈</view>
<!-- <button id="shareBtn" open-type="share" @click="shareBtnInfo(2)"></button> -->
</view>
<view class="share-type-cont" @click="savePoster">
<image :src="`${config.aliyunOssUrl}/static/images/app/config/save.png`" mode=""></image>
<view>保存海报</view>
</view>
<!-- #endif -->
<!-- #ifdef APP -->
<view class="share-type-cont" @click="shareFn('WXSceneSession')">
<image src="@/static/images/app/config/weixin.png" mode=""></image>
<view>微信好友</view>
</view>
<view class="share-type-cont" @click="shareFn('WXSceneTimeline')">
<image src="@/static/images/app/config/pengyouquan.png" mode=""></image>
<view>朋友圈</view>
</view>
<view class="share-type-cont" @click="savePoster">
<image src="@/static/images/app/config/save.png" mode=""></image>
<view>保存海报</view>
</view>
<view class="share-type-cont" @click="shareFn('WXSceneSession')">
<image src="@/static/images/app/config/weixin.png" mode=""></image>
<view>微信好友</view>
</view>
<view class="share-type-cont" @click="shareFn('WXSceneTimeline')">
<image src="@/static/images/app/config/pengyouquan.png" mode=""></image>
<view>朋友圈</view>
</view>
<view class="share-type-cont" @click="savePoster">
<image src="@/static/images/app/config/save.png" mode=""></image>
<view>保存海报</view>
</view>
<!-- #endif -->
</view>
<!-- 画布 -->
@@ -72,6 +72,9 @@
</template>
<script>
import {
urlToBase64
} from "@/utils/index.js"
import {
getInviteInfo
} from "@/api/welfare/welfare.js"
@@ -96,22 +99,22 @@
// 来自页面内分享按钮
}
return {
title:'海报', //分享的名称
title: '海报', //分享的名称
path: '/pages/index/index',
imageUrl: this.imageBg,
};
},
onShareTimeline(res){
onShareTimeline(res) {
return {
title:'海报',
title: '海报',
path: '/pages/index/index',
imageUrl: this.imageBg,
// channel:''
};
},
methods: {
shareBtnInfo(num){
if(num==2){
shareBtnInfo(num) {
if (num == 2) {
uni.showToast({
title: '请点击右上角胶囊中的三个点进行朋友圈分享',
duration: 3000,
@@ -121,7 +124,7 @@
},
//分享
shareFn(type) {
this.drawPoster(this.imageBg, false,type)
this.drawPoster(this.imageBg, false, type)
},
// 轮播图切换
@@ -222,30 +225,37 @@
// console.log(res, '海报');
this.userInfo = res.data
this.imageBg = this.userInfo.posterList[0].image
let url =`https://cms.diyouzhijia.com/car_h5/#/pages/index?uId=${this.userInfo.id}`
// let base64Data = uni.arrayBufferToBase64([url])
this.verificationImage =
`https://wxapp.nianxiang-tech.com/prod-api/ums/login/qrcode?content=${url}`
let url = `https://cms.diyouzhijia.com/car_h5/#/pages/index?uId=${this.userInfo.id}`
// const encodedUrl = encodeURIComponent(url);
// console.log(unescape(encodeURIComponent(url)));
// const base64 = uni.arrayBufferToBase64(encodedUrl);
// this.verificationImage =
// `https://wxapp.nianxiang-tech.com/prod-api/ums/login/qrcode/base64?content=${base64Data}`
// console.log(`https://wxapp.nianxiang-tech.com/prod-api/ums/login/qrcode?content=${url}`);
// `https://wxapp.nianxiang-tech.com/prod-api/ums/login/qrcode/base64?content=${base64}`
// console.log(this.verificationImage);
let base64Data = urlToBase64(url)
this.verificationImage =
`https://wxapp.nianxiang-tech.com/prod-api/ums/login/qrcode/base64?content=${base64Data}`
console.log('base', this.verificationImage); // 打印出Base64字符串
})
}
}
</script>
<style lang="scss">
#shareBtn {
// border: 1px solid ;
position: absolute;
top: 0;
z-index: 2;
opacity:0;
width: 100%;
height: 100%;
// border: 1px solid ;
position: absolute;
top: 0;
z-index: 2;
opacity: 0;
width: 100%;
height: 100%;
}
page {
background: linear-gradient(180deg, #98C2E1 0%, rgba(255, 255, 255, 0) 100%);
}
@@ -297,6 +307,7 @@
height: 1126rpx;
background: #fff;
border-radius: 8rpx;
image {
width: 100%;
height: 100%;

View File

@@ -296,4 +296,26 @@ export const getTimeDifference = (time) => {
} else if (diffInSeconds > 0) {
return diffInSeconds + "秒前";
}
}
}
//传入url 返回base64格式
export const urlToBase64 = (str) => {
let CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
let out = '', i = 0, len = str.length, c1, c2, c3, enc1, enc2, enc3, enc4;
while (i < len) {
c1 = str.charCodeAt(i++);
c2 = str.charCodeAt(i++);
c3 = str.charCodeAt(i++);
enc1 = c1 >> 2;
enc2 = ((c1 & 3) << 4) | (c2 >> 4);
enc3 = ((c2 & 15) << 2) | (c3 >> 6);
enc4 = c3 & 63;
if (isNaN(c2)) {
enc3 = enc4 = 64;
} else if (isNaN(c3)) {
enc4 = 64;
}
out += CHARS.charAt(enc1) + CHARS.charAt(enc2) + CHARS.charAt(enc3) + CHARS.charAt(enc4);
}
return out;
}

View File

@@ -41,7 +41,7 @@ const request = config => {
}
const code = res.data.code || 200
const msg = errorCode[code] || res.data.message || res.data.msg || errorCode['default']
if (code === 401 || code === 402) {
if (code === 401 || code === 402|| code === 301) {
showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
if (res.confirm) {
// store.dispatch('LogOut').then(res => {