Commit 28a782b7 authored by Mac's avatar Mac

1

parent 281edbf5
......@@ -599,6 +599,8 @@
"path":"userList"//用户列表
},{
"path":"editData"//编辑资料
},{
"path":"xqposter"//相亲分享海报
}]
},
//韩国馆项目 { "root": "pages/kotra", "pages": [{ "path": "contanctus" },{ "path": "contanctDetail" },{ "path": "compInformation" },{
......
......@@ -321,6 +321,7 @@
</view>
<view class="details">
<view class="details-title"><text v-if="details.Label!=null&& details.Label!='' " :style="{color:mainColor}">【{{details.Label}}</text>{{details.ActivityTitle}}</view>
<view @click="fxshow=true">分享</view>
<view class="details-info">
<view class="details-info-l">
<view style="width: 35px;height: 35px;border-radius: 50%;position: relative;" @click.native.stop="goUserinfo(details)">
......@@ -572,6 +573,25 @@
</view>
</view>
</u-popup>
<u-popup v-model="fxshow" mode="bottom" border-radius='14'>
<view class="popup-box">
<view style="width: 100%;display: flex;align-items: center;justify-content: space-around;padding: 20px 15px;">
<view style="display: flex;flex-direction: column;align-items: center;font-size: 12px;color: #666666;position: relative;">
<image src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Upload/Goods/1616749584000_898.png" style="width: 40px;height: 40px;"></image>
<text style="margin-top: 8px;">微信</text>
<button style="width: 100%;height: 100%;position: absolute;left: 0;top: 0;opacity: 0;" open-type="share"></button>
</view>
<view style="display: flex;flex-direction: column;align-items: center;font-size: 12px;color: #666666;" @click="goposter()">
<image src="https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Upload/Goods/1616749674000_539.png" style="width: 40px;height: 40px;"></image>
<text style="margin-top: 8px;">生成海报</text>
</view>
</view>
<view style="width: 100%;height: 10px;background: #E7E7E7;"></view>
<view class="popup-box-item" @click="fxshow=false" style="height: 45px;">
取消
</view>
</view>
</u-popup>
<auth v-if="showAuth" @changeuserinfo="reloadUserinfo" @gbAuth= 'gbAuth'></auth>
</view>
</template>
......@@ -587,6 +607,7 @@
pageTitle: "活动详情",
mainColor: "",
showAuth:false,
fxshow:false,
msg:{
pageIndex:1,
pageSize:20,
......@@ -652,6 +673,10 @@
uni.setNavigationBarTitle({
title: this.pageTitle,
});
wx.showShareMenu({
withShareTicket: true,
menus: ["shareAppMessage", "shareTimeline"],
});
},
onLoad(options) {
console.log(options)
......@@ -664,6 +689,54 @@
this.sendMsg.ReplyUserId = UserId
this.UserId = UserId
},
onShareTimeline() {
setTimeout(() => {
console.log("分享朋友圈调用");
this.getReceive();
}, 2500);
let uid = uni.getStorageSync("mall_UserInfo")
? uni.getStorageSync("mall_UserInfo").UserId
: 0;
if(uid==0){
uid = uni.getStorageSync("pid")?uni.getStorageSync("pid").pid:0
}
let SmallShopId = uni.getStorageSync("mall_UserInfo")
? uni.getStorageSync("mall_UserInfo").SmallShopId
: 0;
if(SmallShopId == 0){//如果微店id为0 去找所属微店id
SmallShopId = uni.getStorageSync("mall_UserInfo")
? uni.getStorageSync("mall_UserInfo").UserSmallShopId
: 0;
}
let title =this.details.ActivityTitle?this.details.ActivityTitle:'帖子';
let imageUrl =this.details.ImageList && this.details.ImageList.length>0?this.details.ImageList[0]:'';
let id = this.msg.ActivityId;
return {
title: title,
query: "id=" + this.id + "&user_id=" + uid+ "&SmallShopId=" + SmallShopId+ "&Up=" + this.Up,
imageUrl: imageUrl,
};
},
onShareAppMessage(res) {
setTimeout(() => {
console.log("分享好友调用");
this.getReceive();
}, 2500);
let u = uni.getStorageSync("mall_UserInfo");
let uid = u.UserId ? u.UserId : 0;
if(uid==0){
uid = uni.getStorageSync("pid")?uni.getStorageSync("pid").pid:0
}
let SmallShopId = u.SmallShopId ? u.SmallShopId : 0;
if(SmallShopId == 0){//如果微店id为0 去找所属微店id
SmallShopId = u.UserSmallShopId? u.UserSmallShopId:0
}
return {
title:this.details.ActivityTitle?this.details.ActivityTitle:'帖子',
path: "/pages/index/index?id=" + this.msg.ActivityId + "&user_id=" + uid+ "&SmallShopId=" + SmallShopId+ "&Up=" + this.Up+'&JumpType=10',
imageUrl:this.details.ImageList && this.details.ImageList.length>0?this.details.ImageList[0]:'',
};
},
methods:{
getActivityInfo(){
......@@ -1056,7 +1129,7 @@
uni.navigateTo({
url: '/pages/blindDate/persondetails?UserId='+ x.UserId
});
innerAudioContext.stop();
},
goopenlocation(x){
uni.openLocation({
......@@ -1069,6 +1142,11 @@
console.log(err)
}
});
},
goposter(){
uni.navigateTo({
url: '/pages/blindDate/xqposter?cover='+this.details.ImageList[0]+'&title='+this.details.ActivityTitle
});
}
}
}
......
<template>
<view class="qrcodeStyle" :style="{'height':contentHeight}">
<u-top-tips ref="uTips"></u-top-tips>
<img :src="tempPic" mode="widthFix" style="width: 320px;margin-top: 20px;" />
<canvas canvas-id="firstCanvas" class="sty-box" @error="canvasIdErrorCallback"></canvas>
<view class="btn" :style="{background:mainColor}" @click="preservation">
<Text>保存图片分享赚钱</Text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
pageTitle: "推广二维码",
contentHeight: 0,
mainColor: '',
qrcode: '',
fenxqrcode: '',
UserInfo: '',
tempPic: '',
cover: '',
}
},
created() {
this.contentHeight = this.$utils.calcContentHeight(-40) + 'px';
this.mainColor = this.$uiConfig.mainColor;
this.secondary = this.$uiConfig.secondary;
this.UserInfo = uni.getStorageSync('mall_UserInfo') ? uni.getStorageSync('mall_UserInfo') : {}
},
onLoad(options) {
console.log(options, 'options')
if (options ) {
this.cover = options.cover
this.title = options.title
this.init()
}
uni.setNavigationBarTitle({
title: this.pageTitle,
});
},
onReady() {
},
mounted() {
},
methods: {
init() {
uni.showNavigationBarLoading();
this.request2({
url: '/api/AppletUser/GetFenXiaoPoster',
data: {
IsOpenSchool: 2
}
},
(res) => {
uni.hideNavigationBarLoading()
this.qrcode = res.data;
this.getWeiXinQRCode()
}
);
},
getWeiXinQRCode() {
let that = this
uni.showNavigationBarLoading();
let SmallShopId = that.UserInfo.SmallShopId ? that.UserInfo.SmallShopId : 0;
if (SmallShopId == 0) {
SmallShopId = that.UserInfo.UserSmallShopId ? that.UserInfo.UserSmallShopId : 0;
}
that.request2({
url: '/api/AppletUser/GetWeiXinQRCodeForApplet',
data: {
Path: '/pages/index/index?user_id=' + that.UserInfo.UserId + '&SmallShopId=' + SmallShopId,
With: that.qrcode.QrCodeSize,
}
},
(res) => {
uni.hideNavigationBarLoading()
that.fenxqrcode = that.host2 + res.data;
console.log(that.fenxqrcode)
let tmpTimeout = setTimeout(() => {
that.drawCtx();
clearTimeout(tmpTimeout)
}, 100)
}
);
},
drawCtx() {
uni.showLoading({
title: "正在生成",
});
let ctx = uni.createCanvasContext("firstCanvas", this);
let that = this;
uni.getImageInfo({
src: that.qrcode.PosterBgImg,
success: function(image) {
console.log('绘制')
ctx.drawImage(image.path, 0, 0, 750, 1344); //绘制图
if (that.qrcode.IsShowNick == 0) {
console.log('绘制文字')
that.drawTitle(ctx); //绘制文字
}
if (that.qrcode.IsShowHead == 0) {
console.log('绘制头像')
uni.getImageInfo({ //头像
src: that.UserInfo.Photo,
success: function(image) {
ctx.save(); // 先保存状态 已便于画完圆再用
ctx.beginPath(); //开始绘制
//先画个圆
ctx.arc(that.qrcode.HeadSize / 2 + that.qrcode.HeadPaddingLeft, that.qrcode.HeadSize / 2 + that.qrcode.HeadPaddingTop,
that.qrcode.HeadSize / 2, 0, Math.PI * 2, false);
ctx.clip(); //画了圆 再剪切 原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内
ctx.drawImage(image.path, that.qrcode.HeadPaddingLeft, that.qrcode.HeadPaddingTop, that.qrcode.HeadSize,
that.qrcode.HeadSize); //绘制头像
ctx.restore(); //恢复之前保存的绘图上下文 恢复之前保存的绘图上下午即状态 可以继续绘制
// if (that.qrcode.IsShowQrCode == 0) { //二维码
// console.log('绘制二维码')
// uni.getImageInfo({
// // src: that.UserInfo.Photo,
// src: that.fenxqrcode,
// success: function(image) {
// if (that.qrcode.QrCodeType == 0) {
// ctx.arc(that.qrcode.QrCodeSize / 2 + that.qrcode.QrCodePaddingLeft, that.qrcode.QrCodeSize / 2 +
// that.qrcode.QrCodePaddingTop, that.qrcode.QrCodeSize / 2, 0, Math.PI * 2, false);
// ctx.clip(); //画了圆 再剪切 原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内
// }
// ctx.drawImage(image.path, that.qrcode.QrCodePaddingLeft, that.qrcode.QrCodePaddingTop, that.qrcode
// .QrCodeSize, that.qrcode.QrCodeSize); //绘制二维码
// that.drawQrCode(ctx)
// },
// });
// } else {
// that.drawQrCode(ctx)
// }
},
});
} else {
if (that.qrcode.IsShowQrCode == 0) {
console.log('绘制二维码')
uni.getImageInfo({ //头像
src: that.fenxqrcode,
success: function(image) {
if (that.qrcode.QrCodeType == 0) {
ctx.arc(that.qrcode.QrCodeSize / 2 + that.qrcode.QrCodePaddingLeft, that.qrcode.QrCodeSize / 2 + that.qrcode
.QrCodePaddingTop, that.qrcode.QrCodeSize / 2, 0, Math.PI * 2, false);
ctx.clip(); //画了圆 再剪切 原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内
}
ctx.drawImage(image.path, that.qrcode.QrCodePaddingLeft, that.qrcode.QrCodePaddingTop, that.qrcode.QrCodeSize,
that.qrcode.QrCodeSize); //绘制二维码
that.drawQrCode(ctx)
},
});
} else {
that.drawQrCode(ctx)
}
}
},
});
},
drawTitle(ctx) {
let that = this
let text = that.UserInfo.Name;
ctx.setFillStyle = that.qrcode.NickColor;
ctx.setFontSize(that.qrcode.NickSize)
ctx.fillText(text, that.qrcode.NickPaddingLeft, that.qrcode.NickPaddingTop);
ctx.restore();
},
drawQrCode(ctx) {
let that = this;
console.log('生成海报12')
setTimeout(() => {
ctx.draw(false, () => {
uni.canvasToTempFilePath({
x: 0,
y: 0,
width: 750,
height: 1344,
destWidth: 750.0,
destHeight: 1344.0,
canvasId: "firstCanvas",
success: (res) => {
uni.hideLoading();
that.tempPic = res.tempFilePath;
},
fail(e) {
console.log(e);
},
},
that
);
});
}, 200)
},
preservation() {
uni.showLoading({
title: "正在生成",
});
let that = this;
uni.canvasToTempFilePath({
canvasId: "firstCanvas",
success: (res) => {
uni.hideLoading();
uni.showLoading({
title: "正在保存",
});
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: function() {
uni.showToast({
title: "保存成功",
});
},
fail: function(err) {
if (err.errMsg === "saveImageToPhotosAlbum:fail auth deny") {
uni.authorize({
scope: 'scope.writePhotosAlbum',
success: (res) => {
console.log('11111');
},
fail: (res) => {
uni.showModal({
content: '检测到您没打开保存到相册权限,是否去设置打开?',
confirmText: "确认",
cancelText: '取消',
success: (res) => {
if (res.confirm) {
uni.openSetting({
success: (res) => {
console.log(res);
if (res.authSetting['scope.writePhotosAlbum']) {
that.preservation()
}
}
})
} else {
console.log('取消');
}
}
})
}
})
} else {
that.$refs.uTips.show({
title: "保存失败,请稍后重试",
type: "error",
duration: "2300",
});
}
},
complete: function() {
uni.hideLoading();
},
});
},
fail: function(e) {
console.log(e);
that.$refs.uTips.show({
title: "生成失败,请稍后重试",
type: "error",
duration: "2300",
});
},
},
this
);
}
}
}
</script>
<style>
.qrcodeStyle {
background: #f3f4f6;
display: flex;
flex-direction: column;
align-items: center;
}
.qrcodeStyle .btn {
width: 80%;
height: 50px;
border-radius: 25px;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
margin: 20px;
}
.qrcodeStyle .imgbox {
width: 70%;
height: 515px;
margin-left: 15%;
position: relative;
background-repeat: no-repeat;
background-size: 100% 515px;
}
.qrcodeStyle .sty-box {
width: 750px;
height: 1344px;
position: absolute;
top: -1344px;
left: -750px;
}
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment