1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- const _Http = getApp().globalData.http;
- Component({
- properties: {},
- data: {
- item: null,
- show: false
- },
- methods: {
- onClick(item) {
- 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) {
- let data = s[0].data;
- if (!item.length || item.length == 0) item.length = data.type == '可选' ? data.rowsdetail[0].num : data.min - 0;
- arr.push(data)
- }
- if (item.widthschemeid) {
- let data = s[1].data;
- if (!item.width || item.width == 0) item.width = data.type == '可选' ? data.rowsdetail[0].num : data.min - 0;
- arr.push(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
- })
- },
- }
- })
|