|
|
|
@ -4,13 +4,7 @@ |
|
|
|
<!-- <image src="../../static/images/bill.png" mode="widthFix" style="height: 1220rpx;width: 686rpx;"></image> --> |
|
|
|
<image v-if="imagePath" :src="imagePath" mode="widthFix"></image> |
|
|
|
</view> |
|
|
|
|
|
|
|
<tki-qrcode v-if="info.avatar" style="visibility: hidden;position: fixed;left: -500rpx;" 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 v-else ref="qrcode" style="visibility: hidden;position: fixed;left: -500rpx;" @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"> |
|
|
|
<canvas style="width: 375px;height: 667px;position:fixed;top:9999px" canvas-id="mycanvas" /> |
|
|
|
</view> |
|
|
|
@ -18,7 +12,7 @@ |
|
|
|
<view class="btn-bottom" style="bottom: 40rpx;"> |
|
|
|
<view class="padding-lr-lg"> |
|
|
|
<button class="cu-btn block bg-orange lg" style="border-radius: 42rpx;" @tap="saveBill()"> |
|
|
|
<text class="text-df text-white">保存</text> |
|
|
|
<text class="lf-font-32 text-white">保存</text> |
|
|
|
</button> |
|
|
|
</view> |
|
|
|
|
|
|
|
@ -32,7 +26,6 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import tkiQrcode from "tki-qrcode"; // 二维码生成器 |
|
|
|
export default { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
@ -49,75 +42,65 @@ |
|
|
|
showLogin: true, |
|
|
|
imagePath: '', |
|
|
|
|
|
|
|
userToken: '' |
|
|
|
userToken: '', |
|
|
|
wxCode: '', |
|
|
|
onceCode: '' |
|
|
|
} |
|
|
|
}, |
|
|
|
components: { |
|
|
|
tkiQrcode |
|
|
|
}, |
|
|
|
onLoad() { |
|
|
|
wx.showToast({ |
|
|
|
title: '生成海报中...', |
|
|
|
icon: 'loading', |
|
|
|
duration: 1000 |
|
|
|
}); |
|
|
|
this.getData(); |
|
|
|
this.createNewImg(); |
|
|
|
this.getWxCode() |
|
|
|
}, |
|
|
|
methods:{ |
|
|
|
//保存头像 |
|
|
|
saveAvatar() { |
|
|
|
var that = this |
|
|
|
console.log(that.info.avatar) |
|
|
|
wx.saveImageToPhotosAlbum({ |
|
|
|
filePath: that.info.avatar, |
|
|
|
success(res) { |
|
|
|
wx.showModal({ |
|
|
|
content: '图片已保存到相册,赶紧晒一下吧~', |
|
|
|
showCancel: false, |
|
|
|
confirmText: '好的', |
|
|
|
confirmColor: '#333', |
|
|
|
success: function(res) { |
|
|
|
if (res.confirm) { |
|
|
|
console.log('用户点击确定'); |
|
|
|
that.maskHidden = false |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: function(res) { |
|
|
|
that.maskHidden = false |
|
|
|
console.log(res) |
|
|
|
} |
|
|
|
}) |
|
|
|
getWxCode() { |
|
|
|
uni.request({ |
|
|
|
url: 'http://dev-gxsky.com/api/salesman/qrcode', //仅为示例,并非真实接口地址。 |
|
|
|
data: { |
|
|
|
scene: 'route=goods&id=2&pt=2', |
|
|
|
page: 'pages/route/index', |
|
|
|
width: '2800' |
|
|
|
}, |
|
|
|
fail(err) { |
|
|
|
method: 'POST', |
|
|
|
success: (res) => { |
|
|
|
this.wxCode = res.data.data.base_url |
|
|
|
if (this.wxCode) { |
|
|
|
this.getwxCodeImg() |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
//保存二维码 |
|
|
|
getwxCodeImg() { |
|
|
|
var imgSrc = this.wxCode; //base64编码 |
|
|
|
var save = wx.getFileSystemManager(); |
|
|
|
var number = Math.random(); |
|
|
|
save.writeFile({ |
|
|
|
filePath: wx.env.USER_DATA_PATH + '/pic' + number + '.jpg', |
|
|
|
data: imgSrc, |
|
|
|
encoding: 'base64', |
|
|
|
success: res => { |
|
|
|
this.onceCode = wx.env.USER_DATA_PATH + '/pic' + number + '.jpg' |
|
|
|
if(this.onceCode) { |
|
|
|
this.createNewImg() |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: err => { |
|
|
|
console.log(err) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
qrR(data) { |
|
|
|
this.base64Img = data; |
|
|
|
console.log('base64',this.base64Img) |
|
|
|
}, |
|
|
|
getData() { |
|
|
|
let userinfo = uni.getStorageSync('userinfo') || {}; |
|
|
|
if (userinfo) { |
|
|
|
this.info = userinfo |
|
|
|
console.log('用户数据缓存',this.info) |
|
|
|
} else { |
|
|
|
this.$http(this.API.API_USER_CENTER).then(res => { |
|
|
|
this.info = res.data; |
|
|
|
console.log('用户数据接口',this.info) |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
createNewImg() { |
|
|
|
var that = this; |
|
|
|
var context = wx.createCanvasContext('mycanvas'); |
|
|
|
var path = "../../static/images/bill.png"; |
|
|
|
context.drawImage(path, 0, 0, 375, 667); |
|
|
|
//绘制二维码 |
|
|
|
var path1 = "../../static/logo.png"; |
|
|
|
context.drawImage(path1, 24, 530,120, 120); |
|
|
|
let wxcode = that.onceCode |
|
|
|
context.drawImage(wxcode, 18, 530, 120, 120); |
|
|
|
//绘制名字 |
|
|
|
// context.setFontSize(24); |
|
|
|
// context.setFillStyle('#fff'); |
|
|
|
@ -168,16 +151,6 @@ |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
formSubmit() { |
|
|
|
var that = this; |
|
|
|
wx.showToast({ |
|
|
|
title: '生成海报中...', |
|
|
|
icon: 'loading', |
|
|
|
duration: 1000 |
|
|
|
}); |
|
|
|
wx.hideToast() |
|
|
|
that.createNewImg() |
|
|
|
}, |
|
|
|
// 点击复制 |
|
|
|
copy(text) { |
|
|
|
uni.setClipboardData({ |
|
|
|
|