custom.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. properties: {
  4. isOldPrice: {
  5. type: Boolean
  6. }
  7. },
  8. data: {
  9. item: null,
  10. show: false
  11. },
  12. methods: {
  13. onClick(item) {
  14. if (this.data.product != null && item.itemid == this.data.product.itemid) return this.setData({
  15. show: true
  16. })
  17. wx.showLoading({
  18. title: '获取定制方案中..',
  19. })
  20. this.selectComponent("#customMade").init(item).then(res => {
  21. wx.hideLoading();
  22. if (res) {
  23. this.setData({
  24. show: true
  25. })
  26. } else {
  27. wx.showToast({
  28. title: '未获取到定制方案',
  29. icon: "none"
  30. })
  31. }
  32. })
  33. this.selectComponent("#Dialog").data.beforeClose = (action) => new Promise((resolve) => {
  34. if (action === 'confirm') {
  35. let custom = {
  36. length: 0,
  37. width: 0
  38. };
  39. //是否为定制项
  40. custom = this.selectComponent("#customMade").getResult(true);
  41. if (typeof custom == "boolean") return resolve(false);
  42. getApp().globalData.customizedProduct(item, custom).then(res => resolve(true))
  43. } else {
  44. resolve(false);
  45. this.setData({
  46. show: false
  47. })
  48. }
  49. });
  50. }
  51. }
  52. })