C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

619 lines
20 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. const isCancel = wx.getStorageSync('isCancel')
  139. if (isCancel === '1') {
  140. // 主页
  141. wx.switchTab({
  142. url: app.globalData.goHomeUrl
  143. })
  144. wx.setStorageSync('isCancel', '0')
  145. }
  146. Http.get({
  147. url: config.api.checkUserStatus,
  148. data: {
  149. token: app.globalData.token
  150. }
  151. })
  152. .then(res => {
  153. console.log(res, 'res');
  154. //参与拼团
  155. if (options && options.orderGroupId) {
  156. wx.redirectTo({
  157. url: `/pages/joinFrDpell/index?couponId=${options.couponId}&orderGroupId=${options.orderGroupId}&couponChannelId=${options.couponChannelId}&orderId=${options.orderId}&avatarUrl=${options.avatarUrl}&nickName=${options.nickName}`
  158. })
  159. }
  160. //来自大屏的跳转拼团券详情
  161. else if (options && options.couponChannelId && options.path == 'daping') {
  162. /**
  163. * 主要是为了拿couponId
  164. */
  165. Http.get({
  166. url: config.api.couponDetail,
  167. data: {
  168. couponChannelId: options.couponChannelId
  169. }
  170. }).then(res => {
  171. let data = res.data;
  172. wx.redirectTo({
  173. url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${options.couponChannelId}&couponId=${data.couponId}`
  174. })
  175. })
  176. } else if (options && options.couponChannelId && !options.spellGroup && app.globalData.type != 'sd') {
  177. // 转赠判断
  178. if (options.cuserId) {
  179. wx.redirectTo({
  180. 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}`,
  181. })
  182. } else {
  183. // 跳转普通券/消费卡/限时秒杀/砍价详情
  184. wx.redirectTo({
  185. url: `/pages/coupon/detail/index?couponChannelId=${options.couponChannelId}`,
  186. })
  187. }
  188. }
  189. // 拼团详情页(只有通过扫码进入才可能进入拼团详情页面,只有这一个入口)
  190. else if ((options && options.couponChannelId && app.globalData.type == 'sd') || (options && options.couponChannelId && options.spellGroup)) {
  191. wx.redirectTo({
  192. url: `/pages/spellGroup/mySpellGroup/index?couponChannelId=${options.couponChannelId}`,
  193. })
  194. }
  195. // 游戏页面
  196. else if (options && options.id && app.globalData.type == 'gm') {
  197. that.getGameOne(app.globalData.token, options.id)
  198. }
  199. // 报名活动页面
  200. else if (options && options.id && app.globalData.type == 'ra') {
  201. wx.redirectTo({
  202. url: `/pages/radetail/index?id=${options.id}`,
  203. })
  204. }
  205. //活动签到
  206. else if (options && options.id && app.globalData.type == 'si') {
  207. wx.redirectTo({
  208. url: `/pages/acSignIn/index?id=${options.id}`,
  209. })
  210. }
  211. //答题问卷
  212. else if (options && options.id && app.globalData.type == 'wj') {
  213. wx.redirectTo({
  214. url: `/pages/questionnaire/questionnaire?id=${options.id}`,
  215. })
  216. }
  217. //投诉建议
  218. else if (app.globalData.type == 'ts') {
  219. wx.redirectTo({
  220. url: `/pages3/complaint/complaint`,
  221. })
  222. }
  223. // 宣传页详情
  224. else if (options && options.bt && options.id && app.globalData.type == 'bd') {
  225. if (options.bt == '2') {
  226. // 自由图文
  227. wx.redirectTo({
  228. url: `/pages/freeBannerDetail/index?id=${options.id}`,
  229. })
  230. } else {
  231. // 标准格式
  232. wx.redirectTo({
  233. url: `/pages/bannerdetail/index?id=${options.id}`,
  234. })
  235. }
  236. }
  237. // 专题
  238. else if (options && options.id && app.globalData.type == 'td') {
  239. wx.redirectTo({
  240. url: `/pages/topicDetail/index?id=${options.id}`
  241. });
  242. }
  243. // 门店详情
  244. else if (options && options.id && app.globalData.type == 'md') {
  245. wx.redirectTo({
  246. url: `/pages/index/searchbar/detail/index?id=${options.id}`
  247. });
  248. }
  249. // 参与砍价
  250. else if (options && options.orderId) {
  251. wx.redirectTo({
  252. url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${options.orderId}&from=${"discount"}&composeOrderType=${options.composeOrderType}`,
  253. })
  254. }
  255. // 我的
  256. else if (app.globalData.type == 'uc') {
  257. wx.switchTab({
  258. url: '/index/user'
  259. });
  260. }
  261. // 积分
  262. else if (app.globalData.type == 'jf') {
  263. wx.redirectTo({
  264. url: '/pages/integralmall/index'
  265. });
  266. }
  267. // 首页
  268. else if (app.globalData.type == 'in') {
  269. wx.switchTab({
  270. url: app.globalData.goHomeUrl
  271. });
  272. }
  273. // 停车
  274. else if (app.globalData.type == 'pc') {
  275. // 停车
  276. wx.switchTab({
  277. url: '/index/passCar'
  278. });
  279. }
  280. // 我的券包
  281. else if (app.globalData.type == 'mc') {
  282. // 我的券包
  283. wx.redirectTo({
  284. url: '/pages/couponorder/index/index'
  285. });
  286. }
  287. // 我的订单
  288. else if (app.globalData.type == 'mo') {
  289. // 我的订单
  290. wx.redirectTo({
  291. url: '/pages/order/index/index?id=all'
  292. });
  293. }
  294. // 我的卡包
  295. else if (app.globalData.type == 'ca') {
  296. // 我的卡包
  297. wx.redirectTo({
  298. url: '/pages/cardorder/index/index'
  299. });
  300. }
  301. // 特享礼遇
  302. else if (app.globalData.type == 'sc') {
  303. // 特享礼遇
  304. wx.redirectTo({
  305. url: '/pages/specialcourtesy/specialcourtesy'
  306. });
  307. }
  308. // 限时秒杀
  309. else if (app.globalData.type == 'rb') {
  310. // 限时秒杀
  311. wx.redirectTo({
  312. url: '/pages/rushToBuy/index'
  313. })
  314. }
  315. // 砍价专场
  316. else if (app.globalData.type == 'bl') {
  317. // 砍价专场
  318. wx.redirectTo({
  319. url: '/pages/bargain/bargain'
  320. })
  321. }
  322. // 我的砍价
  323. else if (app.globalData.type == 'mb') {
  324. // 我的砍价
  325. wx.redirectTo({
  326. url: '/pages/bargain/bargain?from=myhtml'
  327. })
  328. }
  329. // 拼团专场
  330. else if (app.globalData.type == 'sl') {
  331. // 拼团专场
  332. wx.redirectTo({
  333. url: '/pages/spellGroup/spellGroup'
  334. })
  335. }
  336. // 我的拼团
  337. else if (app.globalData.type == 'ms') {
  338. // 我的拼团
  339. wx.redirectTo({
  340. url: '/pages/spellGroup/spellGroup?from=myhtml'
  341. })
  342. }
  343. // 消费卡
  344. else if (app.globalData.type == 'dc') {
  345. // 消费卡
  346. wx.redirectTo({
  347. url: '/pages/discountCardList/discountCardList'
  348. })
  349. }
  350. // 录入电子卡
  351. else if (app.globalData.type == 'se') {
  352. // 录入电子卡
  353. wx.redirectTo({
  354. url: '/pages3/exchangeCard/exchangeCard'
  355. })
  356. }
  357. //直播
  358. else if (app.globalData.type == 'zb') {
  359. wx.redirectTo({
  360. url: `/pages2/live/livelist/index`
  361. });
  362. }
  363. //活动日历
  364. else if (app.globalData.type == 'arl') {
  365. wx.redirectTo({
  366. url: `/pages/dateLsit/dateLsit`
  367. });
  368. }
  369. //每日签到
  370. else if (app.globalData.type == 'qd') {
  371. wx.redirectTo({
  372. url: `/pages/activityCalendar/activityCalendar`
  373. });
  374. }
  375. // 门店
  376. else if (app.globalData.type == 'ml') {
  377. wx.switchTab({
  378. url: '/index/searchbar'
  379. })
  380. }
  381. // 兑换
  382. else if (app.globalData.type == 'ec') {
  383. wx.redirectTo({
  384. url: '/pages3/exchange/exchange'
  385. })
  386. }
  387. // 通过分享进入的门店详情
  388. else if (options && options.id && options.frommd == 'md' && app.globalData.type == 'md') {
  389. wx.redirectTo({
  390. url: `/pages/index/searchbar/detail/index?id=${options.id}`
  391. });
  392. } else if (options && app.globalData.type == 'rm') {
  393. console.log("111111111111111111111");
  394. wx.navigateTo({
  395. url: '/pages3/resume/resume',
  396. })
  397. } else {
  398. // 主页
  399. wx.switchTab({
  400. url: app.globalData.goHomeUrl
  401. })
  402. }
  403. })
  404. .catch(err => {
  405. wx.showToast({
  406. title: err,
  407. icon: "loading",
  408. duration: 2000
  409. })
  410. if (err.code == 11004) {
  411. // 用户昵称未授权
  412. if (options && options.orderGroupId) {
  413. wx.redirectTo({
  414. url: `/pages/getuserinfo/index?couponId=${options.couponId}&orderGroupId=${options.orderGroupId}&couponChannelId=${options.couponChannelId}&orderId=${options.orderId}&avatarUrl=${options.avatarUrl}&nickName=${options.nickName}`
  415. })
  416. }
  417. /**
  418. * spellGroup
  419. * 区分是通过拼团详情分享过来的还是从普通券分享过来的
  420. * 注意:拼团券和普通券是两个页面
  421. */
  422. if (options && options.couponChannelId && !options.cuserId && !options.spellGroup) {
  423. wx.redirectTo({
  424. url: `/pages/getuserinfo/index?couponChannelId=${options.couponChannelId}`
  425. })
  426. } else if (options && options.couponChannelId && !options.cuserId && options.spellGroup) {
  427. wx.redirectTo({
  428. url: `/pages/getuserinfo/index?couponChannelId=${options.couponChannelId}&spellGroup=${options.spellGroup}`
  429. })
  430. } else if (options && options.couponChannelId && options.cuserId) {
  431. /**
  432. * 转赠判断
  433. */
  434. wx.redirectTo({
  435. 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}`
  436. })
  437. } else if (options && options.orderId) {
  438. wx.redirectTo({
  439. url: `/pages/getuserinfo/index?orderId=${options.orderId}&from='${"discount"}`
  440. })
  441. }
  442. // 报名活动页面
  443. else if (options && options.id && app.globalData.type == 'ra') {
  444. wx.redirectTo({
  445. url: `/pages/radetail/index?id=${options.id}`,
  446. })
  447. }
  448. // 通过分享进入的门店详情
  449. else if (options && options.id && options.frommd == 'md' && app.globalData.type == 'md') {
  450. wx.redirectTo({
  451. url: `/pages/getuserinfo/index?id=${options.id}&frommd=md`
  452. });
  453. }// 门店详情
  454. else if (options && options.id && app.globalData.type == 'md') {
  455. wx.redirectTo({
  456. url: `/pages/index/searchbar/detail/index?id=${options.id}`
  457. });
  458. } else if (app.globalData.type == 'uc') {
  459. wx.switchTab({
  460. url: '/index/user'
  461. });
  462. }
  463. // 积分
  464. else if (app.globalData.type == 'jf') {
  465. wx.redirectTo({
  466. url: '/pages/integralmall/index'
  467. });
  468. }
  469. // 首页
  470. else if (app.globalData.type == 'in') {
  471. wx.switchTab({
  472. url: app.globalData.goHomeUrl
  473. });
  474. }
  475. // 停车
  476. else if (app.globalData.type == 'pc') {
  477. // 停车
  478. wx.switchTab({
  479. url: '/index/passCar'
  480. });
  481. }
  482. // 我的券包
  483. else if (app.globalData.type == 'mc') {
  484. // 我的券包
  485. wx.redirectTo({
  486. url: '/pages/couponorder/index/index'
  487. });
  488. }
  489. // 我的订单
  490. else if (app.globalData.type == 'mo') {
  491. // 我的订单
  492. wx.redirectTo({
  493. url: '/pages/order/index/index?id=all'
  494. });
  495. }
  496. // 我的卡包
  497. else if (app.globalData.type == 'ca') {
  498. // 我的卡包
  499. wx.redirectTo({
  500. url: '/pages/cardorder/index/index'
  501. });
  502. }
  503. // 特享礼遇
  504. else if (app.globalData.type == 'sc') {
  505. // 特享礼遇
  506. wx.redirectTo({
  507. url: '/pages/specialcourtesy/specialcourtesy'
  508. });
  509. }
  510. // 限时秒杀
  511. else if (app.globalData.type == 'rb') {
  512. // 限时秒杀
  513. wx.redirectTo({
  514. url: '/pages/rushToBuy/index'
  515. })
  516. }
  517. // 砍价专场
  518. else if (app.globalData.type == 'bl') {
  519. // 砍价专场
  520. wx.redirectTo({
  521. url: '/pages/bargain/bargain'
  522. })
  523. }
  524. // 我的砍价
  525. else if (app.globalData.type == 'mb') {
  526. // 我的砍价
  527. wx.redirectTo({
  528. url: '/pages/bargain/bargain?from=myhtml'
  529. })
  530. }
  531. // 拼团专场
  532. else if (app.globalData.type == 'sl') {
  533. // 拼团专场
  534. wx.redirectTo({
  535. url: '/pages/spellGroup/spellGroup'
  536. })
  537. }
  538. // 我的拼团
  539. else if (app.globalData.type == 'ms') {
  540. wx.redirectTo({
  541. url: '/pages/spellGroup/spellGroup?from=myhtml'
  542. })
  543. }
  544. // 消费卡
  545. else if (app.globalData.type == 'dc') {
  546. // 消费卡
  547. wx.redirectTo({
  548. url: '/pages/discountCardList/discountCardList'
  549. })
  550. }
  551. // 录入电子卡
  552. else if (app.globalData.type == 'se') {
  553. // 录入电子卡
  554. wx.redirectTo({
  555. url: '/pages3/exchangeCard/exchangeCard'
  556. })
  557. }
  558. // 兑换
  559. else if (app.globalData.type == 'ec') {
  560. wx.redirectTo({
  561. url: '/pages3/exchange/exchange'
  562. })
  563. }
  564. // 门店
  565. else if (app.globalData.type == 'ml') {
  566. wx.switchTab({
  567. url: '/index/searchbar'
  568. })
  569. } else if (options && app.globalData.type == 'rm') {
  570. console.log("22222222222222222");
  571. wx.redirectTo({
  572. url: `/pages/getuserinfo/index`
  573. })
  574. } else {
  575. wx.switchTab({
  576. url: app.globalData.goHomeUrl,
  577. })
  578. }
  579. }
  580. })
  581. },
  582. getGameOne: function (token, id) {
  583. let _this = this;
  584. Http.get({
  585. url: config.api.getOneGame,
  586. data: {
  587. token: token,
  588. id: id
  589. }
  590. }).then(res => {
  591. wx.redirectTo({
  592. url: '/pages/game/index?url=' + res.data.url + "&id=" + res.data.id + "&gameId=" + res.data.gameId,
  593. })
  594. })
  595. .catch(err => {
  596. wx.showModal({
  597. title: '提示',
  598. content: err.message,
  599. showCancel: false,
  600. success: function (res) {
  601. // 如果游戏下架或者找不到,重启首页
  602. if (res.confirm) {
  603. wx.reLaunch({
  604. url: '/pages/index/index',
  605. })
  606. }
  607. }
  608. })
  609. this.alphaClick();
  610. })
  611. },
  612. })