抖音c端
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

555 righe
22 KiB

  1. const navigationBarHeight = (getApp().statusBarHeight + 50) + 'px'
  2. var config = require("../../config/config.js");
  3. var app = getApp();
  4. const Http = require("../../utils/HttpBasics");
  5. Page({
  6. data: {
  7. navigationBarHeight,
  8. path: null,
  9. couponChannelId: null,
  10. cuserId: null,
  11. coverImg: null,
  12. couponOrderId: null,
  13. optionData: null,
  14. fromflag: '',
  15. couponChannelIdflag: '',
  16. confirmationFlag:'',
  17. wjId: "",
  18. composeOrderType: "",
  19. fillIndentId: "",
  20. url: null,//游戏路径
  21. id: null,//游戏id,
  22. gameId: null,//游戏gameId
  23. },
  24. backHome() {
  25. tt.navigateBack({
  26. delta: 1,
  27. success: (res) => {
  28. },
  29. fail: (res) => {
  30. tt.reLaunch({
  31. url: "/index/index",
  32. success: (res) => {
  33. },
  34. fail: (res) => {
  35. },
  36. });
  37. },
  38. });
  39. // tt.reLaunch({
  40. // url: "/pages/index/index",
  41. // success: (res) => {
  42. // },
  43. // fail: (res) => {
  44. // },
  45. // });
  46. },
  47. //是否授权手机号
  48. judgePhonelngo() {
  49. Http.get({
  50. url: config.api.checkPhoneStatus,
  51. data: {}
  52. }).then(res => {
  53. var tempSkip = app.globalData.skip
  54. if (tempSkip == 'redirectTo') {
  55. tt.redirectTo({
  56. url: app.globalData.skipUrl,
  57. })
  58. } else if (tempSkip == 'navigateTo') {
  59. tt.navigateTo({
  60. url: app.globalData.skipUrl,
  61. })
  62. } else if (tempSkip == 'reLaunch') {
  63. tt.reLaunch({
  64. url: app.globalData.skipUrl,
  65. })
  66. } else if (tempSkip == 'switchTab') {
  67. tt.switchTab({
  68. url: app.globalData.skipUrl,
  69. })
  70. }
  71. }).catch(err => {
  72. if(app.globalData.ifCongPh==1){
  73. tt.redirectTo({
  74. url: `/pages/getPhone/getPhone?skipUrl=1`
  75. });
  76. }else{
  77. tt.navigateBack({
  78. delta: 1,
  79. })
  80. }
  81. })
  82. },
  83. onLoad: function (options) {
  84. console.log(app.globalData.skip, app.globalData.skipUrl, app.globalData.type, "跳转地址")
  85. var that = this;
  86. // options.fromflag == 'coupondetail';
  87. // 游戏页面
  88. if (options && options.url && options.id && options.gameId) {
  89. that.setData({
  90. url: options.url,//游戏路径
  91. id: options.id,//游戏id,
  92. gameId: options.gameId,//游戏gameId
  93. })
  94. }
  95. // 来自优惠券详情页面
  96. if (options && options.fromflag) {
  97. that.setData({
  98. fromflag: options.fromflag
  99. })
  100. }
  101. if (options && options.composeOrderType) {
  102. that.setData({
  103. composeOrderType: options.composeOrderType
  104. })
  105. }
  106. //线上配送 填写订单
  107. if (options && options.fillIndentId && couponId && options.couponId) {
  108. that.setData({
  109. fillIndentId: options.fillIndentId,
  110. couponId: options.couponId
  111. })
  112. }
  113. // 来自优惠券列表券详情页面的 couponChannelId
  114. if (options && options.couponChannelIdflag) {
  115. that.setData({
  116. couponChannelIdflag: options.couponChannelIdflag
  117. })
  118. }
  119. //确定订单
  120. if (options && options.confirmationFlag) {
  121. that.setData({
  122. confirmationFlag: options.confirmationFlag
  123. })
  124. }
  125. //调查问卷
  126. if (options && !options.wjId || options.wjId) {
  127. this.setData({
  128. wjId: options.wjId
  129. })
  130. }
  131. if (options && options.spellGroup) {
  132. that.setData({
  133. spellGroup: options.spellGroup
  134. })
  135. } else {
  136. that.setData({
  137. spellGroup: null
  138. })
  139. }
  140. if (options.couponChannelId && !options.cuserId || options.orderId) {
  141. that.setData({
  142. couponChannelId: options.couponChannelId,
  143. orderId: options.orderId
  144. })
  145. }
  146. if (options && options.frommd && options.id) {
  147. that.setData({
  148. id: options.id,
  149. frommd: options.frommd
  150. })
  151. }
  152. // that.setData({
  153. // optionData: null
  154. // })
  155. console.log(tt.getStorageSync('options'), 6666)
  156. that.setData({
  157. optionData: tt.getStorageSync('options') ? JSON.parse(tt.getStorageSync('options')) : null
  158. })
  159. if (options && options.path == 'index') {
  160. that.setData({
  161. path: options.path
  162. })
  163. }
  164. /**
  165. * 来自转赠
  166. */
  167. if (options.couponChannelId && options.cuserId) {
  168. that.setData({
  169. couponChannelId: options.couponChannelId,
  170. cuserId: options.cuserId,
  171. updateDate: options.updateDate,
  172. coverImg: options.coverImg,
  173. userName: options.userName,
  174. avatarUrl: options.avatarUrl,
  175. couponOrderId: options.couponOrderId
  176. })
  177. }
  178. Http.get({
  179. url: config.api.marketicon,
  180. data: {
  181. appId: app.globalData.appId
  182. }
  183. }).then(res => {
  184. that.setData({
  185. mallImgUrl: res.data.mallImgUrl
  186. });
  187. tt.setNavigationBarTitle({
  188. title: res.data.mallName
  189. })
  190. })
  191. .catch(err => {
  192. tt.showToast({
  193. title: err.errMsg,
  194. icon: 'none',
  195. duration: 2000,
  196. mask: false
  197. });
  198. })
  199. },
  200. onShow: function () {
  201. tt.checkSession({
  202. success() {
  203. //session_key 未过期,并且在本生命周期一直有效
  204. },
  205. fail() {
  206. console.log("session_key 过期")
  207. // session_key 已经失效,需要重新执行登录流程
  208. tt.login({
  209. success: (res) => {
  210. if (res.code) {
  211. let usrdata = {
  212. appId: app.globalData.appId,
  213. code: res.code,
  214. }
  215. Http.post({
  216. url: config.api.login,
  217. data: usrdata
  218. }).then(res => {
  219. Http.setToken(res.data.token);
  220. app.globalData.token = res.data.token;
  221. })
  222. }
  223. }
  224. })
  225. }
  226. })
  227. },
  228. bindGetUserInfo(e) {
  229. //session_key 未过期,并且在本生命周期一直有效 tt.getUserProfile
  230. tt.getUserProfile({
  231. withCredentials: true,
  232. title: '温馨提示',
  233. desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  234. success: (res) => {
  235. let that = this;
  236. var iv = res.iv;
  237. var encryptedData = res.encryptedData;
  238. // console.log(res,"数据");
  239. // return
  240. tt.login({
  241. success:(res=>{
  242. let {code} = res
  243. console.log(code,"code");
  244. Http.post({
  245. url:config.api.login,
  246. data:{
  247. code:code,
  248. appId:app.globalData.appId,
  249. systemInfo:JSON.stringify(app.globalData.systemInfo)
  250. }
  251. }).then(res=>{
  252. Http.setToken(res.data.token);
  253. app.globalData.token = res.data.token
  254. Http.post({
  255. url: config.api.getUserInfo,
  256. data: {
  257. encryptedData: encryptedData,
  258. iv: iv
  259. }
  260. }).then(res => {
  261. if (app.globalData.type == 'gm' && that.data.id && that.data.gameId && that.data.url) {//游戏页面
  262. app.globalData.skipUrl = '/pages/game/index?url=' + that.data.url + "&id=" + that.data.id + "&gameId=" + that.data.gameId,
  263. app.globalData.skip = 'redirectTo'
  264. that.judgePhonelngo()
  265. return;
  266. }
  267. if (that.data.wjId) {
  268. app.globalData.skipUrl = `/pages/questionnaire/questionnaire?id=${that.data.wjId}`
  269. app.globalData.skip = 'redirectTo'
  270. that.judgePhonelngo()
  271. return;
  272. }
  273. if (that.data.fromflag == 'poster') {
  274. app.globalData.skipUrl = `/pages/canvas/index?couponChannelId=${that.data.couponChannelId}`
  275. app.globalData.skip = 'redirectTo'
  276. that.judgePhonelngo()
  277. return;
  278. }
  279. //
  280. if (that.data.optionData != null && that.data.optionData.orderGroupId != null && that.data.optionData.orderGroupId != "") {
  281. app.globalData.skipUrl = `/pages/joinFrDpell/index?couponId=${that.data.optionData.couponId}&orderGroupId=${that.data.optionData.orderGroupId}&couponChannelId=${that.data.optionData.couponChannelId}&orderId=${that.data.optionData.orderId}&avatarUrl=${that.data.optionData.avatarUrl}&nickName=${that.data.optionData.nickName}`
  282. app.globalData.skip = 'reLaunch'
  283. that.judgePhonelngo()
  284. return;
  285. }
  286. if (that.data.path == 'index') {
  287. app.globalData.skipUrl = "/pages/game/index"
  288. app.globalData.skip = 'reLaunch'
  289. that.judgePhonelngo()
  290. } else {
  291. //返回主页
  292. // if (that.data.couponChannelId && !that.data.cuserId && !that.data.spellGroup||that.data.couponChannelId && !that.data.cuserId&&app.globalData.type == 'cd') {
  293. if (that.data.couponChannelId && !that.data.cuserId && !that.data.spellGroup && app.globalData.type == 'cd') {
  294. // 跳转普通券/消费卡/限时秒杀/砍价详情
  295. app.globalData.skipUrl = `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}`
  296. app.globalData.skip = 'navigateTo'
  297. that.judgePhonelngo()
  298. } else if (that.data.couponChannelId && that.data.cuserId && !that.data.spellGroup && app.globalData.type != 'sd') {
  299. // 来自转赠
  300. app.globalData.skipUrl = `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}&cuserId=${that.data.cuserId}&coverImg=${that.data.coverImg}&userName=${that.data.userName}&avatarUrl=${that.data.avatarUrl}&couponOrderId=${that.data.couponOrderId}&updateDate=${that.data.updateDate}`
  301. app.globalData.skip = 'reLaunch'
  302. that.judgePhonelngo()
  303. } else if (that.data.couponChannelId && app.globalData.type == 'sd' || that.data.couponChannelId && that.data.spellGroup) {
  304. // 拼团详情页
  305. app.globalData.skipUrl = `/pages/spellGroup/mySpellGroup/index?couponChannelId=${that.data.couponChannelId}`
  306. app.globalData.skip = 'redirectTo'
  307. that.judgePhonelngo()
  308. } else if (that.data.optionData != null && that.data.optionData.id && app.globalData.type == 'gm') {
  309. // 游戏页面
  310. that.getGameOne(app.globalData.token, that.data.optionData.id)
  311. } else if (that.data.optionData != null && that.data.optionData.id && app.globalData.type == 'td') {
  312. app.globalData.skipUrl = `/pages/topicDetail/index?id=${that.data.optionData.id}`
  313. app.globalData.skip = 'redirectTo'
  314. that.judgePhonelngo()
  315. }
  316. // 报名活动
  317. else if (that.data.optionData != null && that.data.optionData.id && app.globalData.type == 'ra') {
  318. app.globalData.skipUrl = `/pages/radetail/index?id=${that.data.optionData.id}`,
  319. app.globalData.skip = 'redirectTo'
  320. that.judgePhonelngo()
  321. }
  322. // 报名签到
  323. else if (that.data.optionData != null && that.data.optionData.id && app.globalData.type == 'si') {
  324. app.globalData.skipUrl = `/pages/acSignIn/index?id=${that.data.optionData.id}`,
  325. app.globalData.skip = 'redirectTo'
  326. that.judgePhonelngo()
  327. }
  328. // 门店详情
  329. else if (that.data.optionData != null && that.data.optionData.id && app.globalData.type == 'md') {
  330. app.globalData.skipUrl = `/pages/index/searchbar/detail/index?id=${that.data.optionData.id}`,
  331. app.globalData.skip = 'redirectTo'
  332. that.judgePhonelngo()
  333. }
  334. // 通过分享进入的门店详情页面
  335. else if (that.data.id && that.data.frommd == 'md') {
  336. app.globalData.skipUrl = `/pages/index/searchbar/detail/index?id=${that.data.id}`,
  337. app.globalData.skip = 'redirectTo'
  338. that.judgePhonelngo()
  339. } else if (that.data.optionData != null && that.data.optionData.bt && that.data.optionData.id && app.globalData.type == 'bd') {
  340. // 宣传页详情
  341. if (that.data.optionData != null && that.data.optionData.bt == '2') {
  342. // 自由图文
  343. app.globalData.skipUrl = `/pages/freeBannerDetail/index?id=${that.data.optionData.id}`,
  344. app.globalData.skip = 'redirectTo'
  345. that.judgePhonelngo()
  346. } else {
  347. // 标准格式
  348. app.globalData.skipUrl = `/pages/bannerdetail/index?id=${that.data.optionData.id}`,
  349. app.globalData.skip = 'redirectTo'
  350. that.judgePhonelngo()
  351. }
  352. } else if (that.data.orderId || that.data.orderId && app.globalData.type == 'bg') {
  353. // 参与砍价
  354. app.globalData.skipUrl = `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.orderId}&composeOrderType=${that.composeOrderType}`,
  355. app.globalData.skip = 'navigateTo'
  356. that.judgePhonelngo()
  357. } else if (app.globalData.type == 'uc') {
  358. // 我的
  359. app.globalData.skipUrl = '/index/user',
  360. app.globalData.skip = 'redirectTo'
  361. that.judgePhonelngo()
  362. } else if (app.globalData.type == 'in') {
  363. // 首页
  364. app.globalData.skipUrl = app.globalData.goHomeUrl,
  365. app.globalData.skip = 'redirectTo'
  366. that.judgePhonelngo()
  367. } else if (app.globalData.type == "qd") {
  368. //每日签到
  369. app.globalData.skipUrl = "/pages/activityCalendar/activityCalendar"
  370. app.globalData.skip = 'reLaunch'
  371. that.judgePhonelngo()
  372. } else if (app.globalData.type == "hdrl") {
  373. //活动日历
  374. app.globalData.skipUrl = `/pages/radetail/index?id=${app.globalData.activityId}`
  375. app.globalData.skip = 'redirectTo'
  376. that.judgePhonelngo()
  377. }
  378. // 积分
  379. else if (app.globalData.type == 'jf') {
  380. app.globalData.skipUrl = '/pages/integralmall/index',
  381. app.globalData.skip = 'redirectTo'
  382. that.judgePhonelngo()
  383. } else if (app.globalData.type == 'pc') {
  384. // 停车
  385. app.globalData.skipUrl = '/index/passCar',
  386. app.globalData.skip = 'redirectTo'
  387. that.judgePhonelngo()
  388. } else if (app.globalData.type == 'mc') {
  389. // 我的券包
  390. app.globalData.skipUrl = '/pages/couponorder/index/index',
  391. app.globalData.skip = 'redirectTo'
  392. that.judgePhonelngo()
  393. } else if (app.globalData.type == 'mo') {
  394. // 我的订单
  395. app.globalData.skipUrl = '/pages/order/index/index?id=all',
  396. app.globalData.skip = 'redirectTo'
  397. that.judgePhonelngo()
  398. } else if (app.globalData.type == 'ca') {
  399. // 我的卡包
  400. app.globalData.skipUrl = '/pages/cardorder/index/index',
  401. app.globalData.skip = 'redirectTo'
  402. that.judgePhonelngo()
  403. } else if (app.globalData.type == 'sc') {
  404. // 特享礼遇
  405. app.globalData.skipUrl = '/pages/specialcourtesy/specialcourtesy',
  406. app.globalData.skip = 'redirectTo'
  407. that.judgePhonelngo()
  408. } else if (app.globalData.type == 'rb') {
  409. // 限时秒杀
  410. app.globalData.skipUrl = '/pages/rushToBuy/index',
  411. app.globalData.skip = 'redirectTo'
  412. that.judgePhonelngo()
  413. } else if (app.globalData.type == 'bl') {
  414. // 砍价专场
  415. app.globalData.skipUrl = '/pages/bargain/bargain',
  416. app.globalData.skip = 'redirectTo'
  417. that.judgePhonelngo()
  418. } else if (app.globalData.type == 'mb') {
  419. // 我的砍价
  420. app.globalData.skipUrl = '/pages/bargain/bargain?from=myhtml',
  421. app.globalData.skip = 'redirectTo'
  422. that.judgePhonelngo()
  423. } else if (app.globalData.type == 'sl') {
  424. // 拼团专场
  425. app.globalData.skipUrl = '/pages/spellGroup/spellGroup',
  426. app.globalData.skip = 'redirectTo'
  427. that.judgePhonelngo()
  428. } else if (app.globalData.type == 'ms') {
  429. // 我的拼团
  430. app.globalData.skipUrl = '/pages/spellGroup/spellGroup?from=myhtml',
  431. app.globalData.skip = 'redirectTo'
  432. that.judgePhonelngo()
  433. } else if (app.globalData.type == 'dc') {
  434. // 消费卡
  435. app.globalData.skipUrl = '/pages/discountCardList/discountCardList',
  436. app.globalData.skip = 'redirectTo'
  437. that.judgePhonelngo()
  438. } else if (app.globalData.type == 'td') {
  439. // 专题活动页
  440. app.globalData.skipUrl = '/pages/topicDetail/index',
  441. app.globalData.skip = 'redirectTo'
  442. that.judgePhonelngo()
  443. } else if (app.globalData.type == 'ml') {
  444. // 门店
  445. app.globalData.skipUrl = '/index/searchbar',
  446. app.globalData.skip = 'redirectTo'
  447. that.judgePhonelngo()
  448. } else if (that.data.fromflag == 'confirmation' && that.data.confirmationFlag) {
  449. //订单确认 confirmation
  450. app.globalData.skipUrl = `/pages/coupon/confirmation/confirmation?couponChannelId=${that.data.confirmationFlag}`,
  451. app.globalData.skip = 'redirectTo'
  452. that.judgePhonelngo()
  453. }
  454. else if (that.data.fromflag == 'coupondetail' && that.data.couponChannelIdflag) {
  455. app.globalData.skipUrl = `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelIdflag}`,
  456. app.globalData.skip = 'redirectTo'
  457. that.judgePhonelngo()
  458. } else if (that.data.fromflag == 'spellcoupondetail' && that.data.couponChannelIdflag) {
  459. app.globalData.skipUrl = `/pages/spellGroup/mySpellGroup/index?couponChannelId=${that.data.couponChannelIdflag}`,
  460. app.globalData.skip = 'redirectTo'
  461. that.judgePhonelngo()
  462. } else if (that.data.fromflag == 'fillIndent' && that.data.fillIndentId && that.data.couponId) {
  463. //线上配送 填写订单
  464. app.globalData.skipUrl = `/pages/fillIndent/fillIndent?id=${that.data.fillIndentId}&couponId=${that.data.couponId}`,
  465. app.globalData.skip = 'redirectTo'
  466. that.judgePhonelngo()
  467. } else {
  468. app.globalData.skipUrl = app.globalData.goHomeUrl,
  469. app.globalData.skip = 'redirectTo'
  470. that.judgePhonelngo()
  471. }
  472. }
  473. })
  474. .catch(err => {
  475. tt.showToast({
  476. title: err.code,
  477. icon: 'none',
  478. duration: 2000,
  479. mask: false
  480. });
  481. })
  482. }).catch(err=>{
  483. console.log(err);
  484. tt.showModal({
  485. title: '提示',
  486. showCancel: false,
  487. content: '登录失败,请重新尝试',
  488. success: (res) => {
  489. if (res.cancel) {
  490. //点击取消,默认隐藏弹框
  491. } else {
  492. //点击确定
  493. tt.reLaunch({
  494. url: '/pages/index/index',
  495. })
  496. }
  497. }
  498. });
  499. })
  500. }),
  501. });
  502. },
  503. fail: (err => {
  504. console.log(err)
  505. })
  506. })
  507. },
  508. getGameOne: function (token, id) {
  509. let _this = this;
  510. Http.get({
  511. url: config.api.getOneGame,
  512. data: {
  513. token: token,
  514. id: id
  515. }
  516. }).then(res => {
  517. tt.redirectTo({
  518. url: '/pages/game/index?url=' + res.data.url + "&id=" + res.data.id + "&gameId=" + res.data.gameId,
  519. })
  520. })
  521. .catch(err => {
  522. tt.showModal({
  523. title: '提示',
  524. content: err.message,
  525. showCancel: false,
  526. success: function (res) {
  527. // 如果游戏下架或者找不到,重启首页
  528. if (res.confirm) {
  529. tt.reLaunch({
  530. url: '/pages/index/index',
  531. })
  532. }
  533. }
  534. })
  535. this.alphaClick();
  536. })
  537. },
  538. });