抖音c端
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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