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.

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