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

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