|
|
<template>
|
|
|
<view class="content">
|
|
|
<view class="memberBanner">
|
|
|
<image mode="widthFix" src="../../static/member_01.jpg"></image>
|
|
|
</view>
|
|
|
<view class="memberBanner">
|
|
|
<image mode="widthFix" src="../../static/member_02.jpg"></image>
|
|
|
</view>
|
|
|
<view class="memberBanner">
|
|
|
<image mode="widthFix" src="../../static/member_03.jpg"></image>
|
|
|
</view>
|
|
|
<view class="memberBanner">
|
|
|
<image mode="widthFix" src="../../static/member_04.jpg"></image>
|
|
|
</view>
|
|
|
<view class="joinBox" @click="open"><button>加入会员</button></view>
|
|
|
<view class="shareIcon" @click="shareOpen" v-if="user_info.promotion == 1">
|
|
|
<image src="../../static/share.png"></image>
|
|
|
</view>
|
|
|
<uni-popup ref="popup" :mask-click="false" type="bottom" class="popBox">
|
|
|
<view class="memberPop">
|
|
|
<image class="i_close" @click="close" src="../../static/details_close@2x.png"></image>
|
|
|
<view class="title">购会员,享特权</view>
|
|
|
<view class="cardOuter">
|
|
|
<view v-for="(i, k) in packages" :class="{cur: cardActive == k, cardCol: true}" @click="cardActive = k">
|
|
|
<view>{{i.name}}</view>
|
|
|
<view class="cardTit">{{i.price}}元</view>
|
|
|
</view>
|
|
|
<!-- <view :class="{cur: cardActive == 1, cardCol: true}" @click="cardActive = 1">
|
|
|
<view>福利卡</view>
|
|
|
<view class="cardTit">99元</view>
|
|
|
</view> -->
|
|
|
</view>
|
|
|
<button class="buyNow" @click="goBuy">立即购买</button>
|
|
|
</view>
|
|
|
</uni-popup>
|
|
|
<uni-popup ref="shareCode" :mask-click="true" type="bottom" class="shareBox">
|
|
|
<view class="codeOuter">
|
|
|
<view class="shareCon" @click="shareClose">
|
|
|
<canvas style="width:100%;" :style="{ height: (cropperH-50) + 'px' }" 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>
|
|
|
let sysInfo = uni.getSystemInfoSync();
|
|
|
let SCREEN_WIDTH = sysInfo.screenWidth
|
|
|
let SCREEN_HEIGHT = sysInfo.screenHeight
|
|
|
import {
|
|
|
weixin
|
|
|
} from '../../utils/weixin.js';
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
cardActive: 0,
|
|
|
img: '',
|
|
|
user_info: {
|
|
|
promotion: ''
|
|
|
},
|
|
|
shareBtnDisplay: 'none',
|
|
|
// 动态的宽高
|
|
|
cropperW: SCREEN_WIDTH,
|
|
|
cropperH: SCREEN_HEIGHT,
|
|
|
packages: [],
|
|
|
}
|
|
|
},
|
|
|
onLoad() {
|
|
|
weixin.getOpenidInfo(info => {
|
|
|
this.user_info = info
|
|
|
})
|
|
|
},
|
|
|
onShow() {
|
|
|
if (this.checkLogin()) {
|
|
|
this.getPackages()
|
|
|
}
|
|
|
},
|
|
|
onShareAppMessage() {
|
|
|
return {
|
|
|
title: '加入会员',
|
|
|
path: 'pages/member/member?promotion_id=' + this.user_info.id,
|
|
|
imageUrl: this.img
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
shareOpen() {
|
|
|
uni.showLoading({
|
|
|
title: '加载中'
|
|
|
});
|
|
|
this.$refs.shareCode.open()
|
|
|
uni.request({
|
|
|
url: this.baseUrl + '/api/member/get-wxa-qrcode',
|
|
|
method: 'GET',
|
|
|
data: {
|
|
|
path: '',
|
|
|
scene: this.user_info.id
|
|
|
},
|
|
|
success: r => {
|
|
|
if (r.data.status === 1) {
|
|
|
uni.getImageInfo({
|
|
|
src: this.baseUrl + r.data.data, // 二维码
|
|
|
success: res => {
|
|
|
let ctx = uni.createCanvasContext('firstCanvas')
|
|
|
|
|
|
// ctx.fillStyle = '#fff';
|
|
|
// ctx.fillRect(0, 0, 214, 342);
|
|
|
ctx.drawImage('../../static/bg_haibao@2x.jpg', SCREEN_WIDTH *
|
|
|
0.1, (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',
|
|
|
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('../../static/member_01.jpg',
|
|
|
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 = "22px bold";
|
|
|
// 设置颜色
|
|
|
ctx.fillStyle = "#fff";
|
|
|
// 绘制文字(参数:要写的字,x坐标,y坐标)
|
|
|
ctx.fillText("会员福利孕产礼包", SCREEN_WIDTH * 0.15, (SCREEN_HEIGHT-SCREEN_WIDTH * 0.8 * 1.5)/2);
|
|
|
|
|
|
ctx.font = "16px bold";
|
|
|
// 设置颜色
|
|
|
ctx.fillStyle = "#000";
|
|
|
// 绘制文字(参数:要写的字,x坐标,y坐标)
|
|
|
ctx.fillText("专享大礼包", SCREEN_WIDTH * 0.2, (SCREEN_HEIGHT-SCREEN_WIDTH * 0.8 * 1.5)/2+SCREEN_WIDTH * 0.695/ 1.6*1.5);
|
|
|
// ctx.beginPath();
|
|
|
// ctx.arc(SCREEN_WIDTH * 0.62+SCREEN_WIDTH * 0.2*0.5, (SCREEN_HEIGHT -
|
|
|
// 50 - SCREEN_WIDTH * 0.8 * 1.5) / 2 + SCREEN_WIDTH *
|
|
|
// 0.8 * 1.02+SCREEN_WIDTH * 0.2*0.5, SCREEN_WIDTH * 0.2, 2 * Math.PI);
|
|
|
// ctx.clip();
|
|
|
this.circleImg(ctx,res.path, SCREEN_WIDTH * 0.62, (SCREEN_HEIGHT -
|
|
|
50 - SCREEN_WIDTH * 0.8 * 1.5) / 2 + SCREEN_WIDTH *
|
|
|
0.8 * 1.05, SCREEN_WIDTH * 0.2/2);
|
|
|
|
|
|
ctx.draw(),
|
|
|
// r: 半径
|
|
|
setTimeout(() => {
|
|
|
uni.canvasToTempFilePath({
|
|
|
canvasId: 'firstCanvas',
|
|
|
fileType: 'jpg',
|
|
|
success: (res) => {
|
|
|
this.shareBtnDisplay = 'flex'
|
|
|
uni.hideLoading()
|
|
|
this.img = 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()
|
|
|
},
|
|
|
goBuy() {
|
|
|
if (this.checkLogin()) {
|
|
|
this.$refs.popup.close()
|
|
|
let package_id = this.packages.length > 0 ? this.packages[this.cardActive].id : 0
|
|
|
uni.navigateTo({
|
|
|
url: "../../packages/packageBuy/pages/buyMember/buyMember?package_id=" + package_id
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
//保存图片时,h5端不能直接保存,只能通过预览长按保存
|
|
|
save() {
|
|
|
let _this = this;
|
|
|
// #ifdef H5
|
|
|
uni.previewImage({
|
|
|
urls: [_this.img]
|
|
|
})
|
|
|
// #endif
|
|
|
// #ifdef APP-PLUS||MP-WEIXIN
|
|
|
uni.saveImageToPhotosAlbum({
|
|
|
filePath: _this.img,
|
|
|
success: function() {
|
|
|
_this.$refs.shareCode.close()
|
|
|
_this.alert('保存成功')
|
|
|
}
|
|
|
});
|
|
|
// #endif
|
|
|
},
|
|
|
getPackages() {
|
|
|
this.reqByToken('/api/member/get-packages', {}, r => {
|
|
|
this.packages = r
|
|
|
}, 'GET')
|
|
|
},
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
|
<style>
|
|
|
page {
|
|
|
background: #fff;
|
|
|
padding-bottom: 160rpx;
|
|
|
}
|
|
|
</style>
|
|
|
<style lang="scss" scoped>
|
|
|
.content {
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
|
align-items: center;
|
|
|
justify-content: center;
|
|
|
}
|
|
|
|
|
|
.memberBanner {
|
|
|
display: block;
|
|
|
width: 100%;
|
|
|
|
|
|
image {
|
|
|
display: block;
|
|
|
width: 100%;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
.joinBox {
|
|
|
width: 100%;
|
|
|
padding: 30rpx;
|
|
|
box-sizing: border-box;
|
|
|
position: fixed;
|
|
|
left: 0;
|
|
|
bottom: 0;
|
|
|
background: #fff;
|
|
|
box-shadow: -5rpx 0px 20rpx rgba(0, 0, 0, 0.1);
|
|
|
|
|
|
button {
|
|
|
width: 100%;
|
|
|
height: 100rpx;
|
|
|
color: #fff;
|
|
|
font-size: 28rpx;
|
|
|
text-align: center;
|
|
|
line-height: 100rpx;
|
|
|
text-align: center;
|
|
|
background: #FF578A;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
.popBox {
|
|
|
background: #fff;
|
|
|
width: 100%;
|
|
|
}
|
|
|
|
|
|
.shareIcon {
|
|
|
position: fixed;
|
|
|
width: 136rpx;
|
|
|
height: 136rpx;
|
|
|
bottom: 150rpx;
|
|
|
right: 30rpx;
|
|
|
z-index: 9;
|
|
|
|
|
|
image {
|
|
|
display: block;
|
|
|
width: 136rpx;
|
|
|
height: 136rpx;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
.memberPop {
|
|
|
background: #fff;
|
|
|
width: 100%;
|
|
|
position: fixed;
|
|
|
padding-bottom: 50rpx;
|
|
|
bottom: 0;
|
|
|
left: 0;
|
|
|
|
|
|
.title {
|
|
|
font-size: 36rpx;
|
|
|
color: #000;
|
|
|
text-align: center;
|
|
|
padding: 25rpx 0;
|
|
|
}
|
|
|
|
|
|
.i_close {
|
|
|
display: block;
|
|
|
width: 38rpx;
|
|
|
height: 36rpx;
|
|
|
position: absolute;
|
|
|
top: 30rpx;
|
|
|
right: 30rpx;
|
|
|
}
|
|
|
|
|
|
.cardOuter {
|
|
|
display: flex;
|
|
|
justify-content:flex-start;
|
|
|
padding: 20rpx;
|
|
|
.cardCol {
|
|
|
width: 224rpx;
|
|
|
height: 156rpx;
|
|
|
margin:0 15rpx;
|
|
|
border-radius: 8rpx;
|
|
|
box-sizing: border-box;
|
|
|
border: 2rpx solid #F5DFB5;
|
|
|
font-size: 28rpx;
|
|
|
color: #999;
|
|
|
text-align: center;
|
|
|
line-height: 2;
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
|
justify-content: center;
|
|
|
align-items: center;
|
|
|
align-content: center;
|
|
|
|
|
|
.cardTit {
|
|
|
color: #333;
|
|
|
font-size: 32rpx;
|
|
|
font-weight: 700;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
.cardCol.cur {
|
|
|
border: 2rpx solid #E40280;
|
|
|
box-shadow: 0 0 15rpx rgba(228, 2, 128, 0.4);
|
|
|
color: #FF578A;
|
|
|
|
|
|
.cardTit {
|
|
|
color: #FF578A;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
.buyNow {
|
|
|
width: 500rpx;
|
|
|
height: 80rpx;
|
|
|
border-radius: 40rpx;
|
|
|
color: #fff;
|
|
|
font-size: 30rpx;
|
|
|
text-align: center;
|
|
|
line-height: 80rpx;
|
|
|
text-align: center;
|
|
|
background: #FF578A;
|
|
|
margin: 30rpx auto 0 auto;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
.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;
|
|
|
}
|
|
|
}
|
|
|
</style>
|