-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.vue
More file actions
184 lines (178 loc) · 5.2 KB
/
App.vue
File metadata and controls
184 lines (178 loc) · 5.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<script>
import commonUtil from "@/utils/common-util";
export default {
globalData: {
systemInfo: {},
privateKey: "",
entryH5: "",
normalList: [],
refundList: [],
userId: "",
shareInfo: {
title: "",
cover: "",
desc: ""
},
version: "1.0.5",
},
onLaunch() {
var that = this;
uni.getSystemInfo({
success(res) {
that.globalData.systemInfo = res;
}
});
},
created() {
// #ifdef H5
this.initFontSize();
this.iphoneKeyBoard();
// #endif
},
methods: {
isIos() {
var platform = this.getPlatForm();
return platform == "ios";
},
isAndroid() {
var platform = this.getPlatForm();
return platform == "android";
},
getPlatForm() {
return this.globalData.systemInfo["platform"] || uni.getSystemInfoSync()["platform"];
},
getSystemInfo() {
var obj = this.globalData.systemInfo;
if (typeof (obj["SDKVersion"]) == "undefined") {
obj = uni.getSystemInfoSync();
}
obj["version"] = this.globalData.version;
return obj;
},
getSystemWidth() {
return this.globalData.systemInfo.windowWidth || uni.getSystemInfoSync().windowWidth;
},
getSystemScreenHeight: function () {
var systemInfo = this.getSystemInfo();
var version = systemInfo["SDKVersion"];
var ret = commonUtil.tools.versionCompare(version, "2.20.1");
var screenHeight = 0;
if (ret >= 0) {
const windowInfo = uni.getWindowInfo()
screenHeight = windowInfo.screenHeight;
} else {
screenHeight = this.globalData.systemInfo.screenHeight || uni.getSystemInfoSync().screenHeight;
}
return screenHeight
},
getSystemHeight() {
var systemInfo = this.getSystemInfo();
var version = systemInfo["SDKVersion"];
var ret = commonUtil.tools.versionCompare(version, "2.20.1");
var winHeight = 0;
var screenHeight = 0;
if (ret >= 0) {
const windowInfo = uni.getWindowInfo()
winHeight = windowInfo.windowHeight;
screenHeight = windowInfo.screenHeight;
} else {
winHeight = this.globalData.systemInfo.windowHeight || uni.getSystemInfoSync().windowHeight;
screenHeight = this.globalData.systemInfo.screenHeight || uni.getSystemInfoSync().screenHeight;
}
if (screenHeight == winHeight) {
if (this.isAndroid()) {
// android 高度
return winHeight - 77;
} else {
return winHeight - 88;
}
} else {
return winHeight;
}
},
getRefId() {
return this.globalData.userId;
},
getSharePath(url) {
let schema = "";
// #ifdef H5
schema = window.location.protocol + "//" + window.location.host;
// #endif
if (url != "") {
return schema + "/pages/login";
} else {
return schema + "/pages/login";
}
},
catSharePath(scene) {
let schema = "";
let rid = this.getRefId();
// #ifdef H5
schema = window.location.protocol + "//" + window.location.host;
// #endif
return schema + "/pages/login?scene=" + scene + ",p:" + rid;
},
getPageOpt() {
let pages = getCurrentPages();
if (pages.length == 0) {
return {};
}
let curPage = pages[pages.length - 1];
let curParam = curPage.options || curPage.$route.query;
let cloneParam = uni.$u.deepClone(curParam);
let attr = ["rand", "sign", "url", "version"];
for (let i = 0; i < attr.length; i++) {
if (typeof (cloneParam[attr[i]]) != "undefined") {
delete cloneParam[attr[i]];
}
}
return cloneParam;
},
getScene() {
let launchOpt = uni.getLaunchOptionsSync();
let query = launchOpt.query;
if (typeof (query["scene"]) == "undefined") {
return ""
}
return query["scene"];
},
handleFontSize() {
// 设置网页字体为默认大小
WeixinJSBridge.invoke('setFontSizeCallback', {'fontSize': 0});
// 重写设置网页字体大小的事件
WeixinJSBridge.on('menu:setfont', function () {
WeixinJSBridge.invoke('setFontSizeCallback', {'fontSize': 0});
});
},
initFontSize() {
if (typeof WeixinJSBridge == "object" && typeof WeixinJSBridge.invoke == "function") {
this.handleFontSize();
} else {
if (document.addEventListener) {
document.addEventListener("WeixinJSBridgeReady", this.handleFontSize, false);
} else if (document.attachEvent) {
document.attachEvent("WeixinJSBridgeReady", this.handleFontSize);
document.attachEvent("onWeixinJSBridgeReady", this.handleFontSize);
}
}
},
iphoneKeyBoard() {
if (/iphone|ipod|ipad/i.test(navigator.appVersion)) {
// this.globalData.entryH5 = window.location.href.split('#')[0];
}
(/iphone|ipod|ipad/i.test(navigator.appVersion)) && document.addEventListener('blur', () => {
document.body.scrollIntoView(false)
}, true);
}
}
}
</script>
<style lang="scss">
@import "@/uview-plus/index.scss";
@import "@/static/css/style.scss";
.oil_box{
.u-collapse-item__content__text{
padding:0 15px !important;
}
}
</style>