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.

608 lines
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. // res = JSON.parse('{"code":11004,"message":"用户昵称未授权,请跳转到用户昵称授权页!","data":{}}')
  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. wx.navigateTo({
  386. url: '/pages3/resume/resume',
  387. })
  388. } else {
  389. // 主页
  390. wx.switchTab({
  391. url: app.globalData.goHomeUrl
  392. })
  393. }
  394. })
  395. .catch(err => {
  396. wx.showToast({
  397. title: err,
  398. icon: "loading",
  399. duration: 2000
  400. })
  401. if (err.code == 11004) {
  402. // 用户昵称未授权
  403. if (options && options.orderGroupId) {
  404. wx.redirectTo({
  405. url: `/pages/getuserinfo/index?couponId=${options.couponId}&orderGroupId=${options.orderGroupId}&couponChannelId=${options.couponChannelId}&orderId=${options.orderId}&avatarUrl=${options.avatarUrl}&nickName=${options.nickName}`
  406. })
  407. }
  408. /**
  409. * spellGroup
  410. * 区分是通过拼团详情分享过来的还是从普通券分享过来的
  411. * 注意:拼团券和普通券是两个页面
  412. */
  413. if (options && options.couponChannelId && !options.cuserId && !options.spellGroup) {
  414. wx.redirectTo({
  415. url: `/pages/getuserinfo/index?couponChannelId=${options.couponChannelId}`
  416. })
  417. } else if (options && options.couponChannelId && !options.cuserId && options.spellGroup) {
  418. wx.redirectTo({
  419. url: `/pages/getuserinfo/index?couponChannelId=${options.couponChannelId}&spellGroup=${options.spellGroup}`
  420. })
  421. } else if (options && options.couponChannelId && options.cuserId) {
  422. /**
  423. * 转赠判断
  424. */
  425. wx.redirectTo({
  426. 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}`
  427. })
  428. } else if (options && options.orderId) {
  429. wx.redirectTo({
  430. url: `/pages/getuserinfo/index?orderId=${options.orderId}&from='${"discount"}`
  431. })
  432. }
  433. // 报名活动页面
  434. else if (options && options.id && app.globalData.type == 'ra') {
  435. wx.redirectTo({
  436. url: `/pages/radetail/index?id=${options.id}`,
  437. })
  438. }
  439. // 通过分享进入的门店详情
  440. else if (options && options.id && options.frommd == 'md' && app.globalData.type == 'md') {
  441. wx.redirectTo({
  442. url: `/pages/getuserinfo/index?id=${options.id}&frommd=md`
  443. });
  444. }// 门店详情
  445. else if (options && options.id && app.globalData.type == 'md') {
  446. wx.redirectTo({
  447. url: `/pages/index/searchbar/detail/index?id=${options.id}`
  448. });
  449. } else if (app.globalData.type == 'uc') {
  450. wx.switchTab({
  451. url: '/index/user'
  452. });
  453. }
  454. // 积分
  455. else if (app.globalData.type == 'jf') {
  456. wx.redirectTo({
  457. url: '/pages/integralmall/index'
  458. });
  459. }
  460. // 首页
  461. else if (app.globalData.type == 'in') {
  462. wx.switchTab({
  463. url: app.globalData.goHomeUrl
  464. });
  465. }
  466. // 停车
  467. else if (app.globalData.type == 'pc') {
  468. // 停车
  469. wx.switchTab({
  470. url: '/index/passCar'
  471. });
  472. }
  473. // 我的券包
  474. else if (app.globalData.type == 'mc') {
  475. // 我的券包
  476. wx.redirectTo({
  477. url: '/pages/couponorder/index/index'
  478. });
  479. }
  480. // 我的订单
  481. else if (app.globalData.type == 'mo') {
  482. // 我的订单
  483. wx.redirectTo({
  484. url: '/pages/order/index/index?id=all'
  485. });
  486. }
  487. // 我的卡包
  488. else if (app.globalData.type == 'ca') {
  489. // 我的卡包
  490. wx.redirectTo({
  491. url: '/pages/cardorder/index/index'
  492. });
  493. }
  494. // 特享礼遇
  495. else if (app.globalData.type == 'sc') {
  496. // 特享礼遇
  497. wx.redirectTo({
  498. url: '/pages/specialcourtesy/specialcourtesy'
  499. });
  500. }
  501. // 限时秒杀
  502. else if (app.globalData.type == 'rb') {
  503. // 限时秒杀
  504. wx.redirectTo({
  505. url: '/pages/rushToBuy/index'
  506. })
  507. }
  508. // 砍价专场
  509. else if (app.globalData.type == 'bl') {
  510. // 砍价专场
  511. wx.redirectTo({
  512. url: '/pages/bargain/bargain'
  513. })
  514. }
  515. // 我的砍价
  516. else if (app.globalData.type == 'mb') {
  517. // 我的砍价
  518. wx.redirectTo({
  519. url: '/pages/bargain/bargain?from=myhtml'
  520. })
  521. }
  522. // 拼团专场
  523. else if (app.globalData.type == 'sl') {
  524. // 拼团专场
  525. wx.redirectTo({
  526. url: '/pages/spellGroup/spellGroup'
  527. })
  528. }
  529. // 我的拼团
  530. else if (app.globalData.type == 'ms') {
  531. wx.redirectTo({
  532. url: '/pages/spellGroup/spellGroup?from=myhtml'
  533. })
  534. }
  535. // 消费卡
  536. else if (app.globalData.type == 'dc') {
  537. // 消费卡
  538. wx.redirectTo({
  539. url: '/pages/discountCardList/discountCardList'
  540. })
  541. }
  542. // 录入电子卡
  543. else if (app.globalData.type == 'se') {
  544. // 录入电子卡
  545. wx.redirectTo({
  546. url: '/pages3/exchangeCard/exchangeCard'
  547. })
  548. }
  549. // 兑换
  550. else if (app.globalData.type == 'ec') {
  551. wx.redirectTo({
  552. url: '/pages3/exchange/exchange'
  553. })
  554. }
  555. // 门店
  556. else if (app.globalData.type == 'ml') {
  557. wx.switchTab({
  558. url: '/index/searchbar'
  559. })
  560. } else if (options && app.globalData.type == 'rm') {
  561. wx.navigateTo({
  562. url: '/pages3/resume/resume',
  563. })
  564. } else {
  565. wx.switchTab({
  566. url: app.globalData.goHomeUrl,
  567. })
  568. }
  569. }
  570. })
  571. },
  572. getGameOne: function (token, id) {
  573. let _this = this;
  574. Http.get({
  575. url: config.api.getOneGame,
  576. data: {
  577. token: token,
  578. id: id
  579. }
  580. }).then(res => {
  581. wx.redirectTo({
  582. url: '/pages/game/index?url=' + res.data.url + "&id=" + res.data.id + "&gameId=" + res.data.gameId,
  583. })
  584. })
  585. .catch(err => {
  586. wx.showModal({
  587. title: '提示',
  588. content: err.message,
  589. showCancel: false,
  590. success: function (res) {
  591. // 如果游戏下架或者找不到,重启首页
  592. if (res.confirm) {
  593. wx.reLaunch({
  594. url: '/pages/index/index',
  595. })
  596. }
  597. }
  598. })
  599. this.alphaClick();
  600. })
  601. },
  602. })