Authored by 肖亚东

快照分享保存到本地绘制功能提交以及其他修改 — review by 李其昌

... ... @@ -153,14 +153,10 @@ Component({
},
creatProductDetailSnapShoot() {
var that = this;
const app = getApp() || {};
let userInfo = app.props.globalData.userInfo;
var product = that.properties.shareData;
console.log('====================================');
console.log(product);
console.log('====================================');
if(!product){
return
}
... ... @@ -173,7 +169,7 @@ Component({
// console.log(windowWidth,screenHeight,snapWidth,snapHeight,scale)
let logoHeight = 50 * HScale;
let logoWidth = 50 * scale;
let logoTop = 40 * HScale;
let logoTop = 38 * HScale;
let logoMarginBottom = 25 * HScale;
let logoLeft = 30 * scale //logo左边坐标
... ... @@ -196,27 +192,37 @@ Component({
let qrImgWH = 70 * scale
let qrCodeLeft = (snapWidth - qrImgWH)/2
let tipLeft = (snapWidth - 180 * scale)/2
let tipTop = qrCodeTop + qrImgWH + 20 * scale
const app = getApp() || {};
let userInfo = app.props.globalData.userInfo;
var pCtx = wx.createCanvasContext("productDetailCanvas", this);
pCtx.setFillStyle('white');
pCtx.fillRect(0, 0, snapWidth, snapHeight);
pCtx.setStrokeStyle('#e0e0e0');
/*---------开始新的作画-----------*/
//头像
pCtx.drawImage(userInfo.avatarUrl, logoLeft , logoTop, logoWidth, logoHeight)//画logo
pCtx.setFillStyle('#ffffff');
pCtx.setStrokeStyle('#e0e0e0')
// pCtx.arc(logoLeft+logoWidth/2, logoTop+logoHeight/2, logoWidth/2, 0, 2*Math.PI)
// this.circleImg(pCtx, userInfo.avatarUrl, logoLeft, logoTop, logoWidth)
//圆形头像
if (userInfo.avatarUrl) {
wx.getImageInfo({
src: userInfo.avatarUrl,
success:function(res){
pCtx.beginPath();
pCtx.arc(logoLeft+logoWidth/2, logoTop+logoHeight/2, logoWidth/2, 0, 2*Math.PI, false)
pCtx.stroke();//画空心圆
pCtx.closePath();
pCtx.save();
pCtx.clip(); //裁剪上面的圆形
pCtx.drawImage(res.path, logoLeft , logoTop, logoWidth, logoHeight)
pCtx.restore(); //恢复之前保存的绘图上下文,以便可以继续绘制
}
})
}
//昵称
if (userInfo.nickName) {
pCtx.setFillStyle('#000')
pCtx.setFontSize(20*scale)
pCtx.fillText(userInfo.nickName, nameLeft, nameTop)
}
pCtx.setFillStyle('#000')
pCtx.setFontSize(12*scale)
... ... @@ -225,16 +231,12 @@ Component({
pCtx.strokeRect(imgContainerLeft, imgContainerTop, imgContainerWidth , imgtextContainerHeight)//图片容器
var defaultImage = getImgUrl(product.default_image, imgContainerWidth, imgContainerHeight);
if (defaultImage) {
if (defaultImage && defaultImage.indexOf("https://") == -1) {
defaultImage = defaultImage.replace('http://', 'https://');
}
product.default_image = defaultImage;
that.setData({
shareData: product,
userInfo
})
wx.getImageInfo({
src: defaultImage,
success:function(res){
... ... @@ -246,7 +248,14 @@ Component({
pCtx.draw(true)
}
})
}
that.setData({
shareData: product,
userInfo
})
if (product.product_qrCode) {
wx.getImageInfo({
src: product.product_qrCode,
success:function(res){
... ... @@ -254,6 +263,7 @@ Component({
pCtx.draw(true)
}
})
}
pCtx.setFillStyle('#999999')
pCtx.setFontSize(12*scale)
... ... @@ -263,17 +273,7 @@ Component({
/*---------结束新的作画-----------*/
},
circleImg(ctx, img, x, y, r) {
ctx.save();
var d = 2 * r;
var cx = x + r;
var cy = y + r;
ctx.beginPath();
ctx.arc(cx, cy, r, 0, 2 * Math.PI);
ctx.clip();
ctx.drawImage(img, x, y, d, d);
},
//绘制商品名
drawLongText(longtext, cxt, begin_width, begin_height, color, fontSize, numsForLine,numberOfLine,
isCenter = true,lineL = 0) {
let linelenght = lineL;//行间距
... ...
... ... @@ -5,7 +5,7 @@
<!--商品详情开始 -->
<view class="snapshoot">
<view wx:if="{{userInfo}}" class="user-header">
<view wx:if="{{userInfo.uid}}" class="user-header">
<image class="user-portrait" src="{{userInfo.avatarUrl}}"> </image>
<view class="user-info">
<text class="user-name">{{userInfo.nickName}}</text>
... ...
... ... @@ -132,7 +132,6 @@
text-align: center;
font-size: 28rpx;
font-family: DINAlternate-Bold;
line-height: 48rpx;
}
.product-miniqr-new {
... ...
<view class='container'>
<view class="message-title">
<text class='message-title'>消息</text>
</view>
<block wx:if="{{isLogined}}">
<!-- 三个通知 -->
<view class='message-header'>
... ...
.message-title {
margin-left: 20rpx;
margin-left: 40rpx;
font-family: PingFang-SC-Semibold;
color: #000;
font-size: 68rpx;
... ...
... ... @@ -42,10 +42,6 @@ Page({
messageInfo
})
wx.showLoading({
title: '',
})
let params = {
type: messgeType,
page: messageInfo.currentPage,
... ... @@ -53,9 +49,7 @@ Page({
}
let api = new MessageService();
api.fetchNewMessageList(params, () => {
wx.hideLoading();
})
api.fetchNewMessageList(params)
.then(data => {
if (data) {
let msgList = data.list;
... ... @@ -82,7 +76,6 @@ Page({
})
.catch(error => {
messageInfo.isLoading = false;
console.error(error);
})
},
... ...
... ... @@ -107,16 +107,6 @@ export default class ProductDetail extends Component {
let default_image = imageSize > 0 ? goodsList.image_list[0]['image_url'] : '';
var product_qrCode = ''
// if (app.globalData.user_union_type) {
// let page_param = {
// union_type: app.globalData.user_union_type,
// productSkn: productInfo.product_id,
// }
// product_qrCode = config.domains.api + '/wechat/miniapp/img-check.jpg?param=' + encodeURIComponent(JSON.stringify(page_param)) + '&miniQrType=7';
// } else {
// product_qrCode = config.domains.api + '/wechat/miniapp/img-check.jpg?param=' + productInfo.product_id;
// }
let param = {
id: productInfo.product_id
}
... ...
... ... @@ -33,19 +33,13 @@ Page({
collectionInfo
})
wx.showLoading({
title: '',
})
let params = {
page: collectionInfo.currentPage,
limit: 20
}
let api = new MessageService();
api.fetchCollectionList(params, () => {
wx.hideLoading();
})
api.fetchCollectionList(params)
.then(data => {
if (data) {
let list = data.product_list;
... ... @@ -66,7 +60,6 @@ Page({
that.setData({
collectionInfo,
})
wx.hideLoading();
let _triggerObserer = that.data._triggerObserer;
that.setData({
... ... @@ -75,9 +68,7 @@ Page({
}
})
.catch(error => {
wx.hideLoading();
collectionInfo.isLoading = false;
console.error(error);
})
},
... ...