|
@@ -8,7 +8,7 @@ import currency from "../../utils/currency";
|
|
|
|
|
|
Page({
|
|
|
data: {
|
|
|
- hidePrice: wx.getStorageSync('hidePrice'),
|
|
|
+ hidePrice: wx.getStorageSync('hidePrice'),
|
|
|
badge: getApp().globalData.collectCount,
|
|
|
loading: true,
|
|
|
content: {
|
|
@@ -17,7 +17,14 @@ Page({
|
|
|
color: "", //颜色
|
|
|
material: "", //材质
|
|
|
cheek: "", //边框
|
|
|
- }
|
|
|
+ dwidth: 0,
|
|
|
+ dlength: 0,
|
|
|
+ },
|
|
|
+ detail: {
|
|
|
+ spec: ""
|
|
|
+ },
|
|
|
+ cWidth: null, //宽定制方案
|
|
|
+ cLength: null, //长定制方案
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
let data = JSON.parse(options.params);
|
|
@@ -48,22 +55,63 @@ Page({
|
|
|
icon: "none",
|
|
|
mask: true
|
|
|
})
|
|
|
- this.handleFiles(res.data.item[0].attinfos)
|
|
|
+ const item = res.data.item[0];
|
|
|
+ this.handleFiles(item.attinfos)
|
|
|
const CNY = sum => currency(sum, {
|
|
|
symbol: "¥",
|
|
|
precision: 2
|
|
|
}).format();
|
|
|
- res.data.item[0].gradeprice = CNY(res.data.item[0].gradeprice);
|
|
|
- res.data.item[0].marketprice = CNY(res.data.item[0].marketprice);
|
|
|
+ item.gradeprice = CNY(item.gradeprice);
|
|
|
+ item.marketprice = CNY(item.marketprice);
|
|
|
this.setData({
|
|
|
content,
|
|
|
- detail: res.data.item[0],
|
|
|
+ detail: item,
|
|
|
specRows: res.data.specRows,
|
|
|
cheekRows: res.data.cheekRows,
|
|
|
materialRows: res.data.materialRows,
|
|
|
colorRows: res.data.colorRows,
|
|
|
loading: false
|
|
|
});
|
|
|
+ //是否定制
|
|
|
+ if (init) {
|
|
|
+ if (item.iscustomsize == 1) {
|
|
|
+ let cWidth = null,
|
|
|
+ cLength = null;
|
|
|
+ Promise.all([{
|
|
|
+ "id": "20230707091603",
|
|
|
+ "version": 1,
|
|
|
+ "content": {
|
|
|
+ "sa_sizecustomizedschemeid": item.lengthschemeid
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ "id": "20230707091603",
|
|
|
+ "version": 1,
|
|
|
+ "content": {
|
|
|
+ "sa_sizecustomizedschemeid": item.widthschemeid
|
|
|
+ }
|
|
|
+ }].map(v => _Http.basic(v))).then(s => {
|
|
|
+ if (s.some(c => c.msg != '成功')) return wx.showToast({
|
|
|
+ title: '定制方案获取失败',
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ if (item.lengthschemeid) cLength = s[0].data;
|
|
|
+ if (item.widthschemeid) cWidth = s[1].data;
|
|
|
+ this.setData({
|
|
|
+ cWidth,
|
|
|
+ cLength,
|
|
|
+ "content.dwidth": cWidth.min || 0,
|
|
|
+ "content.dlength": cLength.min || 0,
|
|
|
+ });
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ cWidth: null,
|
|
|
+ cLength: null,
|
|
|
+ "content.dwidth": 0,
|
|
|
+ "content.dlength": 0,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
/* 预览媒体 */
|
|
@@ -115,7 +163,6 @@ Page({
|
|
|
},
|
|
|
/* 切换产品 */
|
|
|
changeItemno(e) {
|
|
|
- console.log("切换产品", e.currentTarget.dataset)
|
|
|
const {
|
|
|
value,
|
|
|
valuename
|
|
@@ -127,7 +174,35 @@ Page({
|
|
|
mask: true
|
|
|
})
|
|
|
content[valuename] = (content[valuename] == value.parm) ? "" : value.parm;
|
|
|
- this.getDetail()
|
|
|
+ this.getDetail(valuename == "spec")
|
|
|
+ },
|
|
|
+ /* 定制选项 */
|
|
|
+ customParameter(e) {
|
|
|
+ let {
|
|
|
+ value,
|
|
|
+ valuename
|
|
|
+ } = e.currentTarget.dataset;
|
|
|
+ this.data.content[valuename] = value;
|
|
|
+ this.setData({
|
|
|
+ content: this.data.content
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 定制步进器 */
|
|
|
+ cahngeStepper(e) {
|
|
|
+ const name = e.currentTarget.dataset.name,
|
|
|
+ name2 = name == 'cWidth' ? "dwidth" : "dlength",
|
|
|
+ content = this.data.content;
|
|
|
+ if (e.type == 'plus') {
|
|
|
+ content[name2] += 1
|
|
|
+ } else if (e.type == 'minus') {
|
|
|
+ content[name2] -= 1
|
|
|
+ } else {
|
|
|
+ const data = this.data[name];
|
|
|
+ content[name2] = (e.detail.value - 0).toFixed(data.decimalplaces);
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ content
|
|
|
+ })
|
|
|
},
|
|
|
clickBut() {
|
|
|
this.data.detail.tradefield.length >= 2 ? wx.showToast({
|
|
@@ -183,7 +258,18 @@ Page({
|
|
|
this.handleStorage(e.detail.value)
|
|
|
},
|
|
|
handleStorage(index) {
|
|
|
- let detail = this.data.detail;
|
|
|
+ let detail = this.data.detail,
|
|
|
+ content = this.data.content;
|
|
|
+ if (detail.iscustomsize == 1) {
|
|
|
+ if (detail.widthschemeid != 0 && content.dwidth == 0) return wx.showToast({
|
|
|
+ title: '请完成定制宽选项',
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ if (detail.lengthschemeid != 0 && content.dlength == 0) return wx.showToast({
|
|
|
+ title: '请完成定制长选项',
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ }
|
|
|
_Http.basic({
|
|
|
"id": 20220924095102,
|
|
|
"content": {
|
|
@@ -191,7 +277,9 @@ Page({
|
|
|
"itemid": detail.itemid, //货品id
|
|
|
"qty": detail.orderminqty, //数量
|
|
|
itemno: detail.itemno, //货品编号
|
|
|
- tradefield: detail.tradefield[index].tradefield
|
|
|
+ tradefield: detail.tradefield[index].tradefield,
|
|
|
+ width: content.dwidth,
|
|
|
+ length: content.dlength
|
|
|
},
|
|
|
}).then(res => {
|
|
|
console.log("加入购物车", res)
|
|
@@ -206,7 +294,9 @@ Page({
|
|
|
},
|
|
|
/* 前往购物车 */
|
|
|
toCollect(e) {
|
|
|
- getApp().globalData.changeBar({detail:"Collect"})
|
|
|
+ getApp().globalData.changeBar({
|
|
|
+ detail: "Collect"
|
|
|
+ })
|
|
|
wx.navigateBack();
|
|
|
}
|
|
|
})
|