custom.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. let count = setInterval(() => {
  46. if (custom != 'wait') {
  47. if (typeof custom == "boolean") return resolve(false);
  48. getApp().globalData.customizedProduct(item, custom).then(res => resolve(true))
  49. clearInterval(count)
  50. } else {
  51. custom = this.selectComponent("#customMade").getResult(true);
  52. }
  53. }, 100);
  54. } else {
  55. resolve(false);
  56. this.setData({
  57. show: false
  58. })
  59. }
  60. });
  61. }
  62. }
  63. })