|
@@ -27,6 +27,26 @@ Page({
|
|
|
idname: options.idname || this.data.idname
|
|
|
});
|
|
|
this.getList()
|
|
|
+ getApp().globalData.customizedProduct = this.customizedProduct.bind(this);
|
|
|
+ },
|
|
|
+ customization(e) {
|
|
|
+ let {
|
|
|
+ item
|
|
|
+ } = e.target.dataset;
|
|
|
+ item.pitchOn = false;
|
|
|
+ if (item) this.selectComponent("#Custom").onClick(item)
|
|
|
+ },
|
|
|
+ customizedProduct(item) {
|
|
|
+ return new Promise((resolve) => {
|
|
|
+ let index = this.data.list.findIndex(v => v[this.data.idname] == item[this.data.idname]);
|
|
|
+ if (index != -1) this.data.list[index] = item;
|
|
|
+ if (item.pitchOn) this.data.result.push(item[this.data.idname])
|
|
|
+ this.setData({
|
|
|
+ list: this.data.list,
|
|
|
+ result: this.data.result
|
|
|
+ })
|
|
|
+ resolve(true)
|
|
|
+ })
|
|
|
},
|
|
|
getList(init = false) {
|
|
|
//init 用于初始化分页
|
|
@@ -73,15 +93,34 @@ Page({
|
|
|
},
|
|
|
/* 选中 */
|
|
|
changeResult(e) {
|
|
|
- if (e.target.dataset.iscatch) return;
|
|
|
let {
|
|
|
- id
|
|
|
+ id,
|
|
|
+ item
|
|
|
} = e.currentTarget.dataset, result = this.data.result;
|
|
|
- result.some(v => v == id) ? result = result.filter(v => v != id) : result.push(id)
|
|
|
+ if (this.data.radio) {
|
|
|
+ result = [id];
|
|
|
+ } else {
|
|
|
+ let isAdd = result.some(v => v == id);
|
|
|
+ if (!isAdd) {
|
|
|
+ if (item.iscustomsize == 1) {
|
|
|
+ if ((item.widthschemeid && !item.width) || (item.lengthschemeid && !item.length)) {
|
|
|
+ item.pitchOn = true;
|
|
|
+ if (item) this.selectComponent("#Custom").onClick(item)
|
|
|
+ } else {
|
|
|
+ result.push(id)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ result.push(id)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ result = result.filter(v => v != id)
|
|
|
+ }
|
|
|
+ }
|
|
|
this.setData({
|
|
|
result
|
|
|
});
|
|
|
},
|
|
|
+
|
|
|
/* 提交 */
|
|
|
submit() {
|
|
|
let result = this.data.result,
|