123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <script>
-
- export default {
- onLaunch: function() {
- this.fontSizeSetting()
- uni.toast = (...args) => uni.showToast({
- duration: 5678,
- title: args[0],
- icon: 'none'
- });
- },
- onHide: function() {
- console.log('App Hide')
- },
- methods: {
- fontSizeSetting() {
- window.onload = function() {
- setAndroidFontsize();
- htmlFontSize()
- }
- window.onresize = function() {
- setAndroidFontsize();
- htmlFontSize()
- }
-
- function setAndroidFontsize() {
- if (typeof window.WeixinJSBridge == "object" && typeof window.WeixinJSBridge.invoke == "function") {
- handleFontSize();
- } else {
- if (document.addEventListener) {
- document.addEventListener("WeixinJSBridgeReady", handleFontSize, false);
- } else if (document.attachEvent) {
- document.attachEvent("WeixinJSBridgeReady", handleFontSize);
- document.attachEvent("onWeixinJSBridgeReady", handleFontSize);
- }
- }
- }
- function handleFontSize() {
- window.WeixinJSBridge.invoke('setFontSizeCallback', {
- 'fontSize': 0
- });
- window.WeixinJSBridge.on('menu:setfont', function() {
- window.WeixinJSBridge.invoke('setFontSizeCallback', {
- 'fontSize': 0
- });
- });
- }
-
- function htmlFontSize() {
- var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
- var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
- var width = w > h ? h : w;
- width = width > 720 ? 720 : width
- var fz = ~~(width / 15)
- document.getElementsByTagName("html")[0].style.cssText = 'font-size: ' + fz + "px";
- var realfz = ~~(+window.getComputedStyle(document.getElementsByTagName("html")[0]).fontSize.replace(
- 'px', '') *
- 10000) / 10000
- if (fz !== realfz) {
- document.getElementsByTagName("html")[0].style.cssText = 'font-size: ' + fz * (fz / realfz) + "px";
- }
- }
- }
- }
- }
- </script>
- <style lang="scss">
- @import './static/css/iconfont.css';
- @import 'common/style/icon.scss'; //引入 ColorUI 组件库图标样式
- /*每个页面公共css */
- page {
- background-color: #F5F5F5;
- font-size: 28rpx;
- }
- .flexV {
- display: flex;
- align-items: center;
- }
- .flexC {
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .flexS {
- display: flex;
- align-items: center;
- justify-content: flex-start;
- }
- .flexB {
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .flexT {
- display: flex;
- justify-content: space-between;
- align-items: flex-start;
- }
- </style>
|