index.vue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <view class="main">
  3. {{info}}
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. data() {
  9. return {
  10. user: {},
  11. info: {},
  12. }
  13. },
  14. onLoad: async function(e) {
  15. const that = this;
  16. uni.setNavigationBarTitle({
  17. title: e && e.title || '分类'
  18. });
  19. await that.searchOther();
  20. that.searchToken();
  21. that.search();
  22. },
  23. methods: {
  24. searchToken() {
  25. const that = this;
  26. try {
  27. const res = uni.getStorageSync('token');
  28. if (res) that.$set(that, `user`, res);
  29. } catch (e) {
  30. uni.showToast({
  31. title: err.errmsg,
  32. icon: 'error',
  33. duration: 2000
  34. });
  35. }
  36. },
  37. // 查询
  38. async search() {
  39. const that = this;
  40. let res;
  41. res = await that.$api(`/config`, 'GET', {})
  42. if (res.errcode == '0') {
  43. that.$set(that, `info`, res.data)
  44. } else {
  45. uni.showToast({
  46. title: res.errmsg,
  47. });
  48. }
  49. },
  50. async searchOther() {
  51. const that = this;
  52. }
  53. }
  54. }
  55. </script>
  56. <style>
  57. .main {}
  58. </style>