抖音c端
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

index.js 20 KiB

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