抖音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.

618 lines
20 KiB

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