index.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <view class="main">
  3. <view class="one">
  4. <image class="logo" :src="logoUrl||'/static/logo.jpg'"></image>
  5. </view>
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. data() {
  11. return {
  12. logoUrl: ''
  13. };
  14. },
  15. onShow: async function() {
  16. const that = this;
  17. await that.searchConfig();
  18. await that.search();
  19. },
  20. methods: {
  21. // 查询基本设置
  22. async searchConfig() {
  23. const that = this;
  24. const arr = await that.$api(`/design`, 'GET', {});
  25. if (arr.errcode == '0') {
  26. that.$set(that, `logoUrl`, arr.data[0].logoUrl[0]?.url);
  27. uni.setStorage({
  28. key: 'config',
  29. data: arr.data[0],
  30. })
  31. }
  32. },
  33. search() {
  34. const that = this;
  35. uni.getStorage({
  36. key: 'openid',
  37. success: function(res) {
  38. uni.reLaunch({
  39. url: `/pages/home/index`
  40. })
  41. },
  42. fail: function(err) {
  43. uni.login({
  44. success: async function(res) {
  45. if (res.code) {
  46. const aee = await that.$app('/wechat/api/login/app', 'GET', {
  47. js_code: res.code,
  48. config: that.$config.wx_projectkey
  49. })
  50. if (aee.errcode == '0') {
  51. uni.setStorage({
  52. key: "openid",
  53. data: aee.data.openid
  54. })
  55. uni.reLaunch({
  56. url: `/pages/home/index`
  57. })
  58. } else {
  59. uni.showToast({
  60. title: aee.errmsg,
  61. icon: 'none'
  62. })
  63. }
  64. } else {
  65. uni.showToast({
  66. title: res.errMsg,
  67. icon: 'none'
  68. })
  69. }
  70. }
  71. });
  72. }
  73. })
  74. }
  75. },
  76. }
  77. </script>
  78. <style lang="scss" scoped>
  79. .main {
  80. display: flex;
  81. align-items: center;
  82. justify-content: center;
  83. width: 100vw;
  84. height: 100vh;
  85. .one {
  86. .logo {
  87. width: 50vw;
  88. height: 50vw;
  89. // border-radius: 90px;
  90. box-shadow: 0 0 5px var(--f1Color);
  91. }
  92. }
  93. }
  94. </style>