App.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <script>
  2. export default {
  3. // 此处globalData为了演示其作用,不是uView框架的一部分
  4. globalData: {
  5. username: '白居易',
  6. appid: 'wxbf3a12d4b07dfcbf',
  7. uploadUrl: '',
  8. navHeight: 0,
  9. },
  10. onLaunch(options) {
  11. let that=this
  12. // console.log(that.globalData,'this.globalDatathis.globalData')
  13. let res = uni.getSystemInfoSync();
  14. let menu = wx.getMenuButtonBoundingClientRect();
  15. let statusBarHeight = menu.height;
  16. // this.statusBarHeight = (menu.top - res.statusBarHeight) * 2 + menu.height + res.statusBarHeight;
  17. if (res.model.indexOf('iPhone') > -1) {
  18. statusBarHeight += 4
  19. }
  20. that.globalData.navHeight = statusBarHeight + uni.getSystemInfoSync().statusBarHeight
  21. if (!this.vuex_token) {
  22. uni.reLaunch({
  23. url:'pages/login/login'
  24. })
  25. }
  26. // else{
  27. // uni.reLaunch({
  28. // url:'pages/index/index'
  29. // })
  30. // }
  31. },
  32. methods: {
  33. async doLogin() {
  34. uni.login({
  35. provider: 'weixin',
  36. success: (res) => {
  37. console.log(res, 'ppp')
  38. console.log(this.$vm.$u, 'ppppp-----1212')
  39. if (res.code) {
  40. let data = {
  41. appid: 'wxbf3a12d4b07dfcbf',
  42. code: res.code
  43. }
  44. this.$vm.$u.post('/base/auth/weapp/login', data).then(res => {
  45. this.$vm.$u.vuex('vuex_token', res.data.token);
  46. this.$vm.$u.vuex('vuex_session_key', res.data.session_key);
  47. this.$vm.$u.vuex('vuex_is_auth', res.data.is_auth);
  48. this.$vm.$u.vuex('vuex_user', res.data.user);
  49. this.$vm.$u.vuex('vuex_exp', res.data.exp)
  50. })
  51. }
  52. }
  53. })
  54. },
  55. transformWeek(week) {
  56.     switch (week) {
  57.       case 0:
  58.         return '一'
  59.       case 1:
  60.         return '二'
  61.       case 2:
  62.         return '三'
  63.       case 3:
  64.         return '四'
  65.       case 4:
  66.         return '五'
  67.       case 5:
  68.         return '六'
  69.       case 6:
  70.         return '日'
  71.     }
  72.   },
  73. },
  74. }
  75. </script>
  76. <style lang="scss">
  77. @import "uview-ui/index.scss";
  78. @import "common/demo.scss";
  79. u-loadmore{
  80. margin-top: 10px;
  81. }
  82. </style>