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.

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