webview.js
1.47 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
import config from '../../config';
import { verify } from '../../common/api';
import commonModel from '../../models/common';
Page({
data: {
url: '',
title: '',
},
onLoad: function(options) {
if (options && options.scene && options.scene.length > 0) {
let code = options.scene;
return commonModel.getMiniAppRealParam(code)
.then(json => {
if (json) {
this.load(json);
}
})
.catch(() => {});
}
this.load(options);
},
onShareAppMessage: function() {
return {
title: this.data.title,
path: '/pages/webview/webview?url=' + this.data.url,
};
},
load: function(options) {
let app = getApp();
let url = options.url;
if (options && options.url) {
let params = {};
let sys = wx.getSystemInfoSync();
params.uid = app.getUid();
params.udid = app._getSync('udid');
params.session_key = app._getSync('sessionKey');
params.app_version = config.apiParams.app_version;
params.client_type = config.apiParams.client_type;
params.screen_size = `${sys.windowWidth}x${sys.windowHeight}`;
params.os_version = sys.version;
verify.sign(params);
this.setData({
url: decodeURIComponent(`${url}`)
});
}
},
bindGetMsg: function(e) {
if (e.detail && e.detail.data && e.detail.data[0] && e.detail.data[0].title) {
this.setData({
title: e.detail.data[0].title,
});
}
}
});