index.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <view class="main">
  3. <view class="one">
  4. <image class="logo" :src="logoUrl"></image>
  5. </view>
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. data() {
  11. return {
  12. logoUrl: ''
  13. };
  14. },
  15. onLoad: async function() {
  16. const that = this;
  17. await that.searchConfig();
  18. await that.searchOpenid();
  19. },
  20. methods: {
  21. // 查询基本设置
  22. async searchConfig() {
  23. const that = this;
  24. let res = await that.$api(`/config`, 'GET', {});
  25. if (res.errcode == '0') {
  26. that.$set(that, `logoUrl`, res.data.logo_url[0].url);
  27. uni.setStorage({
  28. key: 'config',
  29. data: res.data,
  30. success: function(res) {},
  31. fail: function(err) {
  32. console.log(err);
  33. }
  34. })
  35. }
  36. },
  37. async searchOpenid() {
  38. const that = this;
  39. try {
  40. const res = uni.getStorageSync('openid');
  41. const aee = await that.$api(`/login/wxapp/${res}`, 'POST', {})
  42. if (aee.errcode == '0') {
  43. uni.reLaunch({
  44. url: `/pages/home/index`
  45. })
  46. } else {
  47. uni.showToast({
  48. title: aee.errmsg,
  49. icon: 'none'
  50. })
  51. }
  52. } catch (e) {
  53. uni.showToast({
  54. title: err.errmsg,
  55. icon: 'error',
  56. duration: 2000
  57. });
  58. }
  59. }
  60. },
  61. }
  62. </script>
  63. <style lang="scss" scoped>
  64. .main {
  65. display: flex;
  66. align-items: center;
  67. justify-content: center;
  68. width: 100vw;
  69. height: 100vh;
  70. .one {
  71. .logo {
  72. width: 50vw;
  73. height: 50vw;
  74. border-radius: 90px;
  75. box-shadow: 0 0 5px var(--f1Color);
  76. }
  77. }
  78. }
  79. </style>