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.

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