刘翔宇-旅管家 3 years ago
parent 17485aa785
commit 2efcb58396

@ -417,6 +417,7 @@
this.form.hospital = this.arrHospital[e.target.value];
}
},
getPoster: function() {
var that = this;
uni.getImageInfo({

@ -224,20 +224,70 @@
<view class="bottom-btn">
<u-button :custom-style="btnStyle" style="width: 90%;" @click="showQR=true" shape="circle">联系优孕月子福利官</u-button>
</view>
<view class="footer">
<view class="menuLink">
<navigator url="../../../../pages/home/home" open-type="switchTab">
<view class="menuCol">
<text class="iconfont icon-home"></text>
<text>首页</text>
</view>
</navigator>
<view class="menuCol" @click="shareOpen">
<text class="iconfont icon-Share"></text>
<text>分享</text>
</view>
</view>
<view class="buyBtn" @click="showQR=true" >联系优孕月子福利官</view>
</view>
</view>
<u-skeleton :loading="loading" :animation="true" bgColor="#FFF"></u-skeleton>
<u-skeleton :loading="loading" :animation="true" bgColor="#FFF"></u-skeleton>
<uni-popup ref="shareCode" :mask-click="true" type="bottom" class="shareBox">
<view class="codeOuter">
<view class="shareCon" @click="shareClose">
<canvas style="width:80%;margin-left:10%;position: absolute;"
:style="{ height:(shareHeight*scare) + 'px', marginTop:(cropperH-(shareHeight*scare))/2+'rpx'}"
canvas-id="firstCanvas" id="firstCanvas"></canvas>
<!-- <image class="shareBg" mode="widthFix" src="../../static/bg_haibao@2x.png"></image> -->
<!-- <image class="code" src="../../static/300_qr.png"></image> -->
</view>
<view class="shareBott" :style="{display: shareBtnDisplay}">
<button class="shareCol" @click="shareClose" open-type="share"
style="border-radius:0;flex:1;">发给朋友</button>
<button class="shareCol" @click="save" style="border-radius:0;flex:1;">保存相册</button>
</view>
</view>
</uni-popup>
</view>
</template>
<script>
<script>
let sysInfo = uni.getSystemInfoSync();
let SCREEN_WIDTH = sysInfo.screenWidth
let SCREEN_HEIGHT = sysInfo.screenHeight;
let WindowHeight = sysInfo.windowHeight;
let windowWidth = sysInfo.windowWidth;
import {
weixin
} from '@/utils/weixin.js'
export default {
data() {
return {
return {
promotion_id:"",
//
cropperW: SCREEN_WIDTH,
cropperH: SCREEN_HEIGHT,
packages: [],
sharePath: "",
scare: 1,
shareHeight: 500,
imgAvatar: "",
poster: "",
//
loading: true,
showQR: false,
showFlag: 1,
@ -280,9 +330,8 @@
return {
title: this.detail.name,
path: "packages/packageCarecenter/pages/careCenter/serviceDetail?id=" + this.detail.id + "&promotion_id=" +
this
.user_info.id,
imageUrl: this.img
this.user_info.id,
imageUrl: this.detail.cover_picture
}
},
methods: {
@ -355,7 +404,210 @@
}
})
}
},
getPoster: function() {
var that = this;
uni.getImageInfo({
src: that.detail.cover_picture, //
success: res => {
that.poster = res.path;
that.getAvatar();
}
});
},
getAvatar: function() {
let userProfile = uni.getStorageSync('user_profile');
if (!weixin.isNull(userProfile)) {
console.log(userProfile.avatarUrl)
console.log(this.imgAvatar)
uni.getImageInfo({
src: userProfile.avatarUrl, //
success: rlogo => {
this.imgAvatar = rlogo.path;
console.log(this.imgAvatar)
this.draw();
}
});
} else {
this.imgAvatar = "../../static/avatar.jpg";
console.log(this.imgAvatar)
this.draw();
}
},
shareOpen() {
uni.showLoading({
title: '加载中'
});
var that = this;
this.$refs.shareCode.open();
this.getPoster();
},
draw: function() {
var that = this;
uni.request({
url: this.baseUrl + '/api/member/get-wxa-qrcode',
method: 'GET',
data: {
path: 'packages/packageCarecenter/pages/careCenter/serviceDetail',
scene: 'id=' + this.detail.id + '&promotion_id=' + this.user_info.id
},
success: r => {
if (r.data.status === 1) {
uni.getImageInfo({
src: this.baseUrl + r.data.data, //
success: res => {
var ctx = uni.createCanvasContext('firstCanvas')
var w = SCREEN_WIDTH * 0.8;
var h = this.shareHeight * this.scare;
// ctx.fillStyle = '#fff';
// ctx.fillRect(0, 0, 214, 342);
console.log(1)
ctx.drawImage('../../static/bg_haibao@2x.jpg', 0, 0,
w, h
); //(SCREEN_HEIGHT - 50 - SCREEN_WIDTH * 0.8 * 1.65) /2, SCREEN_WIDTH * 0.8, SCREEN_WIDTH * 0.8 * 1.5);
ctx.drawImage('../../static/bg_haibao1.png', 20, 30 + 40,
w -
40, h - 100);
/* SCREEN_WIDTH *
0.15, (SCREEN_HEIGHT - SCREEN_WIDTH * 0.6 * 1.65) /
2, SCREEN_WIDTH * 0.695, SCREEN_WIDTH * 0.6 * 1.5); */
ctx.drawImage(this.poster, 20, 30 + 40,
w -
40, (h - 60 - 60) * 0.5);
/* SCREEN_WIDTH * 0.15, (SCREEN_HEIGHT - SCREEN_WIDTH *
0.6 * 1.65) /
2, SCREEN_WIDTH * 0.695, SCREEN_WIDTH * 0.695 / 1.6); */
ctx.font = "22rpx bold";
//
ctx.fillStyle = "#fff";
// xy
ctx.fillText("优孕课堂福利专享", 20, 50);
ctx.font = "16rpx bold";
//
ctx.fillStyle = "#000";
// xy
ctx.fillText("专享福利", 40, (h + 50) * 0.5 + 20);
ctx.font = "14rpx bold";
//
ctx.fillStyle = "#3377b7";
// xy
let detail = this.detail
ctx.fillText(detail.name, 40, (h + 50) * 0.5 + 20 + 30);
let user_info = uni.getStorageSync("user_info_yunyubang");
let userProfile = uni.getStorageSync('user_profile');
var img = this.imgAvatar;
uni.getImageInfo({
src: userProfile.avatarUrl, //
success: rlogo => {
img = rlogo.path;
}
});
that.circleImg(ctx,
img,
40, h - 60 - w * 0.15,
w * 0.15 / 2);
ctx.font = "12rpx normal";
//
ctx.fillStyle = "#000";
// xy
if (!weixin.isNull(user_info.name))
ctx.fillText(user_info.name,
40, h - 40);
else
ctx.fillText("",
40, h - 40);
this.circleImg(ctx, res.path, w - 40 - w * 0.2, h - 40 -
w *
0.2, w * 0.2 / 2);
console.log(2)
ctx.draw(),
// r:
setTimeout(() => {
uni.canvasToTempFilePath({
canvasId: 'firstCanvas',
fileType: 'jpg',
success: (res) => {
console.log(3)
this.shareBtnDisplay =
'flex'
uni.hideLoading();
this.img = this.detail.cover_picture;
this.sharePath = res
.tempFilePath;
},
})
}, 100)
}
})
} else {
uni.hideLoading()
this.$refs.shareCode.close()
this.alert(r.data.msg)
}
}
})
},
circleImg: function(ctx, img, x, y, r) {
ctx.save()
var d = 2 * r;
var cx = x + r;
var cy = y + r;
ctx.arc(cx, cy, r, 0, 2 * Math.PI);
ctx.clip();
ctx.drawImage(img, x, y, d, d);
ctx.restore();
},
shareClose() {
this.$refs.shareCode.close()
},
open() {
this.$refs.popup.open('top')
},
close() {
this.$refs.popup.close()
},
//h5
save() {
let _this = this;
// #ifdef H5
uni.previewImage({
urls: [_this.sharePath]
})
// #endif
// #ifdef APP-PLUS||MP-WEIXIN
uni.saveImageToPhotosAlbum({
filePath: _this.sharePath,
success: function() {
_this.$refs.shareCode.close()
_this.alert('保存成功')
}
});
// #endif
},
},
computed: {
@ -371,12 +623,17 @@
weixin.getOpenidInfo(info => {
that.user_info = info.user_info;
}, true);
},
onLoad(option) {
this.getServiceDetail(option.id)
onLoad(options) {
let id = options.id;
const scene = decodeURIComponent(options.scene);
console.log(scene)
if (!weixin.isNull(scene)) {
id = weixin.getParam(scene, "id");
this.promotion_id = weixin.getParam(scene, "promotion_id");
}
this.getServiceDetail(id)
},
onPageScroll(e) {
this.$u.throttle(() => {
@ -390,7 +647,131 @@
}
</script>
<style scoped lang="scss">
<style scoped lang="scss">
.shareBox {
background: rgba(0, 0, 0, 0.5);
}
.codeOuter {
width: 100%;
height: 100vh;
background: rgba(0, 0, 0, 0.5);
// padding-top: 13vh;
box-sizing: border-box;
position: relative;
}
.shareCon {
// width: 500rpx;
// margin: 0 auto;
//position: absolute;
//top: 45%;
//left: 50%;
// transform: translate(-50%, -50%);
.code {
width: 300rpx;
height: 300rpx;
display: block;
position: absolute;
left: 50%;
margin-left: -150rpx;
top: 50%;
margin-top: -150rpx;
}
}
.shareBott {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
display: flex;
justify-content: flex-start;
.shareCol {
width: 50%;
height: 100rpx;
text-align: center;
line-height: 100rpx;
font-size: 30rpx;
background: #FF578A;
color: #fff;
}
.shareCol:first-child {
background: #e8e8e8;
color: #666;
}
}
.userBoxBottom {
.userBoxBottomCol {
font-size: 28rpx;
}
.btnuserBoxBottomCol {
background: linear-gradient(90deg, #FF7E95 0%, #FF447B 100%);
border-radius: 36rpx;
font-size: 28rpx;
font-weight: 500;
text-align: center;
line-height: 72rpx;
color: #fff;
}
}
.footer {
width: 100%;
height: 112rpx;
background: #FFFFFF;
box-shadow: 0px -1rpx 0px 0px #DEDEDE;
padding: 0 30rpx;
box-sizing: border-box;
display: flex;
justify-content: space-between;
align-items: center;
position: fixed;
bottom: 0;
left: 0;
.menuLink {
display: flex;
justify-content: flex-start;
align-items: center;
color: #333;
.menuCol {
margin: 0 30rpx;
font-size: 20rpx;
text {
display: block;
}
.iconfont {
font-size: 36rpx;
margin-bottom: 6rpx;
}
}
}
.buyBtn {
//width: 220rpx;
padding: 0px 40rpx;
height: 72rpx;
background: linear-gradient(90deg, #FF7E95 0%, #FF447B 100%);
border-radius: 36rpx;
font-size: 28rpx;
font-weight: 500;
text-align: center;
line-height: 72rpx;
color: #fff;
}
}
.onlineService {
display: flex;
flex-direction: column;

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Loading…
Cancel
Save