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

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