C端小程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

588 строки
19 KiB

  1. const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
  2. const Http = require("../../utils/HttpBasics");
  3. const imgurl = require("../../utils/imgurl");
  4. const config = require("../../config/config");
  5. let app = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function(options) {
  16. console.log("我是中转页面")
  17. let that = this;
  18. console.log(options);
  19. wx.showToast({
  20. title: '加载中...',
  21. icon: "loading",
  22. duration: 2000
  23. })
  24. /**
  25. * 根据接收到的参数的值,判断跳转到哪个页面
  26. */
  27. if (options && options.type) {
  28. app.globalData.type = options.type;
  29. }
  30. if (decodeURIComponent(options.scene) == "undefined") {
  31. that.setData({
  32. scene: 0
  33. })
  34. app.globalData.scene = 0;
  35. } else {
  36. that.setData({
  37. scene: decodeURIComponent(options.scene)
  38. });
  39. app.globalData.scene = decodeURIComponent(options.scene)
  40. that.setData({
  41. newArr: this.data.scene.split(':')
  42. })
  43. //// 大屏-二维码-start
  44. if (this.data.newArr[0] == 'JC') {
  45. // 跳转券详情
  46. options.couponChannelId = this.data.newArr[1];
  47. } else if (this.data.newArr[0] == 'JG') {
  48. // 跳转拼团详情
  49. options.couponChannelId = this.data.newArr[1];
  50. options.path = 'daping'
  51. } else if (this.data.newArr[0] == 't') {
  52. // 普通二维码
  53. options.type = this.data.newArr[1];
  54. app.globalData.type = options.type;
  55. if (options.type == 'cd') {
  56. options.couponChannelId = this.data.newArr[2];
  57. } else if (options.type == 'bd') {
  58. options.bt = this.data.newArr[2];
  59. options.id = this.data.newArr[3];
  60. } else if (options.type == 'gm') {
  61. options.id = this.data.newArr[2];
  62. } else if (options.type == 'sd') {
  63. options.couponChannelId = this.data.newArr[2];
  64. } else if (options.type == 'td') {
  65. // 专题活动页
  66. options.id = this.data.newArr[2];
  67. } else if (options.type == 'md') {
  68. // 门店详情
  69. options.id = this.data.newArr[2];
  70. } else if (options.type == 'ra') {
  71. //活动详情
  72. options.id = this.data.newArr[2];
  73. } else if (options.type == 'si') {
  74. //活动签到
  75. options.id = this.data.newArr[2];
  76. } else if (options.type == 'wj') {
  77. options.id = this.data.newArr[2];
  78. } else if (options.type == 'ts') {
  79. options.id = this.data.newArr[2];
  80. }
  81. }
  82. }
  83. wx.setStorageSync('options', JSON.stringify(options))
  84. wx.setStorageSync('imgurl', imgurl);
  85. if (app.globalData.token) {
  86. this.updateUserInfo();
  87. if (options.couponChannelId || options.orderId || options.id) {
  88. that.userStatus(options);
  89. } else {
  90. that.userStatus();
  91. }
  92. } else {
  93. // 由于 token 是网络请求,可能会在 Page.onLoad 之后才返回
  94. // 所以此处加入 callback 以防止这种情况
  95. app.tokenCallback = token => {
  96. this.updateUserInfo();
  97. if (options.couponChannelId || options.orderId || options.id) {
  98. that.userStatus(options);
  99. } else {
  100. that.userStatus();
  101. }
  102. }
  103. }
  104. },
  105. /**
  106. * 检查用户的状态
  107. */
  108. userStatus: function(options) {
  109. var that = this;
  110. if (options && (options.couponChannelId || options.orderId || options.id)) {
  111. that.checkuserstatus(options);
  112. } else {
  113. that.checkuserstatus();
  114. }
  115. },
  116. /**
  117. * 获取手机信息
  118. */
  119. updateUserInfo() {
  120. wx.getSystemInfo({
  121. success: function (res) {
  122. Http.post({
  123. url: config.api.updateUserInfo,
  124. data: {
  125. systemInfo: JSON.stringify(res)
  126. }
  127. }).then(res => {
  128. console.log(res)
  129. })
  130. }
  131. })
  132. },
  133. checkuserstatus(options) {
  134. let that = this;
  135. Http.get({
  136. url: config.api.checkUserStatus,
  137. data: {
  138. token: app.globalData.token
  139. }
  140. })
  141. .then(res => {
  142. // res = JSON.parse('{"code":11004,"message":"用户昵称未授权,请跳转到用户昵称授权页!","data":{}}')
  143. //参与拼团
  144. if (options && options.orderGroupId) {
  145. wx.redirectTo({
  146. url: `/pages/joinFrDpell/index?couponId=${options.couponId}&orderGroupId=${options.orderGroupId}&couponChannelId=${options.couponChannelId}&orderId=${options.orderId}&avatarUrl=${options.avatarUrl}&nickName=${options.nickName}`
  147. })
  148. }
  149. //来自大屏的跳转拼团券详情
  150. else if (options && options.couponChannelId && options.path == 'daping') {
  151. /**
  152. * 主要是为了拿couponId
  153. */
  154. Http.get({
  155. url: config.api.couponDetail,
  156. data: {
  157. couponChannelId: options.couponChannelId
  158. }
  159. }).then(res => {
  160. let data = res.data;
  161. wx.redirectTo({
  162. url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${options.couponChannelId}&couponId=${data.couponId}`
  163. })
  164. })
  165. } else if (options && options.couponChannelId && !options.spellGroup && app.globalData.type != 'sd') {
  166. console.log(3333333333333333)
  167. // 转赠判断
  168. if (options.cuserId) {
  169. wx.redirectTo({
  170. url: `/pages/coupon/detail/index?couponChannelId=${options.couponChannelId}&cuserId=${options.cuserId}&coverImg=${options.coverImg}&userName=${options.userName}&avatarUrl=${options.avatarUrl}&couponOrderId=${options.couponOrderId}&updateDate=${options.updateDate}`,
  171. })
  172. } else {
  173. // 跳转普通券/消费卡/限时秒杀/砍价详情
  174. wx.redirectTo({
  175. url: `/pages/coupon/detail/index?couponChannelId=${options.couponChannelId}`,
  176. })
  177. }
  178. }
  179. // 拼团详情页(只有通过扫码进入才可能进入拼团详情页面,只有这一个入口)
  180. else if ((options && options.couponChannelId && app.globalData.type == 'sd') || (options && options.couponChannelId && options.spellGroup)) {
  181. wx.redirectTo({
  182. url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${options.couponChannelId}`,
  183. })
  184. }
  185. // 游戏页面
  186. else if (options && options.id && app.globalData.type == 'gm') {
  187. that.getGameOne(app.globalData.token, options.id)
  188. }
  189. // 报名活动页面
  190. else if (options && options.id && app.globalData.type == 'ra') {
  191. wx.redirectTo({
  192. url: `/pages/radetail/index?id=${options.id}`,
  193. })
  194. }
  195. //活动签到
  196. else if (options && options.id && app.globalData.type == 'si') {
  197. wx.redirectTo({
  198. url: `/pages/acSignIn/index?id=${options.id}`,
  199. })
  200. }
  201. //答题问卷
  202. else if (options && options.id && app.globalData.type == 'wj') {
  203. wx.redirectTo({
  204. url: `/pages/questionnaire/questionnaire?id=${options.id}`,
  205. })
  206. }
  207. //投诉建议
  208. else if (app.globalData.type == 'ts') {
  209. wx.redirectTo({
  210. url: `/pages/complaint/complaint`,
  211. })
  212. }
  213. // 宣传页详情
  214. else if (options && options.bt && options.id && app.globalData.type == 'bd') {
  215. if (options.bt == '2') {
  216. // 自由图文
  217. wx.redirectTo({
  218. url: `/pages/freeBannerDetail/index?id=${options.id}`,
  219. })
  220. } else {
  221. // 标准格式
  222. wx.redirectTo({
  223. url: `/pages/bannerdetail/index?id=${options.id}`,
  224. })
  225. }
  226. }
  227. // 专题
  228. else if (options && options.id && app.globalData.type == 'td') {
  229. wx.redirectTo({
  230. url: `/pages/topicDetail/index?id=${options.id}`
  231. });
  232. }
  233. // 门店详情
  234. else if (options && options.id && app.globalData.type == 'md') {
  235. wx.redirectTo({
  236. url: `/pages/index/searchbar/detail/index?id=${options.id}`
  237. });
  238. }
  239. // 参与砍价
  240. else if (options && options.orderId) {
  241. wx.redirectTo({
  242. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${options.orderId}&from=${"discount"}&composeOrderType=${options.composeOrderType}`,
  243. })
  244. }
  245. // 我的
  246. else if (app.globalData.type == 'uc') {
  247. wx.switchTab({
  248. url: '/index/user'
  249. });
  250. }
  251. // 积分
  252. else if (app.globalData.type == 'jf') {
  253. wx.redirectTo({
  254. url: '/pages/integralmall/index'
  255. });
  256. }
  257. // 首页
  258. else if (app.globalData.type == 'in') {
  259. wx.switchTab({
  260. url: app.globalData.goHomeUrl
  261. });
  262. }
  263. // 停车
  264. else if (app.globalData.type == 'pc') {
  265. // 停车
  266. wx.switchTab({
  267. url: '/index/passCar'
  268. });
  269. }
  270. // 我的券包
  271. else if (app.globalData.type == 'mc') {
  272. // 我的券包
  273. wx.redirectTo({
  274. url: '/pages/couponorder/index/index'
  275. });
  276. }
  277. // 我的订单
  278. else if (app.globalData.type == 'mo') {
  279. // 我的订单
  280. wx.redirectTo({
  281. url: '/pages/order/index/index?id=all'
  282. });
  283. }
  284. // 我的卡包
  285. else if (app.globalData.type == 'ca') {
  286. // 我的卡包
  287. wx.redirectTo({
  288. url: '/pages/cardorder/index/index'
  289. });
  290. }
  291. // 特享礼遇
  292. else if (app.globalData.type == 'sc') {
  293. // 特享礼遇
  294. wx.redirectTo({
  295. url: '/pages/specialcourtesy/specialcourtesy'
  296. });
  297. }
  298. // 限时秒杀
  299. else if (app.globalData.type == 'rb') {
  300. // 限时秒杀
  301. wx.redirectTo({
  302. url: '/pages/rushToBuy/index'
  303. })
  304. }
  305. // 砍价专场
  306. else if (app.globalData.type == 'bl') {
  307. // 砍价专场
  308. wx.redirectTo({
  309. url: '/pages/bargain/bargain'
  310. })
  311. }
  312. // 我的砍价
  313. else if (app.globalData.type == 'mb') {
  314. // 我的砍价
  315. wx.redirectTo({
  316. url: '/pages/bargain/bargain?from=myhtml'
  317. })
  318. }
  319. // 拼团专场
  320. else if (app.globalData.type == 'sl') {
  321. // 拼团专场
  322. wx.redirectTo({
  323. url: '/pages/spellGroup/spellGroup'
  324. })
  325. }
  326. // 我的拼团
  327. else if (app.globalData.type == 'ms') {
  328. // 我的拼团
  329. wx.redirectTo({
  330. url: '/pages/spellGroup/spellGroup?from=myhtml'
  331. })
  332. }
  333. // 消费卡
  334. else if (app.globalData.type == 'dc') {
  335. // 消费卡
  336. wx.redirectTo({
  337. url: '/pages/discountCardList/discountCardList'
  338. })
  339. }
  340. //直播
  341. else if (app.globalData.type == 'zb') {
  342. wx.redirectTo({
  343. url: `/pages2/live/livelist/index`
  344. });
  345. }
  346. //活动日历
  347. else if (app.globalData.type == 'arl') {
  348. wx.redirectTo({
  349. url: `/pages/dateLsit/dateLsit`
  350. });
  351. }
  352. //每日签到
  353. else if (app.globalData.type == 'qd') {
  354. wx.redirectTo({
  355. url: `/pages/activityCalendar/activityCalendar`
  356. });
  357. }
  358. // 门店
  359. else if (app.globalData.type == 'ml') {
  360. wx.switchTab({
  361. url: '/index/searchbar'
  362. })
  363. }
  364. // 兑换
  365. else if (app.globalData.type == 'ec') {
  366. wx.redirectTo({
  367. url: '/pages/exchange/exchange'
  368. })
  369. }
  370. // 通过分享进入的门店详情
  371. else if (options && options.id && options.frommd == 'md' && app.globalData.type == 'md') {
  372. wx.redirectTo({
  373. url: `/pages/index/searchbar/detail/index?id=${options.id}`
  374. });
  375. } else {
  376. // 主页
  377. wx.switchTab({
  378. url: app.globalData.goHomeUrl
  379. })
  380. }
  381. })
  382. .catch(err => {
  383. wx.showToast({
  384. title: err,
  385. icon: "loading",
  386. duration: 2000
  387. })
  388. if (err.code == 11004) {
  389. // 用户昵称未授权
  390. if (options && options.orderGroupId) {
  391. wx.redirectTo({
  392. url: `/pages/getuserinfo/index?couponId=${options.couponId}&orderGroupId=${options.orderGroupId}&couponChannelId=${options.couponChannelId}&orderId=${options.orderId}&avatarUrl=${options.avatarUrl}&nickName=${options.nickName}`
  393. })
  394. }
  395. /**
  396. * spellGroup
  397. * 区分是通过拼团详情分享过来的还是从普通券分享过来的
  398. * 注意:拼团券和普通券是两个页面
  399. */
  400. if (options && options.couponChannelId && !options.cuserId && !options.spellGroup) {
  401. wx.redirectTo({
  402. url: `/pages/getuserinfo/index?couponChannelId=${options.couponChannelId}`
  403. })
  404. } else if (options && options.couponChannelId && !options.cuserId && options.spellGroup) {
  405. wx.redirectTo({
  406. url: `/pages/getuserinfo/index?couponChannelId=${options.couponChannelId}&spellGroup=${options.spellGroup}`
  407. })
  408. } else if (options && options.couponChannelId && options.cuserId) {
  409. /**
  410. * 转赠判断
  411. */
  412. wx.redirectTo({
  413. url: `/pages/getuserinfo/index?couponChannelId=${options.couponChannelId}&cuserId=${options.cuserId}&coverImg=${options.coverImg}&userName=${options.userName}&avatarUrl=${options.avatarUrl}&couponOrderId=${options.couponOrderId}&updateDate=${options.updateDate}`
  414. })
  415. } else if (options && options.orderId) {
  416. wx.redirectTo({
  417. url: `/pages/getuserinfo/index?orderId=${options.orderId}&from='${"discount"}`
  418. })
  419. }
  420. // 报名活动页面
  421. else if (options && options.id && app.globalData.type == 'ra') {
  422. wx.redirectTo({
  423. url: `/pages/radetail/index?id=${options.id}`,
  424. })
  425. }
  426. // 通过分享进入的门店详情
  427. else if (options && options.id && options.frommd == 'md' && app.globalData.type == 'md') {
  428. wx.redirectTo({
  429. url: `/pages/getuserinfo/index?id=${options.id}&frommd=md`
  430. });
  431. }// 门店详情
  432. else if (options && options.id && app.globalData.type == 'md') {
  433. wx.redirectTo({
  434. url: `/pages/index/searchbar/detail/index?id=${options.id}`
  435. });
  436. } else if (app.globalData.type == 'uc') {
  437. wx.switchTab({
  438. url: '/index/user'
  439. });
  440. }
  441. // 积分
  442. else if (app.globalData.type == 'jf') {
  443. wx.redirectTo({
  444. url: '/pages/integralmall/index'
  445. });
  446. }
  447. // 首页
  448. else if (app.globalData.type == 'in') {
  449. wx.switchTab({
  450. url: app.globalData.goHomeUrl
  451. });
  452. }
  453. // 停车
  454. else if (app.globalData.type == 'pc') {
  455. // 停车
  456. wx.switchTab({
  457. url: '/index/passCar'
  458. });
  459. }
  460. // 我的券包
  461. else if (app.globalData.type == 'mc') {
  462. // 我的券包
  463. wx.redirectTo({
  464. url: '/pages/couponorder/index/index'
  465. });
  466. }
  467. // 我的订单
  468. else if (app.globalData.type == 'mo') {
  469. // 我的订单
  470. wx.redirectTo({
  471. url: '/pages/order/index/index?id=all'
  472. });
  473. }
  474. // 我的卡包
  475. else if (app.globalData.type == 'ca') {
  476. // 我的卡包
  477. wx.redirectTo({
  478. url: '/pages/cardorder/index/index'
  479. });
  480. }
  481. // 特享礼遇
  482. else if (app.globalData.type == 'sc') {
  483. // 特享礼遇
  484. wx.redirectTo({
  485. url: '/pages/specialcourtesy/specialcourtesy'
  486. });
  487. }
  488. // 限时秒杀
  489. else if (app.globalData.type == 'rb') {
  490. // 限时秒杀
  491. wx.redirectTo({
  492. url: '/pages/rushToBuy/index'
  493. })
  494. }
  495. // 砍价专场
  496. else if (app.globalData.type == 'bl') {
  497. // 砍价专场
  498. wx.redirectTo({
  499. url: '/pages/bargain/bargain'
  500. })
  501. }
  502. // 我的砍价
  503. else if (app.globalData.type == 'mb') {
  504. // 我的砍价
  505. wx.redirectTo({
  506. url: '/pages/bargain/bargain?from=myhtml'
  507. })
  508. }
  509. // 拼团专场
  510. else if (app.globalData.type == 'sl') {
  511. // 拼团专场
  512. wx.redirectTo({
  513. url: '/pages/spellGroup/spellGroup'
  514. })
  515. }
  516. // 我的拼团
  517. else if (app.globalData.type == 'ms') {
  518. wx.redirectTo({
  519. url: '/pages/spellGroup/spellGroup?from=myhtml'
  520. })
  521. }
  522. // 消费卡
  523. else if (app.globalData.type == 'dc') {
  524. // 消费卡
  525. wx.redirectTo({
  526. url: '/pages/discountCardList/discountCardList'
  527. })
  528. }
  529. // 兑换
  530. else if (app.globalData.type == 'ec') {
  531. wx.redirectTo({
  532. url: '/pages/exchange/exchange'
  533. })
  534. }
  535. // 门店
  536. else if (app.globalData.type == 'ml') {
  537. wx.switchTab({
  538. url: '/index/searchbar'
  539. })
  540. } else {
  541. wx.switchTab({
  542. url: app.globalData.goHomeUrl,
  543. })
  544. }
  545. }
  546. })
  547. },
  548. getGameOne: function(token, id) {
  549. let _this = this;
  550. Http.get({
  551. url: config.api.getOneGame,
  552. data: {
  553. token: token,
  554. id: id
  555. }
  556. }).then(res => {
  557. wx.redirectTo({
  558. url: '/pages/game/index?url=' + res.data.url + "&id=" + res.data.id + "&gameId=" + res.data.gameId,
  559. })
  560. })
  561. .catch(err => {
  562. wx.showModal({
  563. title: '提示',
  564. content: err.message,
  565. showCancel: false,
  566. success: function(res) {
  567. // 如果游戏下架或者找不到,重启首页
  568. if (res.confirm) {
  569. wx.reLaunch({
  570. url: '/pages/index/index',
  571. })
  572. }
  573. }
  574. })
  575. this.alphaClick();
  576. })
  577. },
  578. })