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.

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