|
|
|
@ -6,7 +6,6 @@ import util from "../../../utils/util" |
|
|
|
import QRCode from '../../../utils/weapp-qrcode.js' |
|
|
|
let app = getApp() |
|
|
|
Page({ |
|
|
|
|
|
|
|
/** |
|
|
|
* 页面的初始数据 |
|
|
|
*/ |
|
|
|
@ -23,8 +22,8 @@ Page({ |
|
|
|
shareImg: null, |
|
|
|
showShareFlag: false, |
|
|
|
showAllowance: false, |
|
|
|
allowance_data:null, |
|
|
|
//购物车数量
|
|
|
|
allowance_data: null, |
|
|
|
//购物车数量
|
|
|
|
producNum: 1, |
|
|
|
skuIndex: 0, |
|
|
|
aniSkuIndex: -1, |
|
|
|
@ -32,7 +31,7 @@ Page({ |
|
|
|
cartImgInfo: null, |
|
|
|
cartTop: 0, |
|
|
|
top: 0, |
|
|
|
skuList:[],//立即预定的列表
|
|
|
|
skuList: [], //立即预定的列表
|
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
@ -98,16 +97,22 @@ Page({ |
|
|
|
info: res.data |
|
|
|
}) |
|
|
|
var arr = [] |
|
|
|
res.data.product.forEach((item,index) => { |
|
|
|
item.sku.forEach(itemB=>{ |
|
|
|
itemB.proIndex = index |
|
|
|
arr.push(itemB) |
|
|
|
}) |
|
|
|
res.data.product.forEach((item, index) => { |
|
|
|
item.sku.forEach(itemB => { |
|
|
|
itemB.proIndex = index |
|
|
|
arr.push(itemB) |
|
|
|
}) |
|
|
|
}); |
|
|
|
this.setData({ |
|
|
|
skuList:arr |
|
|
|
skuList: arr |
|
|
|
}) |
|
|
|
util.pagePoint({ event: 'scene_view', param: { type: res.data.type, id: res.data.id } }, 1) |
|
|
|
util.pagePoint({ |
|
|
|
event: 'scene_view', |
|
|
|
param: { |
|
|
|
type: res.data.type, |
|
|
|
id: res.data.id |
|
|
|
} |
|
|
|
}, 1) |
|
|
|
this.BroswerRecord() |
|
|
|
}) |
|
|
|
// 获取收藏的状态
|
|
|
|
@ -141,17 +146,17 @@ Page({ |
|
|
|
commentTotal: res.data.total |
|
|
|
}) |
|
|
|
let arr = this.data.comment |
|
|
|
arr.map((item)=>{ |
|
|
|
arr.map((item) => { |
|
|
|
if (item.img_list) { |
|
|
|
let arr = item.img_list.split(',') |
|
|
|
let arr = item.img_list.split(',') |
|
|
|
item.img_list = arr |
|
|
|
|
|
|
|
}else{ |
|
|
|
item.img_list=[] |
|
|
|
|
|
|
|
} else { |
|
|
|
item.img_list = [] |
|
|
|
} |
|
|
|
}) |
|
|
|
this.setData({ |
|
|
|
comment:arr |
|
|
|
comment: arr |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
@ -170,16 +175,15 @@ Page({ |
|
|
|
source_id: this.data.info.id, |
|
|
|
url: "/pages/info/sceneProductInfo/index?id=" + this.data.info.id, |
|
|
|
uuid: app.globalData.uuid |
|
|
|
}).then(res => { |
|
|
|
}) |
|
|
|
} |
|
|
|
else { |
|
|
|
}).then(res => {}) |
|
|
|
} else { |
|
|
|
this.BroswerRecord(); |
|
|
|
} |
|
|
|
}, 500) |
|
|
|
}, |
|
|
|
like: function () { |
|
|
|
let id = this.data.id, isLike = Number(this.data.isLike); |
|
|
|
let id = this.data.id, |
|
|
|
isLike = Number(this.data.isLike); |
|
|
|
commonApi.user_post(isLike != 1 ? "scene/scene_collection" : "scene/scene_cancel_collection", { |
|
|
|
scene_id: id |
|
|
|
}).then(res => { |
|
|
|
@ -225,24 +229,24 @@ Page({ |
|
|
|
}) |
|
|
|
}, |
|
|
|
// order: function(e){
|
|
|
|
// console.log(e)
|
|
|
|
// if (e.currentTarget.dataset.disable == 1) return;
|
|
|
|
// util.pagePoint({
|
|
|
|
// event: 'scene_order',
|
|
|
|
// param: {
|
|
|
|
// type: this.data.info.type,
|
|
|
|
// id: this.data.info.id
|
|
|
|
// }
|
|
|
|
// }, 1)
|
|
|
|
// wx.setStorageSync('login_from', 'scene_order_login')
|
|
|
|
// wx.setStorageSync('order_from', 'scene_order_submit')
|
|
|
|
// app.globalData.couponInfo = null;
|
|
|
|
// app.globalData.retailId = this.data.retailId;
|
|
|
|
// // let sku = e.currentTarget.dataset.sku,product = e.currentTarget.dataset.product;
|
|
|
|
// app.globalData.product = e.currentTarget.dataset;
|
|
|
|
// wx.navigateTo({
|
|
|
|
// url: '/pages/order/scene/index',
|
|
|
|
// })
|
|
|
|
// console.log(e)
|
|
|
|
// if (e.currentTarget.dataset.disable == 1) return;
|
|
|
|
// util.pagePoint({
|
|
|
|
// event: 'scene_order',
|
|
|
|
// param: {
|
|
|
|
// type: this.data.info.type,
|
|
|
|
// id: this.data.info.id
|
|
|
|
// }
|
|
|
|
// }, 1)
|
|
|
|
// wx.setStorageSync('login_from', 'scene_order_login')
|
|
|
|
// wx.setStorageSync('order_from', 'scene_order_submit')
|
|
|
|
// app.globalData.couponInfo = null;
|
|
|
|
// app.globalData.retailId = this.data.retailId;
|
|
|
|
// // let sku = e.currentTarget.dataset.sku,product = e.currentTarget.dataset.product;
|
|
|
|
// app.globalData.product = e.currentTarget.dataset;
|
|
|
|
// wx.navigateTo({
|
|
|
|
// url: '/pages/order/scene/index',
|
|
|
|
// })
|
|
|
|
// },
|
|
|
|
selectSku: function (e) { |
|
|
|
let index = e.currentTarget.dataset.index; |
|
|
|
@ -251,74 +255,85 @@ Page({ |
|
|
|
}) |
|
|
|
}, |
|
|
|
order: function (e) { |
|
|
|
commonApi.user_post("/product/checkStock",{ |
|
|
|
sku_id: this.data.skuList[this.data.skuIndex].id, |
|
|
|
}).then(res => { |
|
|
|
console.log(res) |
|
|
|
if(res && res.code != 1){ |
|
|
|
return; |
|
|
|
}else{ |
|
|
|
// console.log(this.data.info,this.data.skuFlag)
|
|
|
|
app.globalData.postProduct = [] |
|
|
|
app.globalData.list = [] |
|
|
|
if (this.data.skuFlag == 'order'){ |
|
|
|
if (e.currentTarget.dataset.disable == 1) return; |
|
|
|
util.pagePoint({ |
|
|
|
event: 'scene_order', |
|
|
|
param: { |
|
|
|
type: this.data.info.type, |
|
|
|
id: this.data.info.id |
|
|
|
} |
|
|
|
}, 1) |
|
|
|
wx.setStorageSync('login_from', 'scene_order_login') |
|
|
|
wx.setStorageSync('order_from', 'scene_order_submit') |
|
|
|
app.globalData.couponInfo = null; |
|
|
|
app.globalData.retailId = this.data.retailId; |
|
|
|
// let sku = e.currentTarget.dataset.sku,product = e.currentTarget.dataset.product;
|
|
|
|
// let sku = {sku:e.currentTarget.dataset.product.sku[this.data.skuIndex]},product = {product: e.currentTarget.dataset.product}
|
|
|
|
let sku = {sku:this.data.skuList[this.data.skuIndex]},product = {product:this.data.info.product[this.data.skuList[this.data.skuIndex].proIndex]} |
|
|
|
app.globalData.product = {...sku,...product} |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/order/scene/index', |
|
|
|
}) |
|
|
|
}else { |
|
|
|
commonApi.user_post("cart/add_sku", { |
|
|
|
sku_id: this.data.skuList[this.data.skuIndex].id, |
|
|
|
num: this.data.producNum |
|
|
|
}).then(res => { |
|
|
|
if (res.code == 1) { |
|
|
|
commonApi.user_post('cart/get_list', {}).then(res => { |
|
|
|
this.setData({ |
|
|
|
cartCount: res.data.length |
|
|
|
}) |
|
|
|
}) |
|
|
|
// 加动效
|
|
|
|
this.setData({ |
|
|
|
skuFlag: null, |
|
|
|
aniSkuIndex: this.data.skuIndex, |
|
|
|
cartImgInfo: null |
|
|
|
}) |
|
|
|
setTimeout(() => { |
|
|
|
this.setData({ |
|
|
|
aniSkuIndex: -1 |
|
|
|
}) |
|
|
|
wx.showModal({ |
|
|
|
title: "提示", |
|
|
|
content: "去购物车结算?", |
|
|
|
success: function (res) { |
|
|
|
if (res.confirm) { |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/user/cartlist/list', |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}, 650) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
// commonApi.user_post("/product/checkStock", {
|
|
|
|
// sku_id: this.data.skuList[this.data.skuIndex].id,
|
|
|
|
// }).then(res => {
|
|
|
|
// if (res && res.code != 1) {
|
|
|
|
// wx.showModal({
|
|
|
|
// title: "温馨提示",
|
|
|
|
// content: '商品已经被抢光啦~要不要瞧瞧别的~',
|
|
|
|
// showCancel: false
|
|
|
|
// })
|
|
|
|
// return;
|
|
|
|
// } else {
|
|
|
|
app.globalData.postProduct = [] |
|
|
|
app.globalData.list = [] |
|
|
|
if (this.data.skuFlag == 'order') { |
|
|
|
if (e.currentTarget.dataset.disable == 1) return; |
|
|
|
util.pagePoint({ |
|
|
|
event: 'scene_order', |
|
|
|
param: { |
|
|
|
type: this.data.info.type, |
|
|
|
id: this.data.info.id |
|
|
|
} |
|
|
|
}, 1) |
|
|
|
wx.setStorageSync('login_from', 'scene_order_login') |
|
|
|
wx.setStorageSync('order_from', 'scene_order_submit') |
|
|
|
app.globalData.couponInfo = null; |
|
|
|
app.globalData.retailId = this.data.retailId; |
|
|
|
// let sku = e.currentTarget.dataset.sku,product = e.currentTarget.dataset.product;
|
|
|
|
// let sku = {sku:e.currentTarget.dataset.product.sku[this.data.skuIndex]},product = {product: e.currentTarget.dataset.product}
|
|
|
|
let sku = { |
|
|
|
sku: this.data.skuList[this.data.skuIndex] |
|
|
|
}, |
|
|
|
product = { |
|
|
|
product: this.data.info.product[this.data.skuList[this.data.skuIndex].proIndex] |
|
|
|
} |
|
|
|
app.globalData.product = { |
|
|
|
...sku, |
|
|
|
...product |
|
|
|
} |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/order/scene/index', |
|
|
|
}) |
|
|
|
} else { |
|
|
|
commonApi.user_post("cart/add_sku", { |
|
|
|
sku_id: this.data.skuList[this.data.skuIndex].id, |
|
|
|
num: this.data.producNum |
|
|
|
}).then(res => { |
|
|
|
if (res.code == 1) { |
|
|
|
commonApi.user_post('cart/get_list', {}).then(res => { |
|
|
|
this.setData({ |
|
|
|
cartCount: res.data.length |
|
|
|
}) |
|
|
|
}) |
|
|
|
// 加动效
|
|
|
|
this.setData({ |
|
|
|
skuFlag: null, |
|
|
|
aniSkuIndex: this.data.skuIndex, |
|
|
|
cartImgInfo: null |
|
|
|
}) |
|
|
|
setTimeout(() => { |
|
|
|
this.setData({ |
|
|
|
aniSkuIndex: -1 |
|
|
|
}) |
|
|
|
wx.showModal({ |
|
|
|
title: "提示", |
|
|
|
content: "去购物车结算?", |
|
|
|
success: function (res) { |
|
|
|
if (res.confirm) { |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/user/cartlist/list', |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}, 650) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
// }
|
|
|
|
// })
|
|
|
|
}, |
|
|
|
pagePoint: function (e) { |
|
|
|
util.pagePoint({ |
|
|
|
@ -333,9 +348,7 @@ Page({ |
|
|
|
share: function () { |
|
|
|
if (!wx.getStorageSync("jstrip_token")) { |
|
|
|
wx.setStorageSync('login_from', 'scene_share_login') |
|
|
|
commonApi.user_post("user/getMyInfo", {}).then(res => { |
|
|
|
}).catch(err => { |
|
|
|
}) |
|
|
|
commonApi.user_post("user/getMyInfo", {}).then(res => {}).catch(err => {}) |
|
|
|
return; |
|
|
|
} |
|
|
|
if (!this.data.shareImg) { |
|
|
|
@ -351,7 +364,8 @@ Page({ |
|
|
|
}, |
|
|
|
// 保存
|
|
|
|
save() { |
|
|
|
let url = this.data.shareImg, that = this; |
|
|
|
let url = this.data.shareImg, |
|
|
|
that = this; |
|
|
|
wx.authorize({ |
|
|
|
/* 这个就是保存相册的 */ |
|
|
|
scope: 'scope.writePhotosAlbum', |
|
|
|
@ -366,7 +380,13 @@ Page({ |
|
|
|
that.setData({ |
|
|
|
showShareFlag: !that.data.showShareFlag |
|
|
|
}) |
|
|
|
util.pagePoint({ event: 'scene_share_save', param: { type: that.data.info.type, id: that.data.info.id } }, 1) |
|
|
|
util.pagePoint({ |
|
|
|
event: 'scene_share_save', |
|
|
|
param: { |
|
|
|
type: that.data.info.type, |
|
|
|
id: that.data.info.id |
|
|
|
} |
|
|
|
}, 1) |
|
|
|
}, |
|
|
|
fail(res) { |
|
|
|
wx.showToast({ |
|
|
|
@ -396,7 +416,8 @@ Page({ |
|
|
|
}, |
|
|
|
// 绘制海报
|
|
|
|
drawImg: function () { |
|
|
|
var that = this, userinfo = wx.getStorageSync('jstrip_userInfo'); |
|
|
|
var that = this, |
|
|
|
userinfo = wx.getStorageSync('jstrip_userInfo'); |
|
|
|
if (!userinfo) { |
|
|
|
// 去登录
|
|
|
|
return false; |
|
|
|
@ -434,7 +455,7 @@ Page({ |
|
|
|
ctx.save(); |
|
|
|
ctx.beginPath(); //开始绘制
|
|
|
|
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.restore(); |
|
|
|
ctx.save(); |
|
|
|
@ -548,12 +569,13 @@ Page({ |
|
|
|
}, |
|
|
|
// 绘制两行文字
|
|
|
|
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++) { |
|
|
|
if (ctx.measureText(temp).width < canvasWidth) { |
|
|
|
temp += chr[a]; |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
a--; //这里添加了a-- 是为了防止字符丢失,效果图中有对比
|
|
|
|
row.push(temp); |
|
|
|
temp = ""; |
|
|
|
@ -570,13 +592,12 @@ Page({ |
|
|
|
for (var a = 0; a < rowPart.length; a++) { |
|
|
|
if (ctx.measureText(test).width < canvasWidth - 30 * ratio) { |
|
|
|
test += rowPart[a]; |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
empty.push(test); |
|
|
|
var group = empty[0] + "..."//这里只显示两行,超出的用...表示
|
|
|
|
var group = empty[0] + "..." //这里只显示两行,超出的用...表示
|
|
|
|
rowCut.splice(1, 1, group); |
|
|
|
row = rowCut; |
|
|
|
} |
|
|
|
@ -602,7 +623,7 @@ Page({ |
|
|
|
cartImgInfo: 'top:' + res.top + 'px;left:' + res.left + 'px;' |
|
|
|
}) |
|
|
|
}).exec() |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
hideSku: function () { |
|
|
|
this.setData({ |
|
|
|
@ -644,8 +665,7 @@ Page({ |
|
|
|
this.setData({ |
|
|
|
isTest: app.globalData.configJson.isTest |
|
|
|
}) |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
setTimeout(() => { |
|
|
|
this.onReady() |
|
|
|
}, 300) |
|
|
|
@ -656,11 +676,11 @@ Page({ |
|
|
|
* 生命周期函数--监听页面显示 |
|
|
|
*/ |
|
|
|
onShow: function () { |
|
|
|
commonApi.user_post('cart/get_list', {}).then(res => { |
|
|
|
this.setData({ |
|
|
|
cartCount: res.data.length |
|
|
|
}) |
|
|
|
}) |
|
|
|
commonApi.user_post('cart/get_list', {}).then(res => { |
|
|
|
this.setData({ |
|
|
|
cartCount: res.data.length |
|
|
|
}) |
|
|
|
}) |
|
|
|
if (!wx.getStorageSync('jstrip_token')) { |
|
|
|
return; |
|
|
|
} |
|
|
|
@ -696,8 +716,7 @@ Page({ |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
setTimeout(() => { |
|
|
|
this.onShow() |
|
|
|
}, 200) |
|
|
|
@ -736,6 +755,5 @@ Page({ |
|
|
|
/** |
|
|
|
* 用户点击右上角分享 |
|
|
|
*/ |
|
|
|
onShareAppMessage: function () { |
|
|
|
} |
|
|
|
onShareAppMessage: function () {} |
|
|
|
}) |