|
|
@ -20,7 +20,9 @@ Page({ |
|
|
retailId: "", |
|
|
retailId: "", |
|
|
retailSkuId: "", |
|
|
retailSkuId: "", |
|
|
shareImg: null, |
|
|
shareImg: null, |
|
|
showShareFlag: false |
|
|
showShareFlag: false, |
|
|
|
|
|
showQrCode: false, |
|
|
|
|
|
wxqrcode: null |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -54,7 +56,7 @@ Page({ |
|
|
retailSkuId: options.skuid |
|
|
retailSkuId: options.skuid |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
res.data.flag = res.data.sku.find(item=>item.flag=='on')?res.data.flag:0 |
|
|
res.data.flag = res.data.sku.find(item => item.flag == 'on') ? res.data.flag : 0 |
|
|
|
|
|
|
|
|
this.setData({ |
|
|
this.setData({ |
|
|
info: res.data |
|
|
info: res.data |
|
|
@ -85,16 +87,15 @@ Page({ |
|
|
source_id: this.data.info.id, |
|
|
source_id: this.data.info.id, |
|
|
url: "/pages/info/cardInfo/index?id=" + this.data.info.id, |
|
|
url: "/pages/info/cardInfo/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) |
|
|
}, |
|
|
}, |
|
|
changeMenu: function (e) { |
|
|
changeMenu: function (e) { |
|
|
let index = e.currentTarget.dataset.index, that = this; |
|
|
let index = e.currentTarget.dataset.index, |
|
|
|
|
|
that = this; |
|
|
const query = wx.createSelectorQuery(); //创建节点查询器
|
|
|
const query = wx.createSelectorQuery(); //创建节点查询器
|
|
|
query.select("#box" + index).boundingClientRect() //选择toViewid获取位置信息
|
|
|
query.select("#box" + index).boundingClientRect() //选择toViewid获取位置信息
|
|
|
query.selectViewport().scrollOffset() //获取页面查询位置的
|
|
|
query.selectViewport().scrollOffset() //获取页面查询位置的
|
|
|
@ -110,7 +111,8 @@ Page({ |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
onPageScroll: function (e) { |
|
|
onPageScroll: function (e) { |
|
|
let that = this, height = this.data.top; |
|
|
let that = this, |
|
|
|
|
|
height = this.data.top; |
|
|
let topHeight = height; |
|
|
let topHeight = height; |
|
|
wx.createSelectorQuery().select('#menus').boundingClientRect(function (rect) { |
|
|
wx.createSelectorQuery().select('#menus').boundingClientRect(function (rect) { |
|
|
console.log(rect.top, topHeight) |
|
|
console.log(rect.top, topHeight) |
|
|
@ -119,8 +121,7 @@ Page({ |
|
|
that.setData({ |
|
|
that.setData({ |
|
|
fixed: true |
|
|
fixed: true |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} else { |
|
|
else { |
|
|
|
|
|
that.setData({ |
|
|
that.setData({ |
|
|
fixed: false |
|
|
fixed: false |
|
|
}) |
|
|
}) |
|
|
@ -137,18 +138,15 @@ Page({ |
|
|
that.setData({ |
|
|
that.setData({ |
|
|
type: 4 |
|
|
type: 4 |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} else if (res[2].top < minHeight) { |
|
|
else if (res[2].top < minHeight) { |
|
|
|
|
|
that.setData({ |
|
|
that.setData({ |
|
|
type: 3 |
|
|
type: 3 |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} else if (res[1].top < minHeight) { |
|
|
else if (res[1].top < minHeight) { |
|
|
|
|
|
that.setData({ |
|
|
that.setData({ |
|
|
type: 2 |
|
|
type: 2 |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} else { |
|
|
else { |
|
|
|
|
|
that.setData({ |
|
|
that.setData({ |
|
|
type: 1 |
|
|
type: 1 |
|
|
}) |
|
|
}) |
|
|
@ -158,37 +156,53 @@ Page({ |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
order: function () { |
|
|
order: function () { |
|
|
|
|
|
commonApi.user_post('wx/get_user_keep', { |
|
|
|
|
|
jumpurl: '/pages/info/roadInfo/index?id=' + this.data.id, |
|
|
|
|
|
title: this.data.info.title, |
|
|
|
|
|
type: 'mini' |
|
|
|
|
|
}).then(res => { |
|
|
|
|
|
if (res.data.subscribe == 0) { |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
wxqrcode: res.data.qrcode, |
|
|
|
|
|
showQrCode: true |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
app.globalData.couponInfo = null; |
|
|
app.globalData.couponInfo = null; |
|
|
app.globalData.product = { |
|
|
app.globalData.product = { |
|
|
product: this.data.info |
|
|
product: this.data.info |
|
|
} |
|
|
} |
|
|
app.globalData.retailId = this.data.retailId; |
|
|
app.globalData.retailId = this.data.retailId; |
|
|
util.pagePoint({ |
|
|
util.pagePoint({ |
|
|
event:'product_order', |
|
|
event: 'product_order', |
|
|
param:{ |
|
|
param: { |
|
|
id:this.data.info.id, |
|
|
id: this.data.info.id, |
|
|
type:this.data.info.type |
|
|
type: this.data.info.type |
|
|
} |
|
|
} |
|
|
},1) |
|
|
}, 1) |
|
|
wx.setStorageSync('login_from', 'product_order_login') |
|
|
wx.setStorageSync('login_from', 'product_order_login') |
|
|
wx.setStorageSync('order_from', 'product_order_submit') |
|
|
wx.setStorageSync('order_from', 'product_order_submit') |
|
|
wx.navigateTo({ |
|
|
wx.navigateTo({ |
|
|
url: '/pages/order/road/index?id=' + this.data.info.id + (this.data.retailSkuId ? ('&skuid=' + this.data.retailSkuId) : '') |
|
|
url: '/pages/order/road/index?id=' + this.data.info.id + (this.data.retailSkuId ? ('&skuid=' + this.data.retailSkuId) : '') |
|
|
}) |
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
pagePoint:function(e){ |
|
|
pagePoint: function (e) { |
|
|
util.pagePoint(e) |
|
|
util.pagePoint(e) |
|
|
}, |
|
|
}, |
|
|
// 分享
|
|
|
// 分享
|
|
|
share: function () { |
|
|
share: function () { |
|
|
if (!wx.getStorageSync("jstrip_token")) { |
|
|
if (!wx.getStorageSync("jstrip_token")) { |
|
|
util.pagePoint({ |
|
|
util.pagePoint({ |
|
|
event:'product_share_login', |
|
|
event: 'product_share_login', |
|
|
param:{ |
|
|
param: { |
|
|
id:that.data.info.id, |
|
|
id: that.data.info.id, |
|
|
type:that.data.info.type |
|
|
type: that.data.info.type |
|
|
} |
|
|
} |
|
|
},1) |
|
|
}, 1) |
|
|
commonApi.user_post("user/getMyInfo", {}).then(res => { |
|
|
commonApi.user_post("user/getMyInfo", {}).then(res => { |
|
|
|
|
|
|
|
|
}) |
|
|
}) |
|
|
@ -207,7 +221,8 @@ Page({ |
|
|
}, |
|
|
}, |
|
|
// 保存
|
|
|
// 保存
|
|
|
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', |
|
|
@ -223,12 +238,12 @@ Page({ |
|
|
showShareFlag: !that.data.showShareFlag |
|
|
showShareFlag: !that.data.showShareFlag |
|
|
}) |
|
|
}) |
|
|
util.pagePoint({ |
|
|
util.pagePoint({ |
|
|
event:'product_share_save', |
|
|
event: 'product_share_save', |
|
|
param:{ |
|
|
param: { |
|
|
id:that.data.info.id, |
|
|
id: that.data.info.id, |
|
|
type:that.data.info.type |
|
|
type: that.data.info.type |
|
|
} |
|
|
} |
|
|
},1) |
|
|
}, 1) |
|
|
}, |
|
|
}, |
|
|
fail(res) { |
|
|
fail(res) { |
|
|
wx.showToast({ |
|
|
wx.showToast({ |
|
|
@ -259,7 +274,8 @@ 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; |
|
|
@ -297,7 +313,7 @@ Page({ |
|
|
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(); |
|
|
@ -408,12 +424,13 @@ Page({ |
|
|
}, |
|
|
}, |
|
|
// 绘制两行文字
|
|
|
// 绘制两行文字
|
|
|
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]; |
|
|
} |
|
|
} else { |
|
|
else { |
|
|
|
|
|
a--; //这里添加了a-- 是为了防止字符丢失,效果图中有对比
|
|
|
a--; //这里添加了a-- 是为了防止字符丢失,效果图中有对比
|
|
|
row.push(temp); |
|
|
row.push(temp); |
|
|
temp = ""; |
|
|
temp = ""; |
|
|
@ -430,13 +447,12 @@ Page({ |
|
|
for (var a = 0; a < rowPart.length; a++) { |
|
|
for (var a = 0; a < rowPart.length; a++) { |
|
|
if (ctx.measureText(test).width < canvasWidth - 30 * ratio) { |
|
|
if (ctx.measureText(test).width < canvasWidth - 30 * ratio) { |
|
|
test += rowPart[a]; |
|
|
test += rowPart[a]; |
|
|
} |
|
|
} else { |
|
|
else { |
|
|
|
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
empty.push(test); |
|
|
empty.push(test); |
|
|
var group = empty[0] + "..."//这里只显示两行,超出的用...表示
|
|
|
var group = empty[0] + "..." //这里只显示两行,超出的用...表示
|
|
|
rowCut.splice(1, 1, group); |
|
|
rowCut.splice(1, 1, group); |
|
|
row = rowCut; |
|
|
row = rowCut; |
|
|
} |
|
|
} |
|
|
@ -461,8 +477,7 @@ Page({ |
|
|
} |
|
|
} |
|
|
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) |
|
|
|