goods_info.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. module.exports = {
  2. currentPage: null,
  3. init: function(o) {
  4. var e = this;
  5. void 0 === (e.currentPage = o).showShareModal && (o.showShareModal = function(o) {
  6. e.showShareModal(o)
  7. }), void 0 === o.shareModalClose && (o.shareModalClose = function(o) {
  8. e.shareModalClose(o)
  9. }), void 0 === o.getGoodsQrcode && (o.getGoodsQrcode = function(o) {
  10. e.getGoodsQrcode(o)
  11. }), void 0 === o.goodsQrcodeClose && (o.goodsQrcodeClose = function(o) {
  12. e.goodsQrcodeClose(o)
  13. }), void 0 === o.saveGoodsQrcode && (o.saveGoodsQrcode = function(o) {
  14. e.saveGoodsQrcode(o)
  15. }), void 0 === o.goodsQrcodeClick && (o.goodsQrcodeClick = function(o) {
  16. e.goodsQrcodeClick(o)
  17. })
  18. },
  19. showShareModal: function() {
  20. this.currentPage.setData({
  21. share_modal_active: "active",
  22. no_scroll: !0
  23. })
  24. },
  25. shareModalClose: function() {
  26. this.currentPage.setData({
  27. share_modal_active: "",
  28. no_scroll: !1
  29. })
  30. },
  31. getGoodsQrcode: function() {
  32. var e = this.currentPage;
  33. if (e.setData({
  34. goods_qrcode_active: "active",
  35. share_modal_active: ""
  36. }), e.data.goods_qrcode) return !0;
  37. var o = "",
  38. t = e.data.pageType;
  39. if ("PINTUAN" === t) o = getApp().api.group.goods_qrcode;
  40. else if ("BOOK" === t) o = getApp().api.book.goods_qrcode;
  41. else if ("STORE" === t) o = getApp().api.default.goods_qrcode;
  42. else {
  43. if ("MIAOSHA" !== t) return void getApp().core.showModal({
  44. title: "提示",
  45. content: "pageType未定义或组件js未进行判断"
  46. });
  47. o = getApp().api.miaosha.goods_qrcode
  48. }
  49. getApp().request({
  50. url: o,
  51. data: {
  52. goods_id: e.data.id
  53. },
  54. success: function(o) {
  55. 0 == o.code && e.setData({
  56. goods_qrcode: o.data.pic_url
  57. }), 1 == o.code && (e.goodsQrcodeClose(), getApp().core.showModal({
  58. title: "提示",
  59. content: o.msg,
  60. showCancel: !1,
  61. success: function(o) {
  62. o.confirm
  63. }
  64. }))
  65. }
  66. })
  67. },
  68. goodsQrcodeClose: function() {
  69. this.currentPage.setData({
  70. goods_qrcode_active: "",
  71. no_scroll: !1
  72. })
  73. },
  74. saveGoodsQrcode: function() {
  75. var e = this.currentPage;
  76. getApp().core.saveImageToPhotosAlbum ? (getApp().core.showLoading({
  77. title: "正在保存图片",
  78. mask: !1
  79. }), getApp().core.downloadFile({
  80. url: e.data.goods_qrcode,
  81. success: function(o) {
  82. getApp().core.showLoading({
  83. title: "正在保存图片",
  84. mask: !1
  85. }), getApp().core.saveImageToPhotosAlbum({
  86. filePath: o.tempFilePath,
  87. success: function() {
  88. getApp().core.showModal({
  89. title: "提示",
  90. content: "商品海报保存成功",
  91. showCancel: !1
  92. })
  93. },
  94. fail: function(o) {
  95. getApp().core.showModal({
  96. title: "图片保存失败",
  97. content: o.errMsg,
  98. showCancel: !1
  99. })
  100. },
  101. complete: function(o) {
  102. getApp().core.hideLoading()
  103. }
  104. })
  105. },
  106. fail: function(o) {
  107. getApp().core.showModal({
  108. title: "图片下载失败",
  109. content: o.errMsg + ";" + e.data.goods_qrcode,
  110. showCancel: !1
  111. })
  112. },
  113. complete: function(o) {
  114. getApp().core.hideLoading()
  115. }
  116. })) : getApp().core.showModal({
  117. title: "提示",
  118. content: "当前版本过低,无法使用该功能,请升级到最新版本后重试。",
  119. showCancel: !1
  120. })
  121. },
  122. goodsQrcodeClick: function(o) {
  123. var e = o.currentTarget.dataset.src;
  124. getApp().core.previewImage({
  125. urls: [e]
  126. })
  127. }
  128. };