custom.js 1.4 KB

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