Browse Source

优化商品详情页代码

threedate
邓平艺 4 years ago
parent
commit
4628b8d13b
  1. 28
      pages/goodsDetail/index.vue

28
pages/goodsDetail/index.vue

@ -142,7 +142,6 @@
backgroundImg: '',
goodShare: '',
s_id: '',
isShowButtonCount: 0,
userInfo: {}
}
},
@ -169,11 +168,10 @@
}).then(res => {
let img = res.data.img_url
if (img) {
wx.getImageInfo({
uni.getImageInfo({
src: img,
success: function(sres) {
_this.backgroundImg = sres.path;
_this.isShowButtonCount++;
resolve(); //
}
})
@ -186,7 +184,7 @@
let _this = this
let goods = _this.goods_detail;
let imageUrl = goods.share_cover || goods.cover;
wx.getImageInfo({
uni.getImageInfo({
src: imageUrl,
success: function(sres) {
_this.goodShare = sres.path
@ -251,18 +249,18 @@
})
},
//
//
//
getwxCodeImg(resolve, reject) {
var imgSrc = this.wxCode; //base64
var save = wx.getFileSystemManager();
var save = uni.getFileSystemManager();
var number = Math.random();
var filePath = wx.env.USER_DATA_PATH + '/pic' + number + '.jpg';
save.writeFile({
filePath: wx.env.USER_DATA_PATH + '/pic' + number + '.jpg',
filePath: filePath,
data: imgSrc,
encoding: 'base64',
success: res => {
this.onceCode = wx.env.USER_DATA_PATH + '/pic' + number + '.jpg';
this.isShowButtonCount++;
this.onceCode = filePath;
resolve(); //
console.log('二维码临时路径',this.onceCode)
},
@ -274,7 +272,7 @@
},
createNewImg() {
var that = this;
var context = wx.createCanvasContext('mycanvas');
var context = uni.createCanvasContext('mycanvas');
let goods = that.goods_detail;
let title = goods.name;
let price = '¥'+goods.specs[0].selling_price;
@ -326,7 +324,7 @@
//
setTimeout(function() {
uni.hideLoading(); // loading
wx.canvasToTempFilePath({
uni.canvasToTempFilePath({
canvasId: 'mycanvas',
success: function(res) {
that.imagePath = res.tempFilePath;
@ -334,7 +332,7 @@
that.canvasHidden = true
that.maskHidden = true
}
wx.hideToast()
uni.hideToast()
console.log('海报生成成功')
console.log(res)
console.log('图片链接', that.imagePath)
@ -347,10 +345,10 @@
},
saveBill() {
var that = this
wx.saveImageToPhotosAlbum({
uni.saveImageToPhotosAlbum({
filePath: that.imagePath,
success(res) {
wx.showModal({
uni.showModal({
content: '图片已保存到相册,赶紧晒一下吧~',
showCancel: false,
confirmText: '好的',
@ -370,7 +368,7 @@
},
formSubmit() {
var that = this;
wx.showToast({
uni.showToast({
title: '生成海报中...',
icon: 'loading',
duration: 100000

Loading…
Cancel
Save