Browse Source

二期海报

twodate
Enzo 4 years ago
parent
commit
d7789e10da
  1. 71
      pages/bill/bill.vue

71
pages/bill/bill.vue

@ -1,20 +1,23 @@
<template> <template>
<view> <view>
<button class='zfbtn m_l' @tap='formSubmit()'> <button class='zfbtn m_l' @tap='formSubmit()'>
分享 分享
</button> </button>
<image :src="info.avatar" mode="aspectFill"></image>
<tki-qrcode v-if="info.avatar" ref="qrcode" @result="qrR" :val="checkArea" :size="115" unit="px" background="#fff"
foreground="#000" pdground="#000" :onval="true" :loadMake="true" :icon="info.avatar" />
<tki-qrcode ref="qrcode" @result="qrR" :val="checkArea" :size="115" unit="px" background="#fff"
foreground="#000" pdground="#000" :onval="true" :loadMake="true" />
<tki-qrcode v-else ref="qrcode" @result="qrR" :val="checkArea" :size="115" unit="px" background="#fff"
foreground="#000" pdground="#000" :onval="true" :loadMake="true" :icon="require('@/static/images/system/payfail.png')" />
<view class="canvas-box"> <view class="canvas-box">
<canvas style="width: 375px;height: 667px;position:fixed;top:9999px" canvas-id="mycanvas" /> <canvas style="width: 375px;height: 667px;position:fixed;top:9999px" canvas-id="mycanvas" />
</view> </view>
<view class='imagePathBox' v-if="maskHidden == true">
<image :src="imagePath" class='shengcheng'></image>
<button class='baocun'@click="baocun()">保存相册分享到朋友圈</button>
<view class='imagePathBox' v-if="maskHidden == true && imagePath" @click="maskHidden = false ">
<image :src="imagePath" class='shengcheng' mode="aspectFill"></image>
<button class='baocun' @click.stop="baocun()">保存相册分享到朋友圈</button>
</view> </view>
</view> </view>
</template> </template>
@ -28,19 +31,11 @@
}, },
data() { data() {
return { return {
base64Img: '', //
checkArea: '0',
img: "../../static/images/empty.png",
wechat: "../../static/images/tabbar/home.png",
quan: "../../static/images/tabbar/my.png",
touxiang: "../../static/images/system/payfail.png",
base64Img: '',
checkArea: 'Cannot find module',
inputValue: "", inputValue: "",
maskHidden: false, maskHidden: false,
name: "kk", name: "kk",
code: "E7A93C",
info: { info: {
avatar: '', avatar: '',
nickname: '', nickname: '',
@ -48,12 +43,16 @@
tel: '', tel: '',
tags: [] tags: []
}, },
showLogin: true
showLogin: true,
imagePath: '',
userToken: ''
} }
}, },
methods: { methods: {
qrR(data) { qrR(data) {
this.base64Img = data; this.base64Img = data;
console.log('base64',this.base64Img)
}, },
@ -73,16 +72,15 @@
}, },
getData() { getData() {
let userinfo = uni.getStorageSync('userinfo') || {}; let userinfo = uni.getStorageSync('userinfo') || {};
if(userinfo) {
if (userinfo) {
this.info = userinfo this.info = userinfo
}else {
console.log('用户数据缓存',this.info)
} else {
this.$http(this.API.API_USER_CENTER).then(res => { this.$http(this.API.API_USER_CENTER).then(res => {
this.info = res.data; this.info = res.data;
console.log(this.info)
console.log('用户数据接口',this.info)
}) })
} }
}, },
@ -91,29 +89,28 @@
var context = wx.createCanvasContext('mycanvas'); var context = wx.createCanvasContext('mycanvas');
var path = "../../static/images/poster-1.jpg"; var path = "../../static/images/poster-1.jpg";
context.drawImage(path, 0, 0, 375, 667); context.drawImage(path, 0, 0, 375, 667);
var name = that.info.nickname;
//
context.drawImage(that.base64Img, 24, 530,120, 120);
// //
context.setFontSize(24);
context.setFillStyle('#fff');
context.setTextAlign('center');
context.fillText(name, 34, 620);
// context.setFontSize(24);
// context.setFillStyle('#fff');
// context.setTextAlign('center');
// context.fillText(name, 34, 620);
context.stroke(); context.stroke();
//
context.draw(); context.draw();
// //
setTimeout(function() { setTimeout(function() {
wx.canvasToTempFilePath({ wx.canvasToTempFilePath({
canvasId: 'mycanvas', canvasId: 'mycanvas',
success: function(res) { success: function(res) {
var tempFilePath1 = res.tempFilePath;
that.imagePath = tempFilePath1
that.imagePath = res.tempFilePath;
if(that.imagePath) {
that.canvasHidden = true that.canvasHidden = true
that.maskHidden = true
}
console.log('海报生成成功') console.log('海报生成成功')
console.log(res) console.log(res)
console.log('图片链接',that.imagePath)
console.log('图片链接', that.imagePath)
}, },
fail: function(res) { fail: function(res) {
console.log(res); console.log(res);
@ -152,8 +149,10 @@
duration: 1000 duration: 1000
}); });
wx.hideToast() wx.hideToast()
that.createNewImg();
that.maskHidden = true
that.createNewImg()
// if(that.imagePath) {
// that.maskHidden = true
// }
} }
}, },
onLoad(options) { onLoad(options) {

Loading…
Cancel
Save