C端小程序
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

257 líneas
8.4 KiB

  1. var config = require("../../config/config.js");
  2. var app = getApp();
  3. const Http = require("../../utils/HttpBasics");
  4. Page({
  5. data: {
  6. canIUse: wx.canIUse("button.open-type.getUserInfo"),
  7. path:null,
  8. couponChannelId: null,
  9. cuserId:null,
  10. coverImg:null,
  11. couponOrderId:null,
  12. optionData:null
  13. },
  14. onLoad: function(options) {
  15. var that = this;
  16. if (options.couponChannelId && !options.cuserId||options.orderId) {
  17. that.setData({
  18. couponChannelId: options.couponChannelId,
  19. orderId:options.orderId
  20. })
  21. }
  22. that.setData({
  23. optionData: wx.getStorageSync('options') ? JSON.parse(wx.getStorageSync('options')):null
  24. })
  25. if (options&&options.path == 'index') {
  26. that.setData({
  27. path: options.path
  28. })
  29. }
  30. /**
  31. * 来自转赠
  32. */
  33. if (options.couponChannelId && options.cuserId){
  34. that.setData({
  35. couponChannelId: options.couponChannelId,
  36. cuserId: options.cuserId,
  37. coverImg: options.coverImg,
  38. userName: options.userName,
  39. avatarUrl: options.avatarUrl,
  40. couponOrderId: options.couponOrderId
  41. })
  42. }
  43. Http.get({
  44. url: config.api.marketicon,
  45. data: {
  46. appId: config.weapp.AppId
  47. }
  48. }).then(res => {
  49. that.setData({
  50. mallImgUrl: res.data.mallImgUrl
  51. });
  52. wx.setNavigationBarTitle({
  53. title: res.data.mallName
  54. })
  55. })
  56. .catch(err => {
  57. wx.showToast({
  58. title: err.errMsg,
  59. icon: 'none',
  60. duration: 2000,
  61. mask: false
  62. });
  63. })
  64. },
  65. bindGetUserInfo: function (e) {
  66. let that = this;
  67. var iv = e.detail.iv;
  68. var encryptedData = e.detail.encryptedData;
  69. Http.post({
  70. url: config.api.getUserInfo,
  71. data: {
  72. encryptedData: encryptedData,
  73. iv: iv
  74. }
  75. })
  76. .then(
  77. function (res) {
  78. if (that.data.optionData.orderGroupId){
  79. wx.reLaunch({
  80. url: `/pages/joinFrDpell/index?couponId=${that.data.optionData.couponId}&orderGroupId=${that.data.optionData.orderGroupId}&couponChannelId=${that.data.optionData.couponChannelId}&orderId=${that.data.optionData.orderId}&avatarUrl=${that.data.optionData.avatarUrl}&nickName=${that.data.optionData.nickName}`
  81. });
  82. return;
  83. }
  84. if (that.data.path == 'index') {
  85. wx.reLaunch({
  86. url: "/pages/game/index"
  87. });
  88. } else {
  89. //返回主页
  90. if (that.data.couponChannelId && !that.data.cuserId&&app.globalData.type == 'cd') {
  91. // 跳转普通券/消费卡/限时秒杀/砍价详情
  92. wx.navigateTo({
  93. url: `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}`
  94. });
  95. } else if (that.data.couponChannelId && that.data.cuserId) {
  96. // 来自转赠
  97. wx.reLaunch({
  98. url: `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}&cuserId=${that.data.cuserId}&coverImg=${that.data.coverImg}&userName=${that.data.userName}&avatarUrl=${that.data.avatarUrl}&couponOrderId=${that.data.couponOrderId}&updateDate=${that.data.updateDate}`
  99. });
  100. } else if (that.data.couponChannelId && app.globalData.type == 'sd') {
  101. // 拼团详情页
  102. wx.redirectTo({
  103. url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${that.data.couponChannelId}`,
  104. })
  105. } else if (that.data.optionData.id && app.globalData.type == 'gm') {
  106. // 游戏页面
  107. that.getGameOne(app.globalData.token, that.data.optionData.id)
  108. } else if (that.data.optionData.id && app.globalData.type == 'td') {
  109. wx.redirectTo({
  110. url: `/pages/topicDetail/index?id=${that.data.optionData.id}`
  111. });
  112. } else if (that.data.optionData.bt && that.data.optionData.id && app.globalData.type == 'bd') {
  113. // 宣传页详情
  114. if (that.data.optionData.bt == '2') {
  115. // 自由图文
  116. wx.redirectTo({
  117. url: `/pages/freeBannerDetail/index?id=${that.data.optionData.id}`,
  118. })
  119. } else {
  120. // 标准格式
  121. wx.redirectTo({
  122. url: `/pages/bannerdetail/index?id=${that.data.optionData.id}`,
  123. })
  124. }
  125. } else if (that.data.orderId&&app.globalData.type=='bg') {
  126. // 参与砍价
  127. wx.navigateTo({
  128. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.orderId}`
  129. });
  130. } else if (app.globalData.type == 'uc') {
  131. // 我的
  132. wx.switchTab({
  133. url: '/pages/user/index'
  134. });
  135. } else if (app.globalData.type == 'pc') {
  136. // 停车
  137. wx.switchTab({
  138. url: '/pages/passCar/passCar'
  139. });
  140. } else if (app.globalData.type == 'mc') {
  141. // 我的券包
  142. wx.redirectTo({
  143. url: '/pages/couponorder/index/index'
  144. });
  145. } else if (app.globalData.type == 'mo') {
  146. // 我的订单
  147. wx.redirectTo({
  148. url: '/pages/order/index/index?id=all'
  149. });
  150. } else if (app.globalData.type == 'ca') {
  151. // 我的卡包
  152. wx.redirectTo({
  153. url: '/pages/cardorder/index/index'
  154. });
  155. } else if (app.globalData.type == 'sc') {
  156. // 特享礼遇
  157. wx.redirectTo({
  158. url: '/pages/specialcourtesy/specialcourtesy'
  159. });
  160. } else if (app.globalData.type == 'rb') {
  161. // 限时秒杀
  162. wx.redirectTo({
  163. url: '/pages/rushToBuy/index'
  164. });
  165. } else if (app.globalData.type == 'bl') {
  166. // 砍价专场
  167. wx.redirectTo({
  168. url: '/pages/bargain/bargain'
  169. });
  170. } else if (app.globalData.type == 'mb') {
  171. // 我的砍价
  172. wx.redirectTo({
  173. url: '/pages/bargain/bargain?from=myhtml'
  174. });
  175. } else if (app.globalData.type == 'sl') {
  176. // 拼团专场
  177. wx.redirectTo({
  178. url: '/pages/spellGroup/spellGroup'
  179. });
  180. } else if (app.globalData.type == 'ms') {
  181. // 我的拼团
  182. wx.redirectTo({
  183. url: '/pages/spellGroup/spellGroup?from=myhtml'
  184. });
  185. } else if (app.globalData.type == 'dc') {
  186. // 消费卡
  187. wx.redirectTo({
  188. url: '/pages/discountCardList/discountCardList'
  189. });
  190. } else if (app.globalData.type == 'td') {
  191. // 专题活动页
  192. wx.redirectTo({
  193. url: '/pages/topicDetail/index'
  194. });
  195. }
  196. else if (app.globalData.type == 'ml') {
  197. // 门店
  198. wx.switchTab({
  199. url: '/pages/index/searchbar/index'
  200. });
  201. } else {
  202. wx.switchTab({
  203. url: "/pages/main/index"
  204. });
  205. }
  206. }
  207. },
  208. function (error) {
  209. console.log(error)
  210. wx.showToast({
  211. title: "请授权个人信息",
  212. icon: "none"
  213. });
  214. }
  215. )
  216. .catch(err => {
  217. wx.showToast({
  218. title: err.errMsg,
  219. icon: 'none',
  220. duration: 2000,
  221. mask: false
  222. });
  223. })
  224. },
  225. getGameOne: function (token, id) {
  226. let _this = this;
  227. Http.get({
  228. url: config.api.getOneGame,
  229. data: {
  230. token: token,
  231. id: id
  232. }
  233. }).then(res => {
  234. wx.redirectTo({
  235. url: '/pages/game/index?url=' + res.data.url + "&id=" + res.data.id + "&gameId=" + res.data.gameId,
  236. })
  237. })
  238. .catch(err => {
  239. wx.showModal({
  240. title: '提示',
  241. content: err.message,
  242. showCancel: false,
  243. success: function (res) {
  244. // 如果游戏下架或者找不到,重启首页
  245. if (res.confirm) {
  246. wx.reLaunch({
  247. url: '/pages/index/index',
  248. })
  249. }
  250. }
  251. })
  252. this.alphaClick();
  253. })
  254. },
  255. });