|
|
@ -11,185 +11,185 @@ Page({ |
|
|
* 页面的初始数据 |
|
|
* 页面的初始数据 |
|
|
*/ |
|
|
*/ |
|
|
data: { |
|
|
data: { |
|
|
info:null, |
|
|
info: null, |
|
|
bookingInfo:null, |
|
|
bookingInfo: null, |
|
|
bookingInfoTitle:"", |
|
|
bookingInfoTitle: "", |
|
|
safeBottom:app.globalData.safeBottom, |
|
|
safeBottom: app.globalData.safeBottom, |
|
|
isLike:0, |
|
|
isLike: 0, |
|
|
comment:[], |
|
|
comment: [], |
|
|
commentTotal:0, |
|
|
commentTotal: 0, |
|
|
isTest:true, |
|
|
isTest: true, |
|
|
retailId:"", |
|
|
retailId: "", |
|
|
shareImg:null, |
|
|
shareImg: null, |
|
|
showShareFlag:false |
|
|
showShareFlag: false |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 生命周期函数--监听页面加载 |
|
|
* 生命周期函数--监听页面加载 |
|
|
*/ |
|
|
*/ |
|
|
onLoad: function (options) { |
|
|
onLoad: function (options) { |
|
|
if(!options.id){ |
|
|
if (!options.id) { |
|
|
util.back() |
|
|
util.back() |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
if(options.retailId){ |
|
|
if (options.retailId) { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
retailId:options.retailId |
|
|
retailId: options.retailId |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
commonApi._post("pbservice/Other/getClientConfig",{ |
|
|
commonApi._post("pbservice/Other/getClientConfig", { |
|
|
unique_key:"wechatxcx" |
|
|
unique_key: "wechatxcx" |
|
|
}).then(res=>{ |
|
|
}).then(res => { |
|
|
let data = JSON.parse(res.data); |
|
|
let data = JSON.parse(res.data); |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
isTest:data.isTest |
|
|
isTest: data.isTest |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
id:options.id |
|
|
id: options.id |
|
|
}) |
|
|
}) |
|
|
commonApi._post("scene/detail",{ |
|
|
commonApi._post("scene/detail", { |
|
|
id:options.id |
|
|
id: options.id |
|
|
}).then(res=>{ |
|
|
}).then(res => { |
|
|
if(!res.data){ |
|
|
if (!res.data) { |
|
|
wx.showToast({ |
|
|
wx.showToast({ |
|
|
title: '产品已下架', |
|
|
title: '产品已下架', |
|
|
icon:'none' |
|
|
icon: 'none' |
|
|
}) |
|
|
}) |
|
|
setTimeout(()=>{ |
|
|
setTimeout(() => { |
|
|
util.back(); |
|
|
util.back(); |
|
|
},1000) |
|
|
}, 1000) |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
res.data.display_tags = (res.data.display_tags?res.data.display_tags.split(","):[]).splice(0,2); |
|
|
res.data.display_tags = (res.data.display_tags ? res.data.display_tags.split(",") : []).splice(0, 2); |
|
|
// 如果是带有指定good_id的 那么取指定的
|
|
|
// 如果是带有指定good_id的 那么取指定的
|
|
|
if(options.gid){ |
|
|
if (options.gid) { |
|
|
let pItem = res.data.product.find(item=>item.id==options.gid); |
|
|
let pItem = res.data.product.find(item => item.id == options.gid); |
|
|
if(pItem){ |
|
|
if (pItem) { |
|
|
res.data.product = [pItem]; |
|
|
res.data.product = [pItem]; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
// 如果带有指定skuid的话 那么取指定的sku展示
|
|
|
// 如果带有指定skuid的话 那么取指定的sku展示
|
|
|
if(options.skuid){ |
|
|
if (options.skuid) { |
|
|
let pItem = null; |
|
|
let pItem = null; |
|
|
for(let i = 0;i<res.data.product.length;i++){ |
|
|
for (let i = 0; i < res.data.product.length; i++) { |
|
|
for(let j=0;j<res.data.product[i].sku.length;j++){ |
|
|
for (let j = 0; j < res.data.product[i].sku.length; j++) { |
|
|
if(res.data.product[i].sku[j].id==options.skuid){ |
|
|
if (res.data.product[i].sku[j].id == options.skuid) { |
|
|
res.data.product[i].sku = [res.data.product[i].sku[j]]; |
|
|
res.data.product[i].sku = [res.data.product[i].sku[j]]; |
|
|
pItem = res.data.product[i]; |
|
|
pItem = res.data.product[i]; |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if(pItem){ |
|
|
if (pItem) { |
|
|
res.data.product = [pItem]; |
|
|
res.data.product = [pItem]; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
// res.data.listimg = res.data.listimg?res.data.listimg.split(","):[];
|
|
|
// res.data.listimg = res.data.listimg?res.data.listimg.split(","):[];
|
|
|
res.data.product.map(product=>{ |
|
|
res.data.product.map(product => { |
|
|
product.sku.map(sku=>{ |
|
|
product.sku.map(sku => { |
|
|
sku.display_tags = (sku.display_tags?sku.display_tags.split(","):[]).splice(0,2); |
|
|
sku.display_tags = (sku.display_tags ? sku.display_tags.split(",") : []).splice(0, 2); |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
info:res.data |
|
|
info: res.data |
|
|
}) |
|
|
}) |
|
|
this.BroswerRecord() |
|
|
this.BroswerRecord() |
|
|
}) |
|
|
}) |
|
|
// 获取收藏的状态
|
|
|
// 获取收藏的状态
|
|
|
if(wx.getStorageSync("jstrip_token")){ |
|
|
if (wx.getStorageSync("jstrip_token")) { |
|
|
commonApi.user_post("scene/is_scene_collection",{ |
|
|
commonApi.user_post("scene/is_scene_collection", { |
|
|
scene_id:options.id |
|
|
scene_id: options.id |
|
|
}).then(res=>{ |
|
|
}).then(res => { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
isLike:res.data |
|
|
isLike: res.data |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
commonApi._post("ask/getQuestionList",{ |
|
|
commonApi._post("ask/getQuestionList", { |
|
|
scene_id:options.id, |
|
|
scene_id: options.id, |
|
|
page_no:1, |
|
|
page_no: 1, |
|
|
page_num:3 |
|
|
page_num: 3 |
|
|
}).then(res=>{ |
|
|
}).then(res => { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
ask:res.data.rows |
|
|
ask: res.data.rows |
|
|
}) |
|
|
}) |
|
|
console.log(res) |
|
|
console.log(res) |
|
|
}) |
|
|
}) |
|
|
// 获取评价列表
|
|
|
// 获取评价列表
|
|
|
commonApi._post("scene/get_comment",{ |
|
|
commonApi._post("scene/get_comment", { |
|
|
scene_id:options.id |
|
|
scene_id: options.id |
|
|
}).then(res=>{ |
|
|
}).then(res => { |
|
|
res.data.list.map(item=>{ |
|
|
res.data.list.map(item => { |
|
|
item.rate = Number(item.rate) |
|
|
item.rate = Number(item.rate) |
|
|
}) |
|
|
}) |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
comment:res.data.list.splice(0,3), |
|
|
comment: res.data.list.splice(0, 3), |
|
|
commentTotal:res.data.total |
|
|
commentTotal: res.data.total |
|
|
}) |
|
|
}) |
|
|
console.log(res) |
|
|
console.log(res) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
BroswerRecord:function(){ |
|
|
BroswerRecord: function () { |
|
|
setTimeout(()=>{ |
|
|
setTimeout(() => { |
|
|
if(app.globalData.uuid){ |
|
|
if (app.globalData.uuid) { |
|
|
commonApi._post('browse/browse_record',{ |
|
|
commonApi._post('browse/browse_record', { |
|
|
type:"scene", |
|
|
type: "scene", |
|
|
title:this.data.info.title, |
|
|
title: this.data.info.title, |
|
|
drive:"mini", |
|
|
drive: "mini", |
|
|
source_id:this.data.info.id, |
|
|
source_id: this.data.info.id, |
|
|
url:"/pages/info/sceneProductInfo/index?id="+this.data.info.id, |
|
|
url: "/pages/info/sceneProductInfo/index?id=" + this.data.info.id, |
|
|
uuid:app.globalData.uuid |
|
|
uuid: app.globalData.uuid |
|
|
}).then(res=>{ |
|
|
}).then(res => { |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
this.BroswerRecord(); |
|
|
this.BroswerRecord(); |
|
|
} |
|
|
} |
|
|
},500) |
|
|
}, 500) |
|
|
}, |
|
|
}, |
|
|
like:function(){ |
|
|
like: function () { |
|
|
let id = this.data.id,isLike = Number(this.data.isLike); |
|
|
let id = this.data.id, isLike = Number(this.data.isLike); |
|
|
console.log(isLike) |
|
|
console.log(isLike) |
|
|
commonApi.user_post(isLike!=1?"scene/scene_collection":"scene/scene_cancel_collection",{ |
|
|
commonApi.user_post(isLike != 1 ? "scene/scene_collection" : "scene/scene_cancel_collection", { |
|
|
scene_id:id |
|
|
scene_id: id |
|
|
}).then(res=>{ |
|
|
}).then(res => { |
|
|
if(res.code==1){ |
|
|
if (res.code == 1) { |
|
|
console.log(isLike) |
|
|
console.log(isLike) |
|
|
wx.showToast({ |
|
|
wx.showToast({ |
|
|
title: '操作成功', |
|
|
title: '操作成功', |
|
|
}) |
|
|
}) |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
isLike:isLike==1?0:1 |
|
|
isLike: isLike == 1 ? 0 : 1 |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
gotolocation:function(){ |
|
|
gotolocation: function () { |
|
|
let info = this.data.info; |
|
|
let info = this.data.info; |
|
|
wx.openLocation({ |
|
|
wx.openLocation({ |
|
|
latitude: Number(info.lat), |
|
|
latitude: Number(info.lat), |
|
|
longitude: Number(info.lon) |
|
|
longitude: Number(info.lon) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
audioGuide:function(){ |
|
|
audioGuide: function () { |
|
|
wx.navigateToMiniProgram({ |
|
|
wx.navigateToMiniProgram({ |
|
|
appId: 'wx74f380bc721a0379', |
|
|
appId: 'wx74f380bc721a0379', |
|
|
path:'/pages/listen/listen?title=君到苏州' |
|
|
path: '/pages/listen/listen?title=君到苏州' |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
showBookingInfo:function(e){ |
|
|
showBookingInfo: function (e) { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
bookingInfo:e.currentTarget.dataset.item.sku_model, |
|
|
bookingInfo: e.currentTarget.dataset.item.sku_model, |
|
|
bookingInfoTitle:e.currentTarget.dataset.item.sku_name |
|
|
bookingInfoTitle: e.currentTarget.dataset.item.sku_name |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
closeMask:function(){ |
|
|
closeMask: function () { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
bookingInfo:null |
|
|
bookingInfo: null |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
order:function(e){ |
|
|
order: function (e) { |
|
|
app.globalData.couponInfo = null; |
|
|
app.globalData.couponInfo = null; |
|
|
app.globalData.retailId = this.data.retailId; |
|
|
app.globalData.retailId = this.data.retailId; |
|
|
// let sku = e.currentTarget.dataset.sku,product = e.currentTarget.dataset.product;
|
|
|
// let sku = e.currentTarget.dataset.sku,product = e.currentTarget.dataset.product;
|
|
|
@ -200,46 +200,46 @@ Page({ |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 分享
|
|
|
// 分享
|
|
|
share:function(){ |
|
|
share: function () { |
|
|
if(!wx.getStorageSync("jstrip_token")){ |
|
|
if (!wx.getStorageSync("jstrip_token")) { |
|
|
commonApi.user_post("user/getMyInfo",{}).then(res=>{ |
|
|
commonApi.user_post("user/getMyInfo", {}).then(res => { |
|
|
|
|
|
|
|
|
}) |
|
|
}) |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
if(!this.data.shareImg){ |
|
|
if (!this.data.shareImg) { |
|
|
wx.showToast({ |
|
|
wx.showToast({ |
|
|
title: '图片生成中,稍后再试', |
|
|
title: '图片生成中,稍后再试', |
|
|
icon:'none' |
|
|
icon: 'none' |
|
|
}) |
|
|
}) |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
showShareFlag:!this.data.showShareFlag |
|
|
showShareFlag: !this.data.showShareFlag |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
// 保存
|
|
|
// 保存
|
|
|
save(){ |
|
|
save() { |
|
|
let url = this.data.shareImg,that = this; |
|
|
let url = this.data.shareImg, that = this; |
|
|
wx.authorize({ |
|
|
wx.authorize({ |
|
|
/* 这个就是保存相册的 */ |
|
|
/* 这个就是保存相册的 */ |
|
|
scope: 'scope.writePhotosAlbum', |
|
|
scope: 'scope.writePhotosAlbum', |
|
|
success() { |
|
|
success() { |
|
|
wx.saveImageToPhotosAlbum({ |
|
|
wx.saveImageToPhotosAlbum({ |
|
|
filePath:url, |
|
|
filePath: url, |
|
|
success(res) { |
|
|
success(res) { |
|
|
wx.showToast({ |
|
|
wx.showToast({ |
|
|
title: '保存成功', |
|
|
title: '保存成功', |
|
|
icon:"success" |
|
|
icon: "success" |
|
|
}) |
|
|
}) |
|
|
that.setData({ |
|
|
that.setData({ |
|
|
showShareFlag:!this.data.showShareFlag |
|
|
showShareFlag: !this.data.showShareFlag |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
fail(res){ |
|
|
fail(res) { |
|
|
wx.showToast({ |
|
|
wx.showToast({ |
|
|
title: '保存失败', |
|
|
title: '保存失败', |
|
|
icon:'none' |
|
|
icon: 'none' |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
@ -254,7 +254,7 @@ Page({ |
|
|
// opensit();
|
|
|
// opensit();
|
|
|
wx.showToast({ |
|
|
wx.showToast({ |
|
|
title: '请打开权限后再试', |
|
|
title: '请打开权限后再试', |
|
|
icon:'none' |
|
|
icon: 'none' |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -264,9 +264,9 @@ Page({ |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
// 绘制海报
|
|
|
// 绘制海报
|
|
|
drawImg:function(){ |
|
|
drawImg: function () { |
|
|
var that = this,userinfo = wx.getStorageSync('jstrip_userInfo'); |
|
|
var that = this, userinfo = wx.getStorageSync('jstrip_userInfo'); |
|
|
if(!userinfo){ |
|
|
if (!userinfo) { |
|
|
// 去登录
|
|
|
// 去登录
|
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
@ -274,21 +274,21 @@ Page({ |
|
|
// const device = wx.getSystemInfoSync();
|
|
|
// const device = wx.getSystemInfoSync();
|
|
|
// const ratio = device.screenWidth / 750;
|
|
|
// const ratio = device.screenWidth / 750;
|
|
|
// 先获取到图片信息
|
|
|
// 先获取到图片信息
|
|
|
let promise2 = new Promise(function(resolve,reject){ |
|
|
let promise2 = new Promise(function (resolve, reject) { |
|
|
wx.getImageInfo({ |
|
|
wx.getImageInfo({ |
|
|
src:that.data.info.headimg, |
|
|
src: that.data.info.headimg, |
|
|
success:function(res){ |
|
|
success: function (res) { |
|
|
resolve(res); |
|
|
resolve(res); |
|
|
}, |
|
|
}, |
|
|
fail:function(res){ |
|
|
fail: function (res) { |
|
|
reject(res); |
|
|
reject(res); |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
let promise3 = new Promise(function(resolve,reject){ |
|
|
let promise3 = new Promise(function (resolve, reject) { |
|
|
let userid = wx.getStorageSync('jstrip_userid') |
|
|
let userid = wx.getStorageSync('jstrip_userid') |
|
|
new QRCode('myQrcode',{ |
|
|
new QRCode('myQrcode', { |
|
|
text: 'https://m.cloud.sz-trip.com/ScenicDetail?id='+that.data.info.id+'&sharedUserId='+userid+'&channel=-1', |
|
|
text: 'https://m.cloud.sz-trip.com/ScenicDetail?id=' + that.data.info.id + '&sharedUserId=' + userid + '&channel=-1', |
|
|
width: 500, |
|
|
width: 500, |
|
|
height: 500, |
|
|
height: 500, |
|
|
padding: 12, // 生成二维码四周自动留边宽度,不传入默认为0
|
|
|
padding: 12, // 生成二维码四周自动留边宽度,不传入默认为0
|
|
|
@ -299,39 +299,39 @@ Page({ |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
//成功得到图片信息后,开始绘图
|
|
|
//成功得到图片信息后,开始绘图
|
|
|
Promise.all([promise2,promise3]).then(imgs=>{ |
|
|
Promise.all([promise2, promise3]).then(imgs => { |
|
|
ctx.save(); |
|
|
ctx.save(); |
|
|
ctx.beginPath(); //开始绘制
|
|
|
ctx.beginPath(); //开始绘制
|
|
|
that.handleBorderRect(ctx,0,0,551 * ratio,407 * ratio,25 * ratio,'#ccc') |
|
|
that.handleBorderRect(ctx, 0, 0, 551 * ratio, 407 * ratio, 25 * ratio, '#ccc') |
|
|
ctx.clip();//画好了圆 剪切 原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内 这也是我们要save上下文的原因
|
|
|
ctx.clip();//画好了圆 剪切 原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内 这也是我们要save上下文的原因
|
|
|
ctx.drawImage(imgs[0].path, 0, 0,551 * ratio,407 * ratio); |
|
|
ctx.drawImage(imgs[0].path, 0, 0, 551 * ratio, 407 * ratio); |
|
|
ctx.restore(); |
|
|
ctx.restore(); |
|
|
ctx.save(); |
|
|
ctx.save(); |
|
|
that.handleBorderRect2(ctx,0,407 * ratio,551 * ratio,236*ratio,25 * ratio,'#fff') |
|
|
that.handleBorderRect2(ctx, 0, 407 * ratio, 551 * ratio, 236 * ratio, 25 * ratio, '#fff') |
|
|
ctx.restore(); |
|
|
ctx.restore(); |
|
|
// 绘制二维码
|
|
|
// 绘制二维码
|
|
|
ctx.drawImage(imgs[1].path, 373 * ratio, 495 * ratio,137 * ratio, 137 * ratio); |
|
|
ctx.drawImage(imgs[1].path, 373 * ratio, 495 * ratio, 137 * ratio, 137 * ratio); |
|
|
// 开始文字绘制
|
|
|
// 开始文字绘制
|
|
|
ctx.setFillStyle("#000"); |
|
|
ctx.setFillStyle("#000"); |
|
|
ctx.setFontSize(30 * ratio); //字大小
|
|
|
ctx.setFontSize(30 * ratio); //字大小
|
|
|
ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
|
|
|
ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
|
|
|
that.drawText(ctx,that.data.info.title, 25*ratio, 450*ratio,480 * ratio,ratio); |
|
|
that.drawText(ctx, that.data.info.title, 25 * ratio, 450 * ratio, 480 * ratio, ratio); |
|
|
// 售价
|
|
|
// 售价
|
|
|
ctx.setFillStyle("#D62828"); |
|
|
ctx.setFillStyle("#D62828"); |
|
|
ctx.setFontSize(40 * ratio); //字大小
|
|
|
ctx.setFontSize(40 * ratio); //字大小
|
|
|
ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
|
|
|
ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
|
|
|
let price = "¥"+(that.data.info.price/100); |
|
|
let price = "¥" + (that.data.info.price / 100); |
|
|
let width = ctx.measureText(price).width; |
|
|
let width = ctx.measureText(price).width; |
|
|
ctx.fillText(price, 25*ratio, 620*ratio); |
|
|
ctx.fillText(price, 25 * ratio, 620 * ratio); |
|
|
// 副标题
|
|
|
// 副标题
|
|
|
ctx.setFillStyle("#999999"); |
|
|
ctx.setFillStyle("#999999"); |
|
|
ctx.setFontSize(28 * ratio); //字大小
|
|
|
ctx.setFontSize(28 * ratio); //字大小
|
|
|
ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
|
|
|
ctx.setTextAlign('left'); //是否居中显示,参考点画布中线
|
|
|
let subtitle = that.data.info.display_tags[0]; |
|
|
let subtitle = that.data.info.display_tags[0]; |
|
|
if(subtitle.length>10){ |
|
|
if (subtitle.length > 10) { |
|
|
subtitle = subtitle.substr(0,10)+'...' |
|
|
subtitle = subtitle.substr(0, 10) + '...' |
|
|
} |
|
|
} |
|
|
ctx.fillText(subtitle, 25*ratio, 540*ratio); |
|
|
ctx.fillText(subtitle, 25 * ratio, 540 * ratio); |
|
|
// ctx.draw();
|
|
|
// ctx.draw();
|
|
|
// 划线价
|
|
|
// 划线价
|
|
|
// ctx.setFillStyle("#999999");
|
|
|
// ctx.setFillStyle("#999999");
|
|
|
@ -358,31 +358,31 @@ Page({ |
|
|
// ctx.fillText("长按图片保存到本地",(592*ratio - ctx.measureText("长按图片保存到本地").width)/2, 740*ratio);
|
|
|
// ctx.fillText("长按图片保存到本地",(592*ratio - ctx.measureText("长按图片保存到本地").width)/2, 740*ratio);
|
|
|
ctx.draw(); |
|
|
ctx.draw(); |
|
|
// 转为图片
|
|
|
// 转为图片
|
|
|
setTimeout(()=>{ |
|
|
setTimeout(() => { |
|
|
wx.canvasToTempFilePath({ |
|
|
wx.canvasToTempFilePath({ |
|
|
x: 0, |
|
|
x: 0, |
|
|
y: 0, |
|
|
y: 0, |
|
|
canvasId: 'imageCanvas', |
|
|
canvasId: 'imageCanvas', |
|
|
success: function (res) { |
|
|
success: function (res) { |
|
|
that.setData({ |
|
|
that.setData({ |
|
|
shareImg:res.tempFilePath |
|
|
shareImg: res.tempFilePath |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
fail(err){ |
|
|
fail(err) { |
|
|
console.log('agdgjgdajhg',err) |
|
|
console.log('agdgjgdajhg', err) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
},500) |
|
|
}, 500) |
|
|
return false; |
|
|
return false; |
|
|
}).catch(err=>{ |
|
|
}).catch(err => { |
|
|
console.log("this err",err) |
|
|
console.log("this err", err) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
// 圆角矩形
|
|
|
// 圆角矩形
|
|
|
handleBorderRect(ctx, x, y, w, h, r, color){ |
|
|
handleBorderRect(ctx, x, y, w, h, r, color) { |
|
|
ctx.beginPath(); |
|
|
ctx.beginPath(); |
|
|
ctx.moveTo(x+w,y+h); |
|
|
ctx.moveTo(x + w, y + h); |
|
|
ctx.lineTo(x,y+h) |
|
|
ctx.lineTo(x, y + h) |
|
|
// 左上角
|
|
|
// 左上角
|
|
|
ctx.arc(x + r, y + r, r, Math.PI, 1.5 * Math.PI); |
|
|
ctx.arc(x + r, y + r, r, Math.PI, 1.5 * Math.PI); |
|
|
ctx.moveTo(x + r, y); |
|
|
ctx.moveTo(x + r, y); |
|
|
@ -390,16 +390,16 @@ Page({ |
|
|
ctx.lineTo(x + w, y + r); |
|
|
ctx.lineTo(x + w, y + r); |
|
|
// 右上角
|
|
|
// 右上角
|
|
|
ctx.arc(x + w - r, y + r, r, 1.5 * Math.PI, 2 * Math.PI); |
|
|
ctx.arc(x + w - r, y + r, r, 1.5 * Math.PI, 2 * Math.PI); |
|
|
ctx.lineTo(x + w, y + h ); |
|
|
ctx.lineTo(x + w, y + h); |
|
|
ctx.lineTo(x + w - r, y + h); |
|
|
ctx.lineTo(x + w - r, y + h); |
|
|
ctx.fillStyle = color; |
|
|
ctx.fillStyle = color; |
|
|
ctx.fill(); |
|
|
ctx.fill(); |
|
|
ctx.closePath(); |
|
|
ctx.closePath(); |
|
|
}, |
|
|
}, |
|
|
handleBorderRect2(ctx, x, y, w, h, r, color){ |
|
|
handleBorderRect2(ctx, x, y, w, h, r, color) { |
|
|
ctx.beginPath(); |
|
|
ctx.beginPath(); |
|
|
ctx.moveTo(x,y); |
|
|
ctx.moveTo(x, y); |
|
|
ctx.lineTo(x+w,y) |
|
|
ctx.lineTo(x + w, y) |
|
|
// 右下角
|
|
|
// 右下角
|
|
|
ctx.arc(x + w - r, y + h - r, r, 0, 0.5 * Math.PI); |
|
|
ctx.arc(x + w - r, y + h - r, r, 0, 0.5 * Math.PI); |
|
|
ctx.lineTo(x + r, y + h); |
|
|
ctx.lineTo(x + r, y + h); |
|
|
@ -413,8 +413,8 @@ Page({ |
|
|
ctx.closePath(); |
|
|
ctx.closePath(); |
|
|
}, |
|
|
}, |
|
|
// 绘制两行文字
|
|
|
// 绘制两行文字
|
|
|
drawText: function(ctx, str, x, y, canvasWidth,ratio) { |
|
|
drawText: function (ctx, str, x, y, canvasWidth, ratio) { |
|
|
let row = [],temp="",chr=str.split(""); |
|
|
let row = [], temp = "", chr = str.split(""); |
|
|
for (var a = 0; a < chr.length; a++) { |
|
|
for (var a = 0; a < chr.length; a++) { |
|
|
if (ctx.measureText(temp).width < canvasWidth) { |
|
|
if (ctx.measureText(temp).width < canvasWidth) { |
|
|
temp += chr[a]; |
|
|
temp += chr[a]; |
|
|
@ -462,17 +462,17 @@ Page({ |
|
|
* 生命周期函数--监听页面显示 |
|
|
* 生命周期函数--监听页面显示 |
|
|
*/ |
|
|
*/ |
|
|
onShow: function () { |
|
|
onShow: function () { |
|
|
// if(!wx.getStorageSync('jstrip_token')){
|
|
|
if (!wx.getStorageSync('jstrip_token')) { |
|
|
// return;
|
|
|
return; |
|
|
// }
|
|
|
} |
|
|
// if(this.data.info && this.data.info.id){
|
|
|
if (this.data.info && this.data.info.id) { |
|
|
// this.drawImg()
|
|
|
this.drawImg() |
|
|
// }
|
|
|
} |
|
|
// else {
|
|
|
else { |
|
|
// setTimeout(()=>{
|
|
|
setTimeout(() => { |
|
|
// this.onShow()
|
|
|
this.onShow() |
|
|
// },200)
|
|
|
}, 200) |
|
|
// }
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|