Browse Source

二期海报

twodate
Enzo 4 years ago
parent
commit
bdea625d67
  1. 317
      pages/bill/bill.vue

317
pages/bill/bill.vue

@ -1,21 +1,19 @@
<template> <template>
<view> <view>
分享海报
<view class="qrcode-hidden" style="height: 100px;width: 100%;">
<tkiQrcod cid="qrcode"
@result="result"
ref="qrcode"
:val="qrcode"
onval
:size="340"
:showLoading="false"
/></view>
<image src="../../static/images/empty.png" mode="aspectFill" style="width: 200rpx;height: 200rpx;"></image>
<view class="save-pic bg-blueself discenter animation-slide-right" @click="saveIamge" data-provider="save" data-scene="">保存分享海报</view>
<view @click="baocun()">保存相册</view>
<button class='zfbtn m_l' @tap='formSubmit()'>
<image src="../../static/center/collect-active.png" class='img'></image>
</button>
<view class="canvas-box">
<canvas style="width: 375px;height: 667px;position:fixed;top:9999px" canvas-id="mycanvas" />
</view>
</view> </view>
</template> </template>
<script> <script>
const app = getApp()
import tkiQrcode from "tki-qrcode"; // import tkiQrcode from "tki-qrcode"; //
export default { export default {
components: { components: {
@ -25,19 +23,152 @@
return { return {
qrcode: '', qrcode: '',
qrcodeImg: '', qrcodeImg: '',
code: ''
code: '',
img: "../../static/images/empty.png",
wechat: "../../static/images/tabbar/home.png",
quan: "../../static/images/tabbar/my.png",
touxiang: "../../static/images/system/payfail.png",
code: "E7AI98",
inputValue: "",
maskHidden: false,
name: "kk",
code: "E7A93C"
} }
}, },
methods: { methods: {
result(e) { result(e) {
uni.setStorage({ key: 'shareImg', data: e })
uni.setStorage({
key: 'shareImg',
data: e
})
this.qrcodeImg = e this.qrcodeImg = e
}, },
saveIamge(e) { saveIamge(e) {
this.share(e) this.share(e)
}, },
createNewImg() {
var that = this;
var context = wx.createCanvasContext('mycanvas');
context.setFillStyle("#ffe200")
context.fillRect(0, 0, 375, 667)
var path = "../../static/images/empty.png";
//canvas,drawImage()
//
context.drawImage(path, 0, 0, 375, 183);
var path1 = that.touxiang;
console.log(path1, "path1")
//canvas,drawImage()
var path2 = "../../static/images/system/payfail.png";
var path3 = "../../static/images/system/paysuccess.png";
var path4 = "../../static/images/system/paysuccess.png";
var path5 = "../../static/images/system/refresh.png";
context.drawImage(path2, 126, 186, 120, 120);
//
// context.save(); // context
var name = that.name;
//
context.setFontSize(24);
context.setFillStyle('#333333');
context.setTextAlign('center');
context.fillText(name, 185, 340);
context.stroke();
//
context.setFontSize(14);
context.setFillStyle('#333333');
context.setTextAlign('center');
context.fillText("邀请你一起去吃面", 185, 370);
context.stroke();
//
context.drawImage(path3, 48, 390, 280, 84);
//code
context.setFontSize(40);
context.setFillStyle('#ffe200');
context.setTextAlign('center');
context.fillText(that.code, 185, 435);
context.stroke();
//
context.drawImage(path4, 25, 520, 184, 82);
context.setFontSize(12);
context.setFillStyle('#333');
context.setTextAlign('left');
context.fillText("进入小程序输入朋友的邀请", 35, 540);
context.stroke();
context.setFontSize(12);
context.setFillStyle('#333');
context.setTextAlign('left');
context.fillText("码,朋友和你各自获得通用", 35, 560);
context.stroke();
context.setFontSize(12);
context.setFillStyle('#333');
context.setTextAlign('left');
context.fillText("优惠券1张哦~", 35, 580);
context.stroke();
//
context.drawImage(path5, 248, 578, 90, 25);
//
context.arc(186, 246, 50, 0, 2 * Math.PI) //
context.strokeStyle = "#ffe200";
context.clip(); //
context.drawImage(path1, 136, 196, 100, 100); //
context.draw();
//
setTimeout(function() {
wx.canvasToTempFilePath({
canvasId: 'mycanvas',
success: function(res) {
var tempFilePath = res.tempFilePath;
that.imagePath = tempFilePath
that.canvasHidden = true
console.log('成功')
console.log(res)
},
fail: function(res) {
console.log(res);
}
});
}, 200);
},
baocun() {
var that = this
wx.saveImageToPhotosAlbum({
filePath: that.imagePath,
success(res) {
wx.showModal({
content: '图片已保存到相册,赶紧晒一下吧~',
showCancel: false,
confirmText: '好的',
confirmColor: '#333',
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
}
},
fail: function(res) {
console.log(11111)
}
})
}
})
},
formSubmit() {
var that = this;
wx.showToast({
title: '装逼中...',
icon: 'loading',
duration: 1000
});
setTimeout(function() {
wx.hideToast()
that.createNewImg();
}, 1000)
}
}, },
onLoad() {
onLoad(options) {
this.qrcode = 'dadaa' this.qrcode = 'dadaa'
} }
@ -45,4 +176,160 @@
</script> </script>
<style> <style>
.bgImg {
display: block;
width: 100%;
height: 366rpx;
}
.mine {
display: block;
text-align: center;
color: #333;
margin-top: 44rpx;
}
.code {
display: block;
text-align: center;
color: #333;
font-size: 76rpx;
font-weight: bold;
margin-top: 30rpx;
}
.who {
display: block;
margin-top: 80rpx;
font-size: 32rpx;
color: #333;
text-align: center;
}
.inputBox {
text-align: center;
margin-top: 44rpx;
}
.input {
text-align: center;
width: 440rpx;
height: 88rpx;
border-radius: 44rpx;
background: #f5f5f5;
font-size: 32rpx;
display: inline-block;
}
.btn {
width: 160rpx;
height: 88rpx;
border-radius: 44rpx;
background: linear-gradient(90deg, rgba(255, 226, 0, 1), rgba(255, 200, 11, 1));
box-shadow: 0px 4px 8px 0px rgba(255, 200, 11, 0.5);
color: #333;
font-size: 32rpx;
display: inline-block;
line-height: 88rpx;
margin-left: 40rpx;
}
button[class="btn"]::after {
border: 0;
}
.tishi {
display: block;
text-align: center;
color: #999;
margin-top: 30rpx;
}
.shareText {
display: block;
text-align: center;
color: #333;
font-size: 28rpx;
margin-top: 100rpx;
}
.imgBox {
text-align: center;
width: 100%;
margin-top: 60rpx;
padding-bottom: 120rpx;
}
.img {
display: inline-block;
width: 100%;
height: 100%;
}
.m_l {
margin-left: 180rpx;
}
.zfbtn {
display: inline-block;
width: 120rpx;
height: 120rpx;
border-radius: 50%;
background: transparent;
outline: none;
border: 0;
padding: 0;
}
button[class="zfbtn"]::after {
border: 0;
}
button[class="zfbtn m_l"]::after {
border: 0;
}
.imagePathBox {
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.7);
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 10;
}
.shengcheng {
width: 80%;
height: 80%;
position: fixed;
top: 50rpx;
left: 50%;
margin-left: -40%;
z-index: 10;
}
.baocun {
display: block;
width: 80%;
height: 80rpx;
padding: 0;
line-height: 80rpx;
text-align: center;
position: fixed;
bottom: 50rpx;
left: 10%;
background: #ffe200;
color: #333;
font-size: 32rpx;
border-radius: 44rpx;
}
button[class="baocun"]::after {
border: 0;
}
</style>
}
</style> </style>
Loading…
Cancel
Save