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

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