C端小程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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