抖音c端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

517 行
19 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 未过期,并且在本生命周期一直有效
  230. tt.getUserInfo({
  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. Http.post({
  241. url: config.api.getUserInfo,
  242. data: {
  243. encryptedData: encryptedData,
  244. iv: iv
  245. }
  246. }).then(res => {
  247. if (app.globalData.type == 'gm' && that.data.id && that.data.gameId && that.data.url) {//游戏页面
  248. app.globalData.skipUrl = '/pages/game/index?url=' + that.data.url + "&id=" + that.data.id + "&gameId=" + that.data.gameId,
  249. app.globalData.skip = 'redirectTo'
  250. that.judgePhonelngo()
  251. return;
  252. }
  253. if (that.data.wjId) {
  254. app.globalData.skipUrl = `/pages/questionnaire/questionnaire?id=${that.data.wjId}`
  255. app.globalData.skip = 'redirectTo'
  256. that.judgePhonelngo()
  257. return;
  258. }
  259. if (that.data.fromflag == 'poster') {
  260. app.globalData.skipUrl = `/pages/canvas/index?couponChannelId=${that.data.couponChannelId}`
  261. app.globalData.skip = 'redirectTo'
  262. that.judgePhonelngo()
  263. return;
  264. }
  265. //
  266. if (that.data.optionData != null && that.data.optionData.orderGroupId != null && that.data.optionData.orderGroupId != "") {
  267. 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}`
  268. app.globalData.skip = 'reLaunch'
  269. that.judgePhonelngo()
  270. return;
  271. }
  272. if (that.data.path == 'index') {
  273. app.globalData.skipUrl = "/pages/game/index"
  274. app.globalData.skip = 'reLaunch'
  275. that.judgePhonelngo()
  276. } else {
  277. //返回主页
  278. // if (that.data.couponChannelId && !that.data.cuserId && !that.data.spellGroup||that.data.couponChannelId && !that.data.cuserId&&app.globalData.type == 'cd') {
  279. if (that.data.couponChannelId && !that.data.cuserId && !that.data.spellGroup && app.globalData.type == 'cd') {
  280. // 跳转普通券/消费卡/限时秒杀/砍价详情
  281. app.globalData.skipUrl = `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}`
  282. app.globalData.skip = 'navigateTo'
  283. that.judgePhonelngo()
  284. } else if (that.data.couponChannelId && that.data.cuserId && !that.data.spellGroup && app.globalData.type != 'sd') {
  285. // 来自转赠
  286. 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}`
  287. app.globalData.skip = 'reLaunch'
  288. that.judgePhonelngo()
  289. } else if (that.data.couponChannelId && app.globalData.type == 'sd' || that.data.couponChannelId && that.data.spellGroup) {
  290. // 拼团详情页
  291. app.globalData.skipUrl = `/pages/spellGroup/mySpellGroup/index?couponChannelId=${that.data.couponChannelId}`
  292. app.globalData.skip = 'redirectTo'
  293. that.judgePhonelngo()
  294. } else if (that.data.optionData != null && that.data.optionData.id && app.globalData.type == 'gm') {
  295. // 游戏页面
  296. that.getGameOne(app.globalData.token, that.data.optionData.id)
  297. } else if (that.data.optionData != null && that.data.optionData.id && app.globalData.type == 'td') {
  298. app.globalData.skipUrl = `/pages/topicDetail/index?id=${that.data.optionData.id}`
  299. app.globalData.skip = 'redirectTo'
  300. that.judgePhonelngo()
  301. }
  302. // 报名活动
  303. else if (that.data.optionData != null && that.data.optionData.id && app.globalData.type == 'ra') {
  304. app.globalData.skipUrl = `/pages/radetail/index?id=${that.data.optionData.id}`,
  305. app.globalData.skip = 'redirectTo'
  306. that.judgePhonelngo()
  307. }
  308. // 报名签到
  309. else if (that.data.optionData != null && that.data.optionData.id && app.globalData.type == 'si') {
  310. app.globalData.skipUrl = `/pages/acSignIn/index?id=${that.data.optionData.id}`,
  311. app.globalData.skip = 'redirectTo'
  312. that.judgePhonelngo()
  313. }
  314. // 门店详情
  315. else if (that.data.optionData != null && that.data.optionData.id && app.globalData.type == 'md') {
  316. app.globalData.skipUrl = `/pages/index/searchbar/detail/index?id=${that.data.optionData.id}`,
  317. app.globalData.skip = 'redirectTo'
  318. that.judgePhonelngo()
  319. }
  320. // 通过分享进入的门店详情页面
  321. else if (that.data.id && that.data.frommd == 'md') {
  322. app.globalData.skipUrl = `/pages/index/searchbar/detail/index?id=${that.data.id}`,
  323. app.globalData.skip = 'redirectTo'
  324. that.judgePhonelngo()
  325. } else if (that.data.optionData != null && that.data.optionData.bt && that.data.optionData.id && app.globalData.type == 'bd') {
  326. // 宣传页详情
  327. if (that.data.optionData != null && that.data.optionData.bt == '2') {
  328. // 自由图文
  329. app.globalData.skipUrl = `/pages/freeBannerDetail/index?id=${that.data.optionData.id}`,
  330. app.globalData.skip = 'redirectTo'
  331. that.judgePhonelngo()
  332. } else {
  333. // 标准格式
  334. app.globalData.skipUrl = `/pages/bannerdetail/index?id=${that.data.optionData.id}`,
  335. app.globalData.skip = 'redirectTo'
  336. that.judgePhonelngo()
  337. }
  338. } else if (that.data.orderId || that.data.orderId && app.globalData.type == 'bg') {
  339. // 参与砍价
  340. app.globalData.skipUrl = `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.orderId}&composeOrderType=${that.composeOrderType}`,
  341. app.globalData.skip = 'navigateTo'
  342. that.judgePhonelngo()
  343. } else if (app.globalData.type == 'uc') {
  344. // 我的
  345. app.globalData.skipUrl = '/index/user',
  346. app.globalData.skip = 'redirectTo'
  347. that.judgePhonelngo()
  348. } else if (app.globalData.type == 'in') {
  349. // 首页
  350. app.globalData.skipUrl = app.globalData.goHomeUrl,
  351. app.globalData.skip = 'redirectTo'
  352. that.judgePhonelngo()
  353. } else if (app.globalData.type == "qd") {
  354. //每日签到
  355. app.globalData.skipUrl = "/pages/activityCalendar/activityCalendar"
  356. app.globalData.skip = 'reLaunch'
  357. that.judgePhonelngo()
  358. } else if (app.globalData.type == "hdrl") {
  359. //活动日历
  360. app.globalData.skipUrl = `/pages/radetail/index?id=${app.globalData.activityId}`
  361. app.globalData.skip = 'redirectTo'
  362. that.judgePhonelngo()
  363. }
  364. // 积分
  365. else if (app.globalData.type == 'jf') {
  366. app.globalData.skipUrl = '/pages/integralmall/index',
  367. app.globalData.skip = 'redirectTo'
  368. that.judgePhonelngo()
  369. } else if (app.globalData.type == 'pc') {
  370. // 停车
  371. app.globalData.skipUrl = '/index/passCar',
  372. app.globalData.skip = 'redirectTo'
  373. that.judgePhonelngo()
  374. } else if (app.globalData.type == 'mc') {
  375. // 我的券包
  376. app.globalData.skipUrl = '/pages/couponorder/index/index',
  377. app.globalData.skip = 'redirectTo'
  378. that.judgePhonelngo()
  379. } else if (app.globalData.type == 'mo') {
  380. // 我的订单
  381. app.globalData.skipUrl = '/pages/order/index/index?id=all',
  382. app.globalData.skip = 'redirectTo'
  383. that.judgePhonelngo()
  384. } else if (app.globalData.type == 'ca') {
  385. // 我的卡包
  386. app.globalData.skipUrl = '/pages/cardorder/index/index',
  387. app.globalData.skip = 'redirectTo'
  388. that.judgePhonelngo()
  389. } else if (app.globalData.type == 'sc') {
  390. // 特享礼遇
  391. app.globalData.skipUrl = '/pages/specialcourtesy/specialcourtesy',
  392. app.globalData.skip = 'redirectTo'
  393. that.judgePhonelngo()
  394. } else if (app.globalData.type == 'rb') {
  395. // 限时秒杀
  396. app.globalData.skipUrl = '/pages/rushToBuy/index',
  397. app.globalData.skip = 'redirectTo'
  398. that.judgePhonelngo()
  399. } else if (app.globalData.type == 'bl') {
  400. // 砍价专场
  401. app.globalData.skipUrl = '/pages/bargain/bargain',
  402. app.globalData.skip = 'redirectTo'
  403. that.judgePhonelngo()
  404. } else if (app.globalData.type == 'mb') {
  405. // 我的砍价
  406. app.globalData.skipUrl = '/pages/bargain/bargain?from=myhtml',
  407. app.globalData.skip = 'redirectTo'
  408. that.judgePhonelngo()
  409. } else if (app.globalData.type == 'sl') {
  410. // 拼团专场
  411. app.globalData.skipUrl = '/pages/spellGroup/spellGroup',
  412. app.globalData.skip = 'redirectTo'
  413. that.judgePhonelngo()
  414. } else if (app.globalData.type == 'ms') {
  415. // 我的拼团
  416. app.globalData.skipUrl = '/pages/spellGroup/spellGroup?from=myhtml',
  417. app.globalData.skip = 'redirectTo'
  418. that.judgePhonelngo()
  419. } else if (app.globalData.type == 'dc') {
  420. // 消费卡
  421. app.globalData.skipUrl = '/pages/discountCardList/discountCardList',
  422. app.globalData.skip = 'redirectTo'
  423. that.judgePhonelngo()
  424. } else if (app.globalData.type == 'td') {
  425. // 专题活动页
  426. app.globalData.skipUrl = '/pages/topicDetail/index',
  427. app.globalData.skip = 'redirectTo'
  428. that.judgePhonelngo()
  429. } else if (app.globalData.type == 'ml') {
  430. // 门店
  431. app.globalData.skipUrl = '/index/searchbar',
  432. app.globalData.skip = 'redirectTo'
  433. that.judgePhonelngo()
  434. } else if (that.data.fromflag == 'confirmation' && that.data.confirmationFlag) {
  435. //订单确认 confirmation
  436. app.globalData.skipUrl = `/pages/coupon/confirmation/confirmation?couponChannelId=${that.data.confirmationFlag}`,
  437. app.globalData.skip = 'redirectTo'
  438. that.judgePhonelngo()
  439. }
  440. else if (that.data.fromflag == 'coupondetail' && that.data.couponChannelIdflag) {
  441. app.globalData.skipUrl = `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelIdflag}`,
  442. app.globalData.skip = 'redirectTo'
  443. that.judgePhonelngo()
  444. } else if (that.data.fromflag == 'spellcoupondetail' && that.data.couponChannelIdflag) {
  445. app.globalData.skipUrl = `/pages/spellGroup/mySpellGroup/index?couponChannelId=${that.data.couponChannelIdflag}`,
  446. app.globalData.skip = 'redirectTo'
  447. that.judgePhonelngo()
  448. } else if (that.data.fromflag == 'fillIndent' && that.data.fillIndentId && that.data.couponId) {
  449. //线上配送 填写订单
  450. app.globalData.skipUrl = `/pages/fillIndent/fillIndent?id=${that.data.fillIndentId}&couponId=${that.data.couponId}`,
  451. app.globalData.skip = 'redirectTo'
  452. that.judgePhonelngo()
  453. } else {
  454. app.globalData.skipUrl = app.globalData.goHomeUrl,
  455. app.globalData.skip = 'redirectTo'
  456. that.judgePhonelngo()
  457. }
  458. }
  459. })
  460. .catch(err => {
  461. tt.showToast({
  462. title: err.code,
  463. icon: 'none',
  464. duration: 2000,
  465. mask: false
  466. });
  467. })
  468. },
  469. fail: (err => {
  470. console.log(err)
  471. })
  472. })
  473. },
  474. getGameOne: function (token, id) {
  475. let _this = this;
  476. Http.get({
  477. url: config.api.getOneGame,
  478. data: {
  479. token: token,
  480. id: id
  481. }
  482. }).then(res => {
  483. tt.redirectTo({
  484. url: '/pages/game/index?url=' + res.data.url + "&id=" + res.data.id + "&gameId=" + res.data.gameId,
  485. })
  486. })
  487. .catch(err => {
  488. tt.showModal({
  489. title: '提示',
  490. content: err.message,
  491. showCancel: false,
  492. success: function (res) {
  493. // 如果游戏下架或者找不到,重启首页
  494. if (res.confirm) {
  495. tt.reLaunch({
  496. url: '/pages/index/index',
  497. })
  498. }
  499. }
  500. })
  501. this.alphaClick();
  502. })
  503. },
  504. });