| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- <script>
- import { RequestApi } from '@/api/requestApi';
- import { useGlobalStore } from '@/stores/global';
- export default {
- onLaunch: function () {
- this.listenNetwork();
- },
- onShow: function () {
- console.log('App Show');
- let global = useGlobalStore();
- global.setAppHide(false);
- this.initNetworkStatus();
- },
- onHide: function () {
- console.log('App Hide');
- let global = useGlobalStore();
- global.setAppHide(true);
- },
- data() {
- return {
- globalStore: useGlobalStore()
- };
- },
- methods: {
- loadBasic() {
- RequestApi.getBasic().then((basic) => {
- this.globalStore.setBasic(basic);
- });
- },
- loadService() {
- RequestApi.getService().then((service) => {
- this.globalStore.setService(service);
- });
- },
- initNetworkStatus() {
- uni.getNetworkType({
- success: (e) => {
- if (e.networkType != 'none') {
- this.globalStore.setNetworkIsConnected(true);
- this.loadBasic();
- this.loadService();
- } else {
- this.globalStore.setNetworkIsConnected(false);
- }
- }
- });
- },
- listenNetwork() {
- uni.onNetworkStatusChange((e) => {
- this.globalStore.setNetworkIsConnected(e.isConnected);
- if (e.isConnected) {
- this.loadBasic();
- this.loadService();
- }
- });
- }
- }
- };
- </script>
- <style lang="scss">
- @import '@/static/global.scss';
- view {
- -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
- tap-highlight-color: rgba(0, 0, 0, 0);
- }
- // @font-face {
- // font-family: 'PingFang SC';
- // src: url(getImageUrl('/fonts/PingFang_SC_Thin.ttf')) format('truetype');
- // font-weight: 100;
- // }
- // @font-face {
- // font-family: 'PingFang SC';
- // src: url(getImageUrl('/fonts/PingFang_SC_ExtraLight.ttf')) format('truetype');
- // font-weight: 200;
- // }
- // @font-face {
- // font-family: 'PingFang SC';
- // src: url(getImageUrl('/fonts/PingFang_SC_Light.ttf')) format('truetype');
- // font-weight: 300;
- // }
- // @font-face {
- // font-family: 'PingFang SC';
- // src: url(getImageUrl('/fonts/PingFang_SC_Regular.ttf')) format('truetype');
- // font-weight: 400;
- // }
- // @font-face {
- // font-family: 'PingFang SC';
- // src: url(getImageUrl('/fonts/PingFang_SC_Medium.ttf')) format('truetype');
- // font-weight: 500;
- // }
- // @font-face {
- // font-family: 'PingFang SC';
- // src: url(getImageUrl('/fonts/PingFang_SC_Semibold.ttf')) format('truetype');
- // font-weight: 00;
- // }
- .uni-load-more {
- height: unset !important;
- }
- </style>
- <style>
- /* 自定义全局样式 */
- /deep/ .markdown-body {
- padding: 20rpx;
- font-size: 28rpx;
- line-height: 1.6;
- }
- /deep/ pre {
- padding: 20rpx;
- background: #f8f8f8;
- border-radius: 8rpx;
- overflow-x: auto;
- }
- /deep/ .uni-load-more {
- height: unset !important;
- }
- </style>
|