Browse Source

二期海报修改

twodate
Enzo 5 years ago
parent
commit
b9c043c249
  1. 79
      pages/bill/bill.vue

79
pages/bill/bill.vue

@ -1,17 +1,21 @@
<template> <template>
<view> <view>
<view @click="baocun()">保存相册</view>
<button class='zfbtn m_l' @tap='formSubmit()'> <button class='zfbtn m_l' @tap='formSubmit()'>
<image src="../../static/center/collect-active.png" class='img'></image>
分享
</button> </button>
<tki-qrcode ref="qrcode" @result="qrR" :val="checkArea" :size="115" unit="px" background="#fff" foreground="#000"
pdground="#000" :onval="true" :loadMake="true" />
<tki-qrcode ref="qrcode" @result="qrR" :val="checkArea" :size="115" unit="px" background="#fff"
foreground="#000" pdground="#000" :onval="true" :loadMake="true" />
<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>
</view> </view>
</template> </template>
@ -24,7 +28,7 @@
}, },
data() { data() {
return { return {
base64Img: '', //
base64Img: '', //
checkArea: '0', checkArea: '0',
@ -35,7 +39,16 @@
inputValue: "", inputValue: "",
maskHidden: false, maskHidden: false,
name: "kk", name: "kk",
code: "E7A93C"
code: "E7A93C",
info: {
avatar: '',
nickname: '',
id: '',
tel: '',
tags: []
},
showLogin: true
} }
}, },
methods: { methods: {
@ -44,18 +57,47 @@
}, },
verifyUserInfo() {
let userInfo = uni.getStorageSync('userinfo') || {};
if (!userInfo.id || !userInfo.nickname || !userInfo.avatar) {
if (this.showLogin) {
this.showLogin = false;
this.$url('/pages/login/index?type=userinfo');
} else {
this.showLogin = true;
this.$url('/pages/index/index', {
type: 'switch'
});
}
}
},
getData() {
let userinfo = uni.getStorageSync('userinfo') || {};
if(userinfo) {
this.info = userinfo
}else {
this.$http(this.API.API_USER_CENTER).then(res => {
this.info = res.data;
console.log(this.info)
})
}
},
createNewImg() { createNewImg() {
var that = this; var that = this;
var context = wx.createCanvasContext('mycanvas'); var context = wx.createCanvasContext('mycanvas');
context.setFillStyle("#ffe200") context.setFillStyle("#ffe200")
context.fillRect(0, 0, 375, 667) context.fillRect(0, 0, 375, 667)
var path = "../../static/images/empty.png"; var path = "../../static/images/empty.png";
//canvas,drawImage()
//
context.drawImage(path, 0, 0, 375, 183); context.drawImage(path, 0, 0, 375, 183);
var path1 = that.touxiang;
that.info.avatar = "../../static/images/system/payfail.png"
var path1 = that.info.avatar;
console.log(path1, "path1") console.log(path1, "path1")
//canvas,drawImage()
//
var path2 = "../../static/images/system/payfail.png"; var path2 = "../../static/images/system/payfail.png";
var path3 = "../../static/images/system/paysuccess.png"; var path3 = "../../static/images/system/paysuccess.png";
var path4 = "../../static/images/system/paysuccess.png"; var path4 = "../../static/images/system/paysuccess.png";
@ -64,7 +106,7 @@
// //
// context.save(); // context // context.save(); // context
var name = that.name;
var name = that.info.nickname;
// //
context.setFontSize(24); context.setFontSize(24);
context.setFillStyle('#333333'); context.setFillStyle('#333333');
@ -118,8 +160,9 @@
var tempFilePath = res.tempFilePath; var tempFilePath = res.tempFilePath;
that.imagePath = tempFilePath that.imagePath = tempFilePath
that.canvasHidden = true that.canvasHidden = true
console.log('成功')
console.log('海报生成成功')
console.log(res) console.log(res)
console.log(that.imagePath)
}, },
fail: function(res) { fail: function(res) {
console.log(res); console.log(res);
@ -140,10 +183,11 @@
success: function(res) { success: function(res) {
if (res.confirm) { if (res.confirm) {
console.log('用户点击确定'); console.log('用户点击确定');
that.maskHidden = false
} }
}, },
fail: function(res) { fail: function(res) {
console.log(11111)
that.maskHidden = false
} }
}) })
} }
@ -152,18 +196,23 @@
formSubmit() { formSubmit() {
var that = this; var that = this;
wx.showToast({ wx.showToast({
title: '装逼中...',
title: '生成海报中...',
icon: 'loading', icon: 'loading',
duration: 1000 duration: 1000
}); });
setTimeout(function() { setTimeout(function() {
wx.hideToast() wx.hideToast()
that.createNewImg(); that.createNewImg();
that.maskHidden = true
}, 1000) }, 1000)
} }
}, },
onLoad(options) { onLoad(options) {
this.qrcode = 'dadaa' this.qrcode = 'dadaa'
this.verifyUserInfo();
this.getData();
} }
} }

Loading…
Cancel
Save