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

613 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. 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}`,
  155. })
  156. } else {
  157. // 跳转普通券/消费卡/限时秒杀/砍价详情
  158. tt.redirectTo({
  159. url: `/pages/coupon/detail/index?couponChannelId=${options.couponChannelId}`,
  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. }
  439. else if(app.globalData.type == 'wjLsit'){//问卷调查
  440. tt.redirectTo({
  441. url: `/pages/questionnaire/questionnaireLsit/questionnaireLsit`,
  442. })
  443. }
  444. // 答题问卷
  445. else if (options && options.id && app.globalData.type == 'wj') {
  446. tt.redirectTo({
  447. url: `/pages/questionnaire/questionnaire?id=${options.id}`,
  448. })
  449. }
  450. // 报名活动页面
  451. else if (options && options.id && app.globalData.type == 'ra') {
  452. tt.redirectTo({
  453. url: `/pages/radetail/index?id=${options.id}`,
  454. })
  455. } else if (app.globalData.type == 'uc') {
  456. tt.navigateTo({
  457. url: '/index/user'
  458. });
  459. }
  460. // 积分
  461. else if (app.globalData.type == 'jf') {
  462. tt.redirectTo({
  463. url: '/pages/integralmall/index'
  464. });
  465. }
  466. // 专题
  467. else if (options && options.id && app.globalData.type == 'td') {
  468. tt.redirectTo({
  469. url: `/pages/topicDetail/index?id=${options.id}`
  470. });
  471. }
  472. // 首页
  473. else if (app.globalData.type == 'in') {
  474. tt.reLaunch({
  475. url: '/index/index'
  476. });
  477. }
  478. // 停车
  479. else if (app.globalData.type == 'pc') {
  480. // 停车
  481. tt.navigateTo({
  482. url: '/index/passCar'
  483. });
  484. }
  485. // 我的券包
  486. else if (app.globalData.type == 'mc') {
  487. // 我的券包
  488. tt.redirectTo({
  489. url: '/pages/couponorder/index/index'
  490. });
  491. }
  492. // 我的订单
  493. else if (app.globalData.type == 'mo') {
  494. // 我的订单
  495. tt.redirectTo({
  496. url: '/pages/order/index/index?id=all'
  497. });
  498. }
  499. // 我的卡包
  500. else if (app.globalData.type == 'ca') {
  501. // 我的卡包
  502. tt.redirectTo({
  503. url: '/pages/cardorder/index/index'
  504. });
  505. }
  506. // 特享礼遇
  507. else if (app.globalData.type == 'sc') {
  508. // 特享礼遇
  509. tt.redirectTo({
  510. url: '/pages/specialcourtesy/specialcourtesy'
  511. });
  512. }
  513. // 限时秒杀
  514. else if (app.globalData.type == 'rb') {
  515. // 限时秒杀
  516. tt.redirectTo({
  517. url: '/pages/rushToBuy/index'
  518. })
  519. }
  520. // 砍价专场
  521. else if (app.globalData.type == 'bl') {
  522. // 砍价专场
  523. tt.redirectTo({
  524. url: '/pages/bargain/bargain'
  525. })
  526. }
  527. // 我的砍价
  528. else if (app.globalData.type == 'mb') {
  529. // 我的砍价
  530. tt.redirectTo({
  531. url: '/pages/bargain/bargain?from=myhtml'
  532. })
  533. }
  534. // 拼团专场
  535. else if (app.globalData.type == 'sl') {
  536. // 拼团专场
  537. tt.redirectTo({
  538. url: '/pages/spellGroup/spellGroup'
  539. })
  540. }
  541. // 我的拼团
  542. else if (app.globalData.type == 'ms') {
  543. tt.redirectTo({
  544. url: '/pages/spellGroup/spellGroup?from=myhtml'
  545. })
  546. }
  547. // 消费卡
  548. else if (app.globalData.type == 'dc') {
  549. // 消费卡
  550. tt.redirectTo({
  551. url: '/pages/discountCardList/discountCardList'
  552. })
  553. }
  554. // 兑换
  555. else if (app.globalData.type == 'ec') {
  556. tt.redirectTo({
  557. url: '/pages/exchange/exchange'
  558. })
  559. }
  560. // 门店
  561. else if (app.globalData.type == 'ml') {
  562. tt.navigateTo({
  563. url: '/index/searchbar'
  564. })
  565. } else {
  566. tt.reLaunch({
  567. url: '/index/index',
  568. })
  569. }
  570. }
  571. })
  572. }
  573. },
  574. getGameOne: function(token, id) {
  575. let _this = this;
  576. Http.get({
  577. url: config.api.getOneGame,
  578. data: {
  579. token: token,
  580. id: id
  581. }
  582. }).then(res => {
  583. tt.redirectTo({
  584. url: '/pages/game/index?url=' + res.data.url + "&id=" + res.data.id + "&gameId=" + res.data.gameId,
  585. })
  586. })
  587. .catch(err => {
  588. tt.showModal({
  589. title: '提示',
  590. content: err.message,
  591. showCancel: false,
  592. success: function(res) {
  593. // 如果游戏下架或者找不到,重启首页
  594. if (res.confirm) {
  595. tt.reLaunch({
  596. url: '/pages/index/index',
  597. })
  598. }
  599. }
  600. })
  601. this.alphaClick();
  602. })
  603. },
  604. })