C端小程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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