admin
2020-05-26 c6b8dd48f76b3cce5a8e5c91ba7b4efc91bba54d
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
var yesApp = {
    getPlatform: function() {
        var u = navigator.userAgent;
        var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1;
        if (isAndroid)
            return 1;
        else
            return 2;
    },
    login: function() {
        if (yesApp.getPlatform() == 1)
            yestv.login();
        else {
            try {
                yestv.login();
            } catch (e) { //wkwebview兼容
                window.webkit.messageHandlers.login.postMessage(null);
            }
        }
    },
    getUid: function() {
        if (yesApp.getPlatform() == 1)
            return yestv.getUid();
        else {
            try {
                var uid = yestv.getUid();
 
            } catch (e) { //wkwebview兼容
                var payload = {
                    type: 'getUid'
                };
                var uid = prompt(JSON.stringify(payload));
                return uid;
            }
        }
    },
    getRequestBaseParams: function(params) {
        if (yesApp.getPlatform() == 1)
            return yestv.getRequestBaseParams(JSON.stringify(params));
        else {
            try {
                return yestv.getRequestBaseParams(JSON.stringify(params));
            } catch (e) { //wkwebview兼容
                var payload = {
                    type: 'getRequestBaseParams',
                    params: JSON.stringify(params)
                };
                var result = prompt(JSON.stringify(payload));
                return result;
            }
        }
    },
    jumpPage: function(jumpDetail, params) {
        if(params==null||params==undefined)
            params={}
        if (yesApp.getPlatform() == 1)
            yestv.jumpPage(jumpDetail.activity, JSON.stringify(params));
        else {
            try {
                yestv.jumpPage(jumpDetail.controller, JSON.stringify(params));
            } catch (e) { //wkwebview兼容
                window.webkit.messageHandlers.jumpPage.postMessage({
                    controller: jumpDetail.controller,
                    params: JSON.stringify(params)
                });
            }
        }
    },
    showLoading: function() {
        if (yesApp.getPlatform() == 1)
            yestv.showLoading();
        else {
            try {
                yestv.showLoading();
            } catch (e) { //wkwebview兼容
                window.webkit.messageHandlers.showLoading.postMessage(null);
            }
        }
    },
    hideLoading: function() {
        if (yesApp.getPlatform() == 1)
            yestv.hideLoading();
        else {
            try {
                yestv.hideLoading();
            } catch (e) { //wkwebview兼容
                window.webkit.messageHandlers.hideLoading.postMessage(null);
            }
        }
    },
    toast: function(msg) {
        if (yesApp.getPlatform() == 1)
            yestv.toast(msg);
        else {
            try {
                yestv.toast(msg);
            } catch (e) { //wkwebview兼容
                window.webkit.messageHandlers.toast.postMessage(msg);
            }
        }
    },
 
    finishPage: function() {
        if (yesApp.getPlatform() == 1)
            yestv.finishPage();
        else {
            try {
                yestv.finishPage();
            } catch (e) { //wkwebview兼容
                window.webkit.messageHandlers.finishPage.postMessage(null);
            }
        }
    },
    //跳转客服
    jumpKeFu: function(from) {
        if (yesApp.getPlatform() == 1)
            yestv.jumpKeFu(from);
        else {
            try {
                yestv.jumpKeFu(from);
            } catch (e) { //wkwebview兼容
                window.webkit.messageHandlers.jumpKeFu.postMessage(from);
            }
        }
    },
    //跳转客服
    jumpKeFu: function(from) {
        if (yesApp.getPlatform() == 1)
            yestv.jumpKeFu(from);
        else {
            try {
                yestv.jumpKeFu(from);
            } catch (e) { //wkwebview兼容
                window.webkit.messageHandlers.jumpKeFu.postMessage(from);
            }
        }
    },
    jumpGoodsSplashWithFrom: function(goodsId, from) {
        if (yesApp.getPlatform() == 1)
            yestv.jumpGoodsSplashWithFrom(goodsId, from);
        else {
            try {
                yestv.jumpGoodsSplashWithFrom(goodsId, from);
            } catch (e) { //wkwebview兼容
                window.webkit.messageHandlers.jumpGoodsSplashWithFrom.postMessage({
                    id: goodsId,
                    from: from
                });
            }
        }
    }
}