const _Http = getApp().globalData.http; Component({ properties: { isOldPrice: { type: Boolean } }, data: { item: null, show: false }, methods: { onClick(item) { console.log(item) if (this.data.product != null && item.itemid == this.data.product.itemid) return this.setData({ show: true }) wx.showLoading({ title: '获取定制方案中..', }) Promise.all([{ "id": "20230707091603", "version": 1, "content": { "sa_sizecustomizedschemeid": item.lengthschemeid, date: Date.now() } }, { "id": "20230707091603", "version": 1, "content": { "sa_sizecustomizedschemeid": item.widthschemeid, date: Date.now() + 2 } }].map(v => _Http.basic(v))).then(s => { console.log("获取定制方案", s) wx.hideLoading(); if (s.some(c => c.msg != '成功')) return wx.showToast({ title: '定制方案获取失败', icon: "none" }) s[0].data.name = '长度' if (!item.length) item.length = s[0].data.type == '可选' ? s[0].data.rowsdetail[0].num : s[0].data.min - 0; console.log("长度id", item.lengthschemeid, '长:' + item.length, '结果:', s[0].data.sa_sizecustomizedschemeid) s[1].data.name = '宽度' if (!item.width) item.width = s[1].data.type == '可选' ? s[1].data.rowsdetail[0].num : s[1].data.min - 0; console.log("宽度id", item.widthschemeid, '宽:' + item.width, '结果:', s[1].data.sa_sizecustomizedschemeid) this.setData({ show: true, arr: [s[0].data, s[1].data], product: item }); }); this.selectComponent("#Dialog").data.beforeClose = (action) => new Promise((resolve) => { if (action === 'confirm') { //getItem(this.data.product, this.data.isOldPrice ? "oldprice" : "") getApp().globalData.customizedProduct(this.data.product).then(res => { resolve(true); }) } else { resolve(false); this.setData({ show: false }) } }); }, selected(e) { const { name, num } = e.currentTarget.dataset; this.data.product[name] = num; this.setData({ product: this.data.product }) }, /* 定制步进器 */ cahngeStepper(e) { const { name, item } = e.currentTarget.dataset, product = this.data.product; if (e.type == 'plus') { product[name] += 1 } else if (e.type == 'minus') { product[name] -= 1 } else { product[name] = (e.detail.value - 0).toFixed(product.decimalplaces); } if (product[name] > item.max) product[name] = item.max; if (product[name] < item.min) product[name] = item.min; this.setData({ product }) } } })