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

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