topic.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. var WxParse = require("./../../wxParse/wxParse.js");
  2. Page({
  3. data: {},
  4. onLoad: function (e) {
  5. getApp().page.onLoad(this, e);
  6. var t = this;
  7. if ("undefined" == typeof my) {
  8. var o = decodeURIComponent(e.scene);
  9. if (void 0 !== o) {
  10. var a = getApp().helper.scene_decode(o);
  11. a.uid && a.gid && (e.id = a.gid)
  12. }
  13. } else if (null !== getApp().query) {
  14. var i = app.query;
  15. getApp().query = null, e.id = i.gid
  16. }
  17. getApp().request({
  18. url: getApp().api.default.topic,
  19. data: {
  20. id: e.id
  21. },
  22. success: function (e) {
  23. 0 == e.code ? (t.setData(e.data), WxParse.wxParse("content", "html", e.data.content, t)) : getApp().core.showModal({
  24. title: "提示",
  25. content: e.msg,
  26. showCancel: !1,
  27. success: function (e) {
  28. e.confirm && getApp().core.redirectTo({
  29. url: "/pages/index/index"
  30. })
  31. }
  32. })
  33. }
  34. })
  35. },
  36. wxParseTagATap: function (e) {
  37. var t = e.currentTarget.dataset.src || !1;
  38. if (!t) return;
  39. getApp().core.navigateTo({
  40. url: t
  41. })
  42. },
  43. quickNavigation: function () {
  44. this.setData({
  45. quick_icon: !this.data.quick_icon
  46. });
  47. var e = getApp().core.createAnimation({
  48. duration: 300,
  49. timingFunction: "ease-out"
  50. });
  51. this.data.quick_icon ? e.opacity(0).step() : e.translateY(-55).opacity(1).step(), this.setData({
  52. animationPlus: e.export()
  53. })
  54. },
  55. favoriteClick: function (e) {
  56. var t = this,
  57. o = e.currentTarget.dataset.action;
  58. getApp().request({
  59. url: getApp().api.user.topic_favorite,
  60. data: {
  61. topic_id: t.data.id,
  62. action: o
  63. },
  64. success: function (e) {
  65. getApp().core.showToast({
  66. title: e.msg
  67. }), 0 == e.code && t.setData({
  68. is_favorite: o
  69. })
  70. }
  71. })
  72. },
  73. onShow: function () {
  74. getApp().page.onShow(this)
  75. },
  76. onShareAppMessage: function () {
  77. getApp().page.onShareAppMessage(this);
  78. var e = getApp().getUser(),
  79. t = this.data.id;
  80. return {
  81. title: this.data.title,
  82. path: "/pages/topic/topic?id=" + t + "&user_id=" + e.id
  83. }
  84. },
  85. showShareModal: function () {
  86. this.setData({
  87. share_modal_active: "active"
  88. })
  89. },
  90. shareModalClose: function () {
  91. this.setData({
  92. share_modal_active: ""
  93. })
  94. },
  95. getGoodsQrcode: function () {
  96. var t = this;
  97. if (t.setData({
  98. qrcode_active: "active",
  99. share_modal_active: ""
  100. }), t.data.goods_qrcode) return !0;
  101. getApp().request({
  102. url: getApp().api.default.topic_qrcode,
  103. data: {
  104. goods_id: t.data.id
  105. },
  106. success: function (e) {
  107. 0 == e.code && t.setData({
  108. goods_qrcode: e.data.pic_url
  109. }), 1 == e.code && (t.goodsQrcodeClose(), getApp().core.showModal({
  110. title: "提示",
  111. content: e.msg,
  112. showCancel: !1,
  113. success: function (e) {
  114. e.confirm
  115. }
  116. }))
  117. }
  118. })
  119. },
  120. qrcodeClick: function (e) {
  121. var t = e.currentTarget.dataset.src;
  122. getApp().core.previewImage({
  123. urls: [t]
  124. })
  125. },
  126. qrcodeClose: function () {
  127. this.setData({
  128. qrcode_active: ""
  129. })
  130. },
  131. goodsQrcodeClose: function () {
  132. this.setData({
  133. goods_qrcode_active: "",
  134. no_scroll: !1
  135. })
  136. },
  137. saveQrcode: function () {
  138. var t = this;
  139. getApp().core.saveImageToPhotosAlbum ? (getApp().core.showLoading({
  140. title: "正在保存图片",
  141. mask: !1
  142. }), getApp().core.downloadFile({
  143. url: t.data.goods_qrcode,
  144. success: function (e) {
  145. getApp().core.showLoading({
  146. title: "正在保存图片",
  147. mask: !1
  148. }), getApp().core.saveImageToPhotosAlbum({
  149. filePath: e.tempFilePath,
  150. success: function () {
  151. getApp().core.showModal({
  152. title: "提示",
  153. content: "专题海报保存成功",
  154. showCancel: !1
  155. })
  156. },
  157. fail: function (e) {
  158. getApp().core.showModal({
  159. title: "图片保存失败",
  160. content: e.errMsg,
  161. showCancel: !1
  162. })
  163. },
  164. complete: function (e) {
  165. getApp().core.hideLoading()
  166. }
  167. })
  168. },
  169. fail: function (e) {
  170. getApp().core.showModal({
  171. title: "图片下载失败",
  172. content: e.errMsg + ";" + t.data.goods_qrcode,
  173. showCancel: !1
  174. })
  175. },
  176. complete: function (e) {
  177. getApp().core.hideLoading()
  178. }
  179. })) : getApp().core.showModal({
  180. title: "提示",
  181. content: "当前版本过低,无法使用该功能,请升级到最新版本后重试。",
  182. showCancel: !1
  183. })
  184. }
  185. });