App.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <script>
  2. export default {
  3. onLaunch: function() {
  4. this.createUser();
  5. },
  6. onShow: function() {
  7. console.log('App Show')
  8. },
  9. onHide: function() {
  10. console.log('App Hide')
  11. },
  12. methods: {
  13. //查询用户信息
  14. createUser() {
  15. let _this = this;
  16. // #ifdef H5
  17. this.$request
  18. .get({
  19. url: 'system/temporaryUser',
  20. loadingTip: "加载中..."
  21. })
  22. .then((res) => {
  23. uni.setStorageSync("user", res.data.user);
  24. uni.setStorageSync("token", res.data.token);
  25. });
  26. // #endif
  27. // #ifdef MP-TOUTIAO
  28. tt.login({
  29. success(res) {
  30. let para = {
  31. code: code,
  32. petName: '',
  33. modelPhone: '',
  34. };
  35. _this.$request
  36. .post({
  37. url: 'api/douyin/code2Session',
  38. data: para
  39. })
  40. .then(
  41. (res) => {
  42. uni.setStorageSync("user", res.data.user);
  43. uni.setStorageSync("token", res.data.token);
  44. },
  45. (err) => {
  46. console.log("登录失败", err);
  47. }
  48. );
  49. },
  50. })
  51. // #endif
  52. }
  53. }
  54. }
  55. </script>
  56. <style>
  57. /*每个页面公共css */
  58. @font-face {
  59. font-family: 'Alibaba PuHuiTi 2.0';
  60. src: url('../../static/images/EQtest/font/AlibabaPuHuiTi-2-55-Regular/AlibabaPuHuiTi-2-55-Regular.woff2') format('woff2'),
  61. url('../../static/images/EQtest/font/AlibabaPuHuiTi-2-55-Regular/AlibabaPuHuiTi-2-55-Regular.woff') format('woff'),
  62. url('../../static/images/EQtest/font/AlibabaPuHuiTi-2-55-Regular/AlibabaPuHuiTi-2-55-Regular.ttf') format('truetype');
  63. font-weight: normal;
  64. font-style: normal;
  65. font-display: swap;
  66. }
  67. </style>