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.

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