C端小程序
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

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