抖音c端
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

569 строки
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. // 我的
  132. if (options && options.mineFlag) {
  133. console.log(11111);
  134. that.setData({
  135. mineFlag: options.mineFlag
  136. })
  137. }
  138. if (options && options.spellGroup) {
  139. that.setData({
  140. spellGroup: options.spellGroup
  141. })
  142. } else {
  143. that.setData({
  144. spellGroup: null
  145. })
  146. }
  147. if (options.couponChannelId && !options.cuserId || options.orderId) {
  148. that.setData({
  149. couponChannelId: options.couponChannelId,
  150. orderId: options.orderId
  151. })
  152. }
  153. if (options && options.frommd && options.id) {
  154. that.setData({
  155. id: options.id,
  156. frommd: options.frommd
  157. })
  158. }
  159. // that.setData({
  160. // optionData: null
  161. // })
  162. console.log(tt.getStorageSync('options'), 6666)
  163. that.setData({
  164. optionData: tt.getStorageSync('options') ? JSON.parse(tt.getStorageSync('options')) : null
  165. })
  166. if (options && options.path == 'index') {
  167. that.setData({
  168. path: options.path
  169. })
  170. }
  171. /**
  172. * 来自转赠
  173. */
  174. if (options.couponChannelId && options.cuserId) {
  175. that.setData({
  176. couponChannelId: options.couponChannelId,
  177. cuserId: options.cuserId,
  178. updateDate: options.updateDate,
  179. coverImg: options.coverImg,
  180. userName: options.userName,
  181. avatarUrl: options.avatarUrl,
  182. couponOrderId: options.couponOrderId
  183. })
  184. }
  185. Http.get({
  186. url: config.api.marketicon,
  187. data: {
  188. appId: app.globalData.appId
  189. }
  190. }).then(res => {
  191. that.setData({
  192. mallImgUrl: res.data.mallImgUrl
  193. });
  194. tt.setNavigationBarTitle({
  195. title: res.data.mallName
  196. })
  197. })
  198. .catch(err => {
  199. tt.showToast({
  200. title: err.errMsg,
  201. icon: 'none',
  202. duration: 2000,
  203. mask: false
  204. });
  205. })
  206. },
  207. onShow: function () {
  208. tt.checkSession({
  209. success() {
  210. //session_key 未过期,并且在本生命周期一直有效
  211. },
  212. fail() {
  213. console.log("session_key 过期")
  214. // session_key 已经失效,需要重新执行登录流程
  215. tt.login({
  216. success: (res) => {
  217. if (res.code) {
  218. let usrdata = {
  219. appId: app.globalData.appId,
  220. code: res.code,
  221. }
  222. Http.post({
  223. url: config.api.login,
  224. data: usrdata
  225. }).then(res => {
  226. Http.setToken(res.data.token);
  227. app.globalData.token = res.data.token;
  228. })
  229. }
  230. }
  231. })
  232. }
  233. })
  234. },
  235. bindGetUserInfo(e) {
  236. //session_key 未过期,并且在本生命周期一直有效 tt.getUserProfile
  237. tt.getUserProfile({
  238. withCredentials: true,
  239. title: '温馨提示',
  240. desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  241. success: (res) => {
  242. let that = this;
  243. var iv = res.iv;
  244. var encryptedData = res.encryptedData;
  245. // console.log(res,"数据");
  246. // return
  247. tt.login({
  248. success: (res => {
  249. let {
  250. code
  251. } = res
  252. console.log(code, "code");
  253. Http.post({
  254. url: config.api.login,
  255. data: {
  256. code: code,
  257. appId: app.globalData.appId,
  258. systemInfo: JSON.stringify(app.globalData.systemInfo)
  259. }
  260. }).then(res => {
  261. Http.setToken(res.data.token);
  262. app.globalData.token = res.data.token
  263. Http.post({
  264. url: config.api.getUserInfo,
  265. data: {
  266. encryptedData: encryptedData,
  267. iv: iv
  268. }
  269. }).then(res => {
  270. if (app.globalData.type == 'gm' && that.data.id && that.data.gameId && that.data.url) { //游戏页面
  271. app.globalData.skipUrl = '/pages/game/index?url=' + that.data.url + "&id=" + that.data.id + "&gameId=" + that.data.gameId,
  272. app.globalData.skip = 'redirectTo'
  273. that.judgePhonelngo()
  274. return;
  275. }
  276. if (that.data.wjId) {
  277. app.globalData.skipUrl = `/pages/questionnaire/questionnaire?id=${that.data.wjId}`
  278. app.globalData.skip = 'redirectTo'
  279. that.judgePhonelngo()
  280. return;
  281. }
  282. if (that.data.mineFlag) {
  283. app.globalData.skipUrl = `/index/user`
  284. app.globalData.skip = 'redirectTo'
  285. that.judgePhonelngo()
  286. return;
  287. }
  288. if (that.data.fromflag == 'poster') {
  289. app.globalData.skipUrl = `/pages/canvas/index?couponChannelId=${that.data.couponChannelId}`
  290. app.globalData.skip = 'redirectTo'
  291. that.judgePhonelngo()
  292. return;
  293. }
  294. //
  295. if (that.data.optionData != null && that.data.optionData.orderGroupId != null && that.data.optionData.orderGroupId != "") {
  296. 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}`
  297. app.globalData.skip = 'reLaunch'
  298. that.judgePhonelngo()
  299. return;
  300. }
  301. if (that.data.path == 'index') {
  302. app.globalData.skipUrl = "/pages/game/index"
  303. app.globalData.skip = 'reLaunch'
  304. that.judgePhonelngo()
  305. } else {
  306. //返回主页
  307. // if (that.data.couponChannelId && !that.data.cuserId && !that.data.spellGroup||that.data.couponChannelId && !that.data.cuserId&&app.globalData.type == 'cd') {
  308. if (that.data.couponChannelId && !that.data.cuserId && !that.data.spellGroup && app.globalData.type == 'cd') {
  309. // 跳转普通券/消费卡/限时秒杀/砍价详情
  310. app.globalData.skipUrl = `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}`
  311. app.globalData.skip = 'navigateTo'
  312. that.judgePhonelngo()
  313. } else if (that.data.couponChannelId && that.data.cuserId && !that.data.spellGroup && app.globalData.type != 'sd') {
  314. // 来自转赠
  315. 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}`
  316. app.globalData.skip = 'reLaunch'
  317. that.judgePhonelngo()
  318. } else if (that.data.couponChannelId && app.globalData.type == 'sd' || that.data.couponChannelId && that.data.spellGroup) {
  319. // 拼团详情页
  320. app.globalData.skipUrl = `/pages/spellGroup/mySpellGroup/index?couponChannelId=${that.data.couponChannelId}`
  321. app.globalData.skip = 'redirectTo'
  322. that.judgePhonelngo()
  323. } else if (that.data.optionData != null && that.data.optionData.id && app.globalData.type == 'gm') {
  324. // 游戏页面
  325. that.getGameOne(app.globalData.token, that.data.optionData.id)
  326. } else if (that.data.optionData != null && that.data.optionData.id && app.globalData.type == 'td') {
  327. app.globalData.skipUrl = `/pages/topicDetail/index?id=${that.data.optionData.id}`
  328. app.globalData.skip = 'redirectTo'
  329. that.judgePhonelngo()
  330. }
  331. // 报名活动
  332. else if (that.data.optionData != null && that.data.optionData.id && app.globalData.type == 'ra') {
  333. app.globalData.skipUrl = `/pages/radetail/index?id=${that.data.optionData.id}`,
  334. app.globalData.skip = 'redirectTo'
  335. that.judgePhonelngo()
  336. }
  337. // 报名签到
  338. else if (that.data.optionData != null && that.data.optionData.id && app.globalData.type == 'si') {
  339. app.globalData.skipUrl = `/pages/acSignIn/index?id=${that.data.optionData.id}`,
  340. app.globalData.skip = 'redirectTo'
  341. that.judgePhonelngo()
  342. }
  343. // 门店详情
  344. else if (that.data.optionData != null && that.data.optionData.id && app.globalData.type == 'md') {
  345. app.globalData.skipUrl = `/pages/index/searchbar/detail/index?id=${that.data.optionData.id}`,
  346. app.globalData.skip = 'redirectTo'
  347. that.judgePhonelngo()
  348. }
  349. // 通过分享进入的门店详情页面
  350. else if (that.data.id && that.data.frommd == 'md') {
  351. app.globalData.skipUrl = `/pages/index/searchbar/detail/index?id=${that.data.id}`,
  352. app.globalData.skip = 'redirectTo'
  353. that.judgePhonelngo()
  354. } else if (that.data.optionData != null && that.data.optionData.bt && that.data.optionData.id && app.globalData.type == 'bd') {
  355. // 宣传页详情
  356. if (that.data.optionData != null && that.data.optionData.bt == '2') {
  357. // 自由图文
  358. app.globalData.skipUrl = `/pages/freeBannerDetail/index?id=${that.data.optionData.id}`,
  359. app.globalData.skip = 'redirectTo'
  360. that.judgePhonelngo()
  361. } else {
  362. // 标准格式
  363. app.globalData.skipUrl = `/pages/bannerdetail/index?id=${that.data.optionData.id}`,
  364. app.globalData.skip = 'redirectTo'
  365. that.judgePhonelngo()
  366. }
  367. } else if (that.data.orderId || that.data.orderId && app.globalData.type == 'bg') {
  368. // 参与砍价
  369. app.globalData.skipUrl = `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.orderId}&composeOrderType=${that.composeOrderType}`,
  370. app.globalData.skip = 'navigateTo'
  371. that.judgePhonelngo()
  372. } else if (app.globalData.type == 'uc') {
  373. // 我的
  374. app.globalData.skipUrl = '/index/user',
  375. app.globalData.skip = 'redirectTo'
  376. that.judgePhonelngo()
  377. } else if (app.globalData.type == 'in') {
  378. // 首页
  379. app.globalData.skipUrl = app.globalData.goHomeUrl,
  380. app.globalData.skip = 'redirectTo'
  381. that.judgePhonelngo()
  382. } else if (app.globalData.type == "qd") {
  383. //每日签到
  384. app.globalData.skipUrl = "/pages/activityCalendar/activityCalendar"
  385. app.globalData.skip = 'reLaunch'
  386. that.judgePhonelngo()
  387. } else if (app.globalData.type == "hdrl") {
  388. //活动日历
  389. app.globalData.skipUrl = `/pages/radetail/index?id=${app.globalData.activityId}`
  390. app.globalData.skip = 'redirectTo'
  391. that.judgePhonelngo()
  392. }
  393. // 积分
  394. else if (app.globalData.type == 'jf') {
  395. app.globalData.skipUrl = '/pages/integralmall/index',
  396. app.globalData.skip = 'redirectTo'
  397. that.judgePhonelngo()
  398. } else if (app.globalData.type == 'pc') {
  399. // 停车
  400. app.globalData.skipUrl = '/index/passCar',
  401. app.globalData.skip = 'redirectTo'
  402. that.judgePhonelngo()
  403. } else if (app.globalData.type == 'mc') {
  404. // 我的券包
  405. app.globalData.skipUrl = '/pages/couponorder/index/index',
  406. app.globalData.skip = 'redirectTo'
  407. that.judgePhonelngo()
  408. } else if (app.globalData.type == 'mo') {
  409. // 我的订单
  410. app.globalData.skipUrl = '/pages/order/index/index?id=all',
  411. app.globalData.skip = 'redirectTo'
  412. that.judgePhonelngo()
  413. } else if (app.globalData.type == 'ca') {
  414. // 我的卡包
  415. app.globalData.skipUrl = '/pages/cardorder/index/index',
  416. app.globalData.skip = 'redirectTo'
  417. that.judgePhonelngo()
  418. } else if (app.globalData.type == 'sc') {
  419. // 特享礼遇
  420. app.globalData.skipUrl = '/pages/specialcourtesy/specialcourtesy',
  421. app.globalData.skip = 'redirectTo'
  422. that.judgePhonelngo()
  423. } else if (app.globalData.type == 'rb') {
  424. // 限时秒杀
  425. app.globalData.skipUrl = '/pages/rushToBuy/index',
  426. app.globalData.skip = 'redirectTo'
  427. that.judgePhonelngo()
  428. } else if (app.globalData.type == 'bl') {
  429. // 砍价专场
  430. app.globalData.skipUrl = '/pages/bargain/bargain',
  431. app.globalData.skip = 'redirectTo'
  432. that.judgePhonelngo()
  433. } else if (app.globalData.type == 'mb') {
  434. // 我的砍价
  435. app.globalData.skipUrl = '/pages/bargain/bargain?from=myhtml',
  436. app.globalData.skip = 'redirectTo'
  437. that.judgePhonelngo()
  438. } else if (app.globalData.type == 'sl') {
  439. // 拼团专场
  440. app.globalData.skipUrl = '/pages/spellGroup/spellGroup',
  441. app.globalData.skip = 'redirectTo'
  442. that.judgePhonelngo()
  443. } else if (app.globalData.type == 'ms') {
  444. // 我的拼团
  445. app.globalData.skipUrl = '/pages/spellGroup/spellGroup?from=myhtml',
  446. app.globalData.skip = 'redirectTo'
  447. that.judgePhonelngo()
  448. } else if (app.globalData.type == 'dc') {
  449. // 消费卡
  450. app.globalData.skipUrl = '/pages/discountCardList/discountCardList',
  451. app.globalData.skip = 'redirectTo'
  452. that.judgePhonelngo()
  453. } else if (app.globalData.type == 'td') {
  454. // 专题活动页
  455. app.globalData.skipUrl = '/pages/topicDetail/index',
  456. app.globalData.skip = 'redirectTo'
  457. that.judgePhonelngo()
  458. } else if (app.globalData.type == 'ml') {
  459. // 门店
  460. app.globalData.skipUrl = '/index/searchbar',
  461. app.globalData.skip = 'redirectTo'
  462. that.judgePhonelngo()
  463. } else if (that.data.fromflag == 'confirmation' && that.data.confirmationFlag) {
  464. //订单确认 confirmation
  465. app.globalData.skipUrl = `/pages/coupon/confirmation/confirmation?couponChannelId=${that.data.confirmationFlag}`,
  466. app.globalData.skip = 'redirectTo'
  467. that.judgePhonelngo()
  468. } else if (that.data.fromflag == 'coupondetail' && that.data.couponChannelIdflag) {
  469. app.globalData.skipUrl = `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelIdflag}`,
  470. app.globalData.skip = 'redirectTo'
  471. that.judgePhonelngo()
  472. } else if (that.data.fromflag == 'spellcoupondetail' && that.data.couponChannelIdflag) {
  473. app.globalData.skipUrl = `/pages/spellGroup/mySpellGroup/index?couponChannelId=${that.data.couponChannelIdflag}`,
  474. app.globalData.skip = 'redirectTo'
  475. that.judgePhonelngo()
  476. } else if (that.data.fromflag == 'fillIndent' && that.data.fillIndentId && that.data.couponId) {
  477. //线上配送 填写订单
  478. app.globalData.skipUrl = `/pages/fillIndent/fillIndent?id=${that.data.fillIndentId}&couponId=${that.data.couponId}`,
  479. app.globalData.skip = 'redirectTo'
  480. that.judgePhonelngo()
  481. } else {
  482. app.globalData.skipUrl = app.globalData.goHomeUrl,
  483. app.globalData.skip = 'redirectTo'
  484. that.judgePhonelngo()
  485. }
  486. }
  487. })
  488. .catch(err => {
  489. tt.showToast({
  490. title: err.code,
  491. icon: 'none',
  492. duration: 2000,
  493. mask: false
  494. });
  495. })
  496. }).catch(err => {
  497. console.log(err);
  498. tt.showModal({
  499. title: '提示',
  500. showCancel: false,
  501. content: '登录失败,请重新尝试',
  502. success: (res) => {
  503. if (res.cancel) {
  504. //点击取消,默认隐藏弹框
  505. } else {
  506. //点击确定
  507. tt.reLaunch({
  508. url: '/pages/index/index',
  509. })
  510. }
  511. }
  512. });
  513. })
  514. }),
  515. });
  516. },
  517. fail: (err => {
  518. console.log(err)
  519. })
  520. })
  521. },
  522. getGameOne: function (token, id) {
  523. let _this = this;
  524. Http.get({
  525. url: config.api.getOneGame,
  526. data: {
  527. token: token,
  528. id: id
  529. }
  530. }).then(res => {
  531. tt.redirectTo({
  532. url: '/pages/game/index?url=' + res.data.url + "&id=" + res.data.id + "&gameId=" + res.data.gameId,
  533. })
  534. })
  535. .catch(err => {
  536. tt.showModal({
  537. title: '提示',
  538. content: err.message,
  539. showCancel: false,
  540. success: function (res) {
  541. // 如果游戏下架或者找不到,重启首页
  542. if (res.confirm) {
  543. tt.reLaunch({
  544. url: '/pages/index/index',
  545. })
  546. }
  547. }
  548. })
  549. this.alphaClick();
  550. })
  551. },
  552. });