分享朋友圈调整
This commit is contained in:
@@ -10,9 +10,11 @@ Page({
|
||||
*/
|
||||
data: {
|
||||
barHeight : getApp().globalData.barHeight, // 状态栏高度
|
||||
shareSee : false, //分享弹出
|
||||
inviteText : '', //邀请码
|
||||
inviteCode : '', //二维码
|
||||
shareSee : false, // 分享弹出
|
||||
inviteText : '', // 邀请码
|
||||
inviteCode : '', // 二维码
|
||||
nickname : '', // 用户名称
|
||||
invite : '', // 邀请码
|
||||
//海报
|
||||
canvas : ''
|
||||
},
|
||||
@@ -38,6 +40,7 @@ Page({
|
||||
onShow() {
|
||||
// 小程序码
|
||||
this.ShareInfo();
|
||||
console.log(wx.getStorageSync("invite"))
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -47,12 +50,40 @@ Page({
|
||||
wx.$api.user.miniShare({
|
||||
url: 'pages/mall/index'
|
||||
}).then(res => {
|
||||
let { user_info, qrcode, invite } = res.data
|
||||
this.setData({
|
||||
inviteCode: res.data.qrcode
|
||||
invite : invite,
|
||||
inviteCode: qrcode,
|
||||
nickname : user_info.nickname
|
||||
})
|
||||
}).catch(err => {})
|
||||
},
|
||||
|
||||
/**
|
||||
* 检查授权信息
|
||||
*/
|
||||
onSetting(){
|
||||
wx.getSetting({
|
||||
success: res => {
|
||||
if(res.authSetting['scope.writePhotosAlbum'] || res.authSetting['scope.writePhotosAlbum'] === undefined){
|
||||
this.onCanvas()
|
||||
return
|
||||
}
|
||||
wx.showModal({
|
||||
title : '提示',
|
||||
content : '暂未授权小程序写入您的相册,无法存储海报',
|
||||
confirmColor: '#144592',
|
||||
confirmText : '去设置',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
wx.openSetting()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生成海报
|
||||
*/
|
||||
@@ -66,9 +97,8 @@ Page({
|
||||
const codeImgEl = canvas.createImage()
|
||||
const backBackEl = canvas.createImage()
|
||||
|
||||
// codeImgEl.src = this.data.inviteCode //二维码
|
||||
codeImgEl.src = '/static/imgs/userHead.png' //二维码
|
||||
backBackEl.src = 'https://cdn.douhuofalv.com/images/2023/08/11/cd8093d6ab1a248e5154be48b0ddcaac.jpg' //背景素材
|
||||
codeImgEl.src = this.data.inviteCode //二维码
|
||||
backBackEl.src = 'https://douhuo-storage.oss-cn-beijing.aliyuncs.com/images/2023/08/31/555d989b496e6d68ee8405bcae16555e.jpg' //背景素材
|
||||
const codeImgLoding = new Promise((resolve, reason) => {
|
||||
codeImgEl.onload = () => {
|
||||
resolve()
|
||||
@@ -83,21 +113,27 @@ Page({
|
||||
ctx.drawImage(backBackEl, 0, 0, 375, 800)
|
||||
// 绘制[二维码-白色背景]
|
||||
ctx.fillStyle = "#ffffff";
|
||||
ctx.fillRect(140, 610, 130, 130);
|
||||
ctx.fillRect(140, 570, 130, 130);
|
||||
|
||||
// 绘制[二维码-白色背景黑框]
|
||||
ctx.strokeStyle = "#da2b54";
|
||||
ctx.lineWidth = 2
|
||||
ctx.strokeRect(140, 610, 132, 132);
|
||||
ctx.strokeRect(140, 570, 132, 132);
|
||||
|
||||
// 绘制[二维码]
|
||||
ctx.drawImage(codeImgEl, 150, 620, 110, 110)
|
||||
ctx.drawImage(codeImgEl, 150, 580, 110, 110)
|
||||
|
||||
// 文字
|
||||
ctx.font = "bold 14px Arial"; //字体大小
|
||||
ctx.fillStyle = "#ffffff"; //字体颜色
|
||||
ctx.textAlign = "center"
|
||||
ctx.fillText('保存并分享二维码', 208, 770);
|
||||
ctx.fillText('保存并分享二维码', 208, 740);
|
||||
|
||||
// 用户昵称
|
||||
ctx.font = "bold 14px Arial"; //字体大小
|
||||
ctx.fillStyle = "#ffffff"; //字体颜色
|
||||
ctx.textAlign = "center"
|
||||
ctx.fillText(this.data.nickname, 208, 770);
|
||||
|
||||
wx.hideLoading()
|
||||
wx.canvasToTempFilePath({
|
||||
@@ -116,22 +152,12 @@ Page({
|
||||
},
|
||||
fail: () => {
|
||||
wx.hideLoading()
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '暂未授权小程序写入您的相册,无法存储海报',
|
||||
confirmColor: '#e50d01',
|
||||
confirmText: '去设置',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
wx.openSetting()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
}).catch(err => {
|
||||
wx.hideLoading()
|
||||
wx.showToast({
|
||||
title: '图片加载失败',
|
||||
icon : 'none'
|
||||
@@ -161,9 +187,9 @@ Page({
|
||||
shareSee: false
|
||||
})
|
||||
return {
|
||||
title : '水感应修复、紧致、舒缓喷雾',
|
||||
path : "/pages/index/index?invite=" + wx.getStorageSync("invite"),
|
||||
imageUrl: "https://cdn.shuiganying.com/images/2023/04/04/9cd9968136e7efd85028fba69e4c587a.jpg"
|
||||
title : '绚火健康,生命可以如此精彩~',
|
||||
path : "/pages/mall/index?invite=" + this.data.invite,
|
||||
imageUrl: "https://douhuo-storage.oss-cn-beijing.aliyuncs.com/images/2023/08/31/555d989b496e6d68ee8405bcae16555e.jpg"
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<!-- 二维码海报 -->
|
||||
<view class="code">
|
||||
<image src="https://cdn.douhuofalv.com/images/2023/08/11/cd8093d6ab1a248e5154be48b0ddcaac.jpg" class="code-back"></image>
|
||||
<image src="https://douhuo-storage.oss-cn-beijing.aliyuncs.com/images/2023/08/31/555d989b496e6d68ee8405bcae16555e.jpg" class="code-back"></image>
|
||||
<view class="code-cont">
|
||||
<view class="code-img">
|
||||
<image src="{{inviteCode}}" mode="widthFix"></image>
|
||||
@@ -30,7 +30,7 @@
|
||||
<image src="https://cdn.shuiganying.com/images/2023/03/28/f8b773edc2fe6db8e45f96773b9a8dc4.png"></image>
|
||||
微信好友
|
||||
</button>
|
||||
<view class="shareCont-label" bindtap="onCanvas">
|
||||
<view class="shareCont-label" bindtap="onSetting">
|
||||
<image src="https://cdn.shuiganying.com/images/2023/03/28/cfe0efbb53eaf7911ea5211923859c65.png"></image>
|
||||
保存二维码
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user