-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
executable file
·124 lines (122 loc) · 3.05 KB
/
app.js
File metadata and controls
executable file
·124 lines (122 loc) · 3.05 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
import { config } from "./config";
import { cache_seek2 } from "./utils/util";
wx.setInnerAudioOption({
obeyMuteSwitch: false,
mixWithOther: true,
});
App({
get_api_version: function () {
return this.globalData.api_version;
},
globalData: {
show_ad: true,
fti: false,
play_mode: "one",
api_version: 20230619,
},
onHide() {},
onShow() {},
onUnload: function (e) {
cache_seek2();
},
onLaunch() {
var that = this;
wx.getStorage({
key: "fti",
success: (res) => {
if (res.data) {
that.globalData.fti = res.data;
}
},
});
wx.getStorage({
key: "play_mode",
success: (res) => {
if (res.data) {
that.globalData.play_mode = res.data;
}
},
});
wx.request({
url: config.service.host + "/version",
enableHttp2: true,
success: function (data) {
that.globalData.api_version = data.data.v;
},
});
this.check_ad();
},
get_open_id: function (callback) {
var app = this;
if (!app.globalData.open_id) {
wx.getStorage({
key: "user_open_id",
success: (res) => {
app.globalData.open_id = res.data;
callback(res.data);
},
fail: (e) => {
wx.login({
success: function (loginCode) {
wx.request({
url: config.service.host + "/user/auth/" + loginCode.code,
enableHttp2: true,
header: {
"content-type": "application/json",
},
success: function (res) {
if (res.statusCode == 200) {
if (res.data.code == 0) {
var open_id = res.data.data.openid;
wx.setStorage({
key: "user_open_id",
data: open_id,
});
app.globalData.open_id = open_id;
callback(open_id);
}
}
},
});
},
fail: function (e) {
wx.showToast({
title: "获取用户标识失败",
icon: "error",
});
},
});
},
});
} else {
callback(app.globalData.open_id);
}
},
check_ad: function () {
var app = this;
this.get_open_id((open_id) => {
if (!open_id || open_id.length == 0) {
app.globalData.show_ad = true;
return;
}
wx.request({
url: config.service.host + "/user/" + open_id + "/ad",
enableHttp2: true,
success: function (res) {
if (res.data.code == 0) {
if (res.data.data == "valid") {
app.globalData.show_ad = false;
} else {
app.globalData.show_ad = true;
}
return;
}
app.globalData.show_ad = true;
},
fail: function (res) {
app.globalData.show_ad = true;
},
});
});
},
});