|
@@ -0,0 +1,93 @@
|
|
|
+const _Http = getApp().globalData.http;
|
|
|
+Component({
|
|
|
+ properties: {},
|
|
|
+ data: {
|
|
|
+ item: null,
|
|
|
+ show: false
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ onClick(item) {
|
|
|
+ console.log(item)
|
|
|
+ console.log(this.data.product)
|
|
|
+ if (this.data.product != null && item.itemid == this.data.product.itemid) return this.setData({
|
|
|
+ show: true
|
|
|
+ })
|
|
|
+ wx.showLoading({
|
|
|
+ title: '获取定制方案中..',
|
|
|
+ })
|
|
|
+ let arr = [];
|
|
|
+ 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 => {
|
|
|
+ console.log("获取定制方案", s)
|
|
|
+ wx.hideLoading();
|
|
|
+ if (s.some(c => c.msg != '成功')) return wx.showToast({
|
|
|
+ title: '定制方案获取失败',
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ if (item.lengthschemeid) arr.push(s[0].data)
|
|
|
+ if (item.widthschemeid) arr.push(s[1].data)
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ show: true,
|
|
|
+ arr,
|
|
|
+ product: item
|
|
|
+ });
|
|
|
+ console.log("arr", arr, item)
|
|
|
+ });
|
|
|
+
|
|
|
+ this.selectComponent("#Dialog").data.beforeClose = (action) => new Promise((resolve) => {
|
|
|
+ if (action === 'confirm') {
|
|
|
+ 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
|
|
|
+ })
|
|
|
+ },
|
|
|
+ }
|
|
|
+})
|