C端小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

302 行
10 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 && app.globalData.type != 'sd') {
  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 == 'ra') {
  131. wx.redirectTo({
  132. url: `/pages/radetail/index?id=${that.data.optionData.id}`,
  133. })
  134. }
  135. // 门店详情
  136. else if (that.data.optionData.id && app.globalData.type == 'md') {
  137. wx.redirectTo({
  138. url: `/pages/index/searchbar/detail/index?id=${that.data.optionData.id}`
  139. });
  140. }
  141. // 通过分享进入的门店详情页面
  142. else if (that.data.id && that.data.frommd == 'md') {
  143. wx.redirectTo({
  144. url: `/pages/index/searchbar/detail/index?id=${that.data.id}`
  145. });
  146. } else if (that.data.optionData.bt && that.data.optionData.id && app.globalData.type == 'bd') {
  147. // 宣传页详情
  148. if (that.data.optionData.bt == '2') {
  149. // 自由图文
  150. wx.redirectTo({
  151. url: `/pages/freeBannerDetail/index?id=${that.data.optionData.id}`,
  152. })
  153. } else {
  154. // 标准格式
  155. wx.redirectTo({
  156. url: `/pages/bannerdetail/index?id=${that.data.optionData.id}`,
  157. })
  158. }
  159. } else if (that.data.orderId||that.data.orderId&&app.globalData.type=='bg') {
  160. // 参与砍价
  161. wx.navigateTo({
  162. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.orderId}`
  163. });
  164. } else if (app.globalData.type == 'uc') {
  165. // 我的
  166. wx.switchTab({
  167. url: '/pages/user/index'
  168. });
  169. } else if (app.globalData.type == 'in') {
  170. // 首页
  171. wx.switchTab({
  172. url: '/pages/main/index'
  173. });
  174. }
  175. // 积分
  176. else if (app.globalData.type == 'jf') {
  177. wx.redirectTo({
  178. url: '/pages/integralmall/index'
  179. });
  180. }else if (app.globalData.type == 'pc') {
  181. // 停车
  182. wx.switchTab({
  183. url: '/pages/passCar/passCar'
  184. });
  185. } else if (app.globalData.type == 'mc') {
  186. // 我的券包
  187. wx.redirectTo({
  188. url: '/pages/couponorder/index/index'
  189. });
  190. } else if (app.globalData.type == 'mo') {
  191. // 我的订单
  192. wx.redirectTo({
  193. url: '/pages/order/index/index?id=all'
  194. });
  195. } else if (app.globalData.type == 'ca') {
  196. // 我的卡包
  197. wx.redirectTo({
  198. url: '/pages/cardorder/index/index'
  199. });
  200. } else if (app.globalData.type == 'sc') {
  201. // 特享礼遇
  202. wx.redirectTo({
  203. url: '/pages/specialcourtesy/specialcourtesy'
  204. });
  205. } else if (app.globalData.type == 'rb') {
  206. // 限时秒杀
  207. wx.redirectTo({
  208. url: '/pages/rushToBuy/index'
  209. });
  210. } else if (app.globalData.type == 'bl') {
  211. // 砍价专场
  212. wx.redirectTo({
  213. url: '/pages/bargain/bargain'
  214. });
  215. } else if (app.globalData.type == 'mb') {
  216. // 我的砍价
  217. wx.redirectTo({
  218. url: '/pages/bargain/bargain?from=myhtml'
  219. });
  220. } else if (app.globalData.type == 'sl') {
  221. // 拼团专场
  222. wx.redirectTo({
  223. url: '/pages/spellGroup/spellGroup'
  224. });
  225. } else if (app.globalData.type == 'ms') {
  226. // 我的拼团
  227. wx.redirectTo({
  228. url: '/pages/spellGroup/spellGroup?from=myhtml'
  229. });
  230. } else if (app.globalData.type == 'dc') {
  231. // 消费卡
  232. wx.redirectTo({
  233. url: '/pages/discountCardList/discountCardList'
  234. });
  235. } else if (app.globalData.type == 'td') {
  236. // 专题活动页
  237. wx.redirectTo({
  238. url: '/pages/topicDetail/index'
  239. });
  240. }
  241. else if (app.globalData.type == 'ml') {
  242. // 门店
  243. wx.switchTab({
  244. url: '/pages/index/searchbar/index'
  245. });
  246. } else {
  247. wx.switchTab({
  248. url: "/pages/main/index"
  249. });
  250. }
  251. }
  252. },
  253. function (error) {
  254. console.log(error)
  255. wx.showToast({
  256. title: "请授权个人信息",
  257. icon: "none"
  258. });
  259. }
  260. )
  261. .catch(err => {
  262. wx.showToast({
  263. title: err.errMsg,
  264. icon: 'none',
  265. duration: 2000,
  266. mask: false
  267. });
  268. })
  269. },
  270. getGameOne: function (token, id) {
  271. let _this = this;
  272. Http.get({
  273. url: config.api.getOneGame,
  274. data: {
  275. token: token,
  276. id: id
  277. }
  278. }).then(res => {
  279. wx.redirectTo({
  280. url: '/pages/game/index?url=' + res.data.url + "&id=" + res.data.id + "&gameId=" + res.data.gameId,
  281. })
  282. })
  283. .catch(err => {
  284. wx.showModal({
  285. title: '提示',
  286. content: err.message,
  287. showCancel: false,
  288. success: function (res) {
  289. // 如果游戏下架或者找不到,重启首页
  290. if (res.confirm) {
  291. wx.reLaunch({
  292. url: '/pages/index/index',
  293. })
  294. }
  295. }
  296. })
  297. this.alphaClick();
  298. })
  299. },
  300. });