app.wpy 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <style lang="less">
  2. page {
  3. width: 100%;
  4. height: 100%;
  5. }
  6. .container {
  7. height: 100%;
  8. box-sizing: border-box;
  9. }
  10. </style>
  11. <script>
  12. import wepy from 'wepy'
  13. import 'wepy-async-function'
  14. import { setStore } from 'wepy-redux'
  15. import configStore from './store'
  16. const store = configStore()
  17. setStore(store)
  18. export default class extends wepy.app {
  19. config = {
  20. pages: [
  21. 'pages/index',
  22. 'pages/detail'
  23. ],
  24. window: {
  25. backgroundTextStyle: 'light',
  26. navigationBarBackgroundColor: '#8397FF',
  27. navigationBarTitleText: '智能共享白板',
  28. navigationBarTextStyle: '#fff'
  29. }
  30. }
  31. globalData = {
  32. userInfo: null
  33. }
  34. constructor () {
  35. super()
  36. this.use('requestfix')
  37. }
  38. onLaunch() {
  39. this.testAsync()
  40. }
  41. sleep (s) {
  42. return new Promise((resolve, reject) => {
  43. setTimeout(() => {
  44. resolve('promise resolved')
  45. }, s * 1000)
  46. })
  47. }
  48. async testAsync () {
  49. const data = await this.sleep(3)
  50. console.log(data)
  51. }
  52. getUserInfo(cb) {
  53. const that = this
  54. if (this.globalData.userInfo) {
  55. return this.globalData.userInfo
  56. }
  57. wepy.getUserInfo({
  58. success (res) {
  59. that.globalData.userInfo = res.userInfo
  60. cb && cb(res.userInfo)
  61. }
  62. })
  63. }
  64. }
  65. </script>