|
@@ -189,6 +189,7 @@
|
|
|
src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"
|
|
|
></script>
|
|
|
<script src="https://cdn.bootcss.com/jquery-weui/1.2.1/js/jquery-weui.min.js"></script>
|
|
|
+ <script type="text/javascript" src="WXdraw.js"></script>
|
|
|
<script type="text/javascript" src="jmuxer.js"></script>
|
|
|
<script type="text/javascript" src="spsParser.js"></script>
|
|
|
<script
|
|
@@ -201,9 +202,9 @@
|
|
|
var baseUrl = url[0] + '//' + url[2];
|
|
|
|
|
|
var parameters = GetRequest();
|
|
|
- var token = parameters['token'];
|
|
|
- var userCardId = parameters['userCardId'];
|
|
|
- var mealType = parameters['mealType'];
|
|
|
+ var form = {};
|
|
|
+ form.token = parameters['token'];
|
|
|
+ form.userCardId = parameters['userCardId'];
|
|
|
var videoTimer = null,
|
|
|
videoTime = 0,
|
|
|
adType = 0,
|
|
@@ -231,92 +232,6 @@
|
|
|
$('.loading_sceen_pic').attr('src', '../static/img/home_bg_PRO.png');
|
|
|
}
|
|
|
initAD();
|
|
|
- let dbName = parameters['username'],
|
|
|
- version = 1,
|
|
|
- storeName = 'usercard';
|
|
|
- let indexedDB = window.indexedDB;
|
|
|
- let db, socketURL, cUrl, cardToken, resolvingPower;
|
|
|
- const request = indexedDB.open(dbName, version);
|
|
|
- request.onsuccess = function (event) {
|
|
|
- db = event.target.result; // 数据库对象
|
|
|
- console.log('数据库打开成功');
|
|
|
- };
|
|
|
-
|
|
|
- request.onerror = function (event) {
|
|
|
- console.log('数据库打开报错');
|
|
|
- };
|
|
|
-
|
|
|
- request.onupgradeneeded = function (event) {
|
|
|
- // 数据库创建或升级的时候会触发
|
|
|
- console.log('onupgradeneeded');
|
|
|
- db = event.target.result; // 数据库对象
|
|
|
- let objectStore;
|
|
|
- if (!db.objectStoreNames.contains(storeName)) {
|
|
|
- objectStore = db.createObjectStore(storeName, { keyPath: 'id' }); // 创建表
|
|
|
- }
|
|
|
- };
|
|
|
- // 添加数据
|
|
|
- function addData(db, storeName, data) {
|
|
|
- let request = db
|
|
|
- .transaction([storeName], 'readwrite') // 事务对象 指定表格名称和操作模式("只读"或"读写")
|
|
|
- .objectStore(storeName) // 仓库对象
|
|
|
- .add(data);
|
|
|
-
|
|
|
- request.onsuccess = function (event) {
|
|
|
- console.log('数据写入成功');
|
|
|
- };
|
|
|
-
|
|
|
- request.onerror = function (event) {
|
|
|
- console.log('数据写入失败');
|
|
|
- throw new Error(event.target.error);
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
- // 根据id获取数据
|
|
|
- function getDataByKey(db, storeName, key) {
|
|
|
- let transaction = db.transaction([storeName]); // 事务
|
|
|
- let objectStore = transaction.objectStore(storeName); // 仓库对象
|
|
|
- let request = objectStore.get(key);
|
|
|
-
|
|
|
- request.onerror = function (event) {
|
|
|
- connect('add');
|
|
|
- };
|
|
|
-
|
|
|
- request.onsuccess = function (event) {
|
|
|
- console.log('主键查询结果: ', request.result);
|
|
|
- if (request.result) {
|
|
|
- socketURL = request.result.socketURL;
|
|
|
- cUrl = request.result.cUrl;
|
|
|
- cardToken = request.result.cardToken;
|
|
|
- resolvingPower = request.result.resolvingPower;
|
|
|
- doConnectBusiness();
|
|
|
- doConnectDirectives();
|
|
|
- } else {
|
|
|
- connect('add');
|
|
|
- }
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
- // 根据id修改数
|
|
|
- function updateDB(db, storeName, data) {
|
|
|
- let request = db
|
|
|
- .transaction([storeName], 'readwrite') // 事务对象
|
|
|
- .objectStore(storeName) // 仓库对象
|
|
|
- .put(data);
|
|
|
-
|
|
|
- request.onsuccess = function () {
|
|
|
- console.log('数据更新成功');
|
|
|
- };
|
|
|
-
|
|
|
- request.onerror = function () {
|
|
|
- console.log('数据更新失败');
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
- // 由于打开indexDB是异步的加个定时器避免 db对象还没获取到值导致 报错
|
|
|
- setTimeout(() => {
|
|
|
- getDataByKey(db, storeName, userCardId);
|
|
|
- }, 1000);
|
|
|
var isAudioPlay = false;
|
|
|
if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
|
|
|
var video = document.getElementById('playerVideo');
|
|
@@ -376,72 +291,21 @@
|
|
|
Module.onRuntimeInitialized = function () {
|
|
|
isFinish = true;
|
|
|
};
|
|
|
- function connect() {
|
|
|
- $.ajax({
|
|
|
- url: baseUrl + '/api/resources/user/cloud/connect',
|
|
|
- type: 'post',
|
|
|
- data: JSON.stringify({
|
|
|
- userCardId: Number(userCardId),
|
|
|
- }),
|
|
|
- headers: {
|
|
|
- 'content-Type': 'application/json',
|
|
|
- Authorization: token,
|
|
|
- },
|
|
|
- dataType: 'json',
|
|
|
- async: false,
|
|
|
- success: function (res) {
|
|
|
- if (res.status === 0) {
|
|
|
- if (res.data.internetHttps) {
|
|
|
- socketURL =
|
|
|
- 'wss://' +
|
|
|
- res.data.internetHttps +
|
|
|
- '/plugflow?cardIp=' +
|
|
|
- res.data.localIp +
|
|
|
- '&token=' +
|
|
|
- res.data.cardToken +
|
|
|
- '&type=business';
|
|
|
- cUrl =
|
|
|
- 'wss://' +
|
|
|
- res.data.internetHttps +
|
|
|
- '/businessChannel?cardIp=' +
|
|
|
- res.data.localIp +
|
|
|
- '&token=' +
|
|
|
- res.data.cardToken +
|
|
|
- '&type=directives';
|
|
|
- cardToken = res.data.cardToken;
|
|
|
- resolvingPower = res.data.resolvingPower;
|
|
|
- doConnectBusiness();
|
|
|
- doConnectDirectives();
|
|
|
- if (type === 'add') {
|
|
|
- addData(db, storeName, {
|
|
|
- id: userCardId,
|
|
|
- socketURL: socketURL,
|
|
|
- cUrl: cUrl,
|
|
|
- cardToken: res.data.cardToken,
|
|
|
- resolvingPower: res.data.resolvingPower,
|
|
|
- });
|
|
|
- } else {
|
|
|
- updateDB(db, storeName, {
|
|
|
- id: userCardId,
|
|
|
- socketURL: socketURL,
|
|
|
- cUrl: cUrl,
|
|
|
- cardToken: res.data.cardToken,
|
|
|
- resolvingPower: res.data.resolvingPower,
|
|
|
- });
|
|
|
- }
|
|
|
- } else {
|
|
|
- $.toast('网络异常,请稍后重试', 'text');
|
|
|
- }
|
|
|
- } else {
|
|
|
- $.toast('画面异常,请重新进入', 'text');
|
|
|
- clearInterval(intervaler);
|
|
|
- quit();
|
|
|
- ws.close();
|
|
|
- wsss.close();
|
|
|
- }
|
|
|
- },
|
|
|
- });
|
|
|
- }
|
|
|
+
|
|
|
+ var isWSS = true;
|
|
|
+ var ip = parameters['ip'];
|
|
|
+ var cardToken = parameters['cardToken'];
|
|
|
+ cardToken = cardToken && decodeURIComponent(cardToken);
|
|
|
+ var appletPushAddress = parameters['appletPushAddress'];
|
|
|
+ var socketURL = isWSS
|
|
|
+ ? 'wss://' +
|
|
|
+ appletPushAddress +
|
|
|
+ '?cardIp=' +
|
|
|
+ ip +
|
|
|
+ '&token=' +
|
|
|
+ cardToken +
|
|
|
+ '&type=business'
|
|
|
+ : 'ws://' + appletPushAddress + '?cardIp=' + ip + '&token=' + cardToken;
|
|
|
|
|
|
var jmuxer = new JMuxer({
|
|
|
node: 'playerVideo',
|
|
@@ -460,7 +324,7 @@
|
|
|
};
|
|
|
var ws,
|
|
|
errorTime = 0;
|
|
|
-
|
|
|
+ doConnect();
|
|
|
// 节流
|
|
|
// 设置一个标志
|
|
|
function throttle(fn, delay) {
|
|
@@ -476,7 +340,7 @@
|
|
|
};
|
|
|
}
|
|
|
var intervaler;
|
|
|
- function doConnectBusiness() {
|
|
|
+ function doConnect() {
|
|
|
ws = new WebSocket(socketURL);
|
|
|
ws.binaryType = 'arraybuffer';
|
|
|
intervaler = setInterval(() => {
|
|
@@ -499,7 +363,7 @@
|
|
|
ws.addEventListener('error', function (event) {
|
|
|
ws.close();
|
|
|
clearInterval(intervaler);
|
|
|
- throttle(doConnectBusiness, 100);
|
|
|
+ throttle(doConnect, 100);
|
|
|
if (errorTime > 1000) {
|
|
|
$.toast('画面异常,请重新进入', 'text');
|
|
|
wsss.close();
|
|
@@ -683,7 +547,11 @@
|
|
|
var checkBuffer = GetScreenState();
|
|
|
ws.send(checkBuffer);
|
|
|
} else {
|
|
|
- connect('update');
|
|
|
+ $.toast('画面异常,请重新进入', 'text');
|
|
|
+ clearInterval(intervaler);
|
|
|
+ quit();
|
|
|
+ ws.close();
|
|
|
+ wsss.close();
|
|
|
}
|
|
|
}
|
|
|
if (input[23] == 0x05) {
|
|
@@ -733,6 +601,9 @@
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ var form = {};
|
|
|
+ form.token = parameters['token'];
|
|
|
+ form.userCardId = parameters['userCardId'];
|
|
|
function array_unique(arr) {
|
|
|
return arr.filter(function (e, i) {
|
|
|
return arr.indexOf(e) === i;
|
|
@@ -750,7 +621,7 @@
|
|
|
$.ajax({
|
|
|
url: baseUrl + '/api/public/v5/shear/content',
|
|
|
headers: {
|
|
|
- Authorization: token,
|
|
|
+ Authorization: form.token,
|
|
|
},
|
|
|
type: 'get',
|
|
|
dataType: 'json',
|
|
@@ -813,7 +684,7 @@
|
|
|
$.ajax({
|
|
|
url: baseUrl + '/api/public/v5/shear/content?' + ids,
|
|
|
headers: {
|
|
|
- Authorization: token,
|
|
|
+ Authorization: form.token,
|
|
|
},
|
|
|
type: 'DELETE',
|
|
|
dataType: 'json',
|
|
@@ -841,7 +712,7 @@
|
|
|
$.ajax({
|
|
|
url: baseUrl + '/api/public/v5/shear/content?ids=' + id,
|
|
|
headers: {
|
|
|
- Authorization: token,
|
|
|
+ Authorization: form.token,
|
|
|
},
|
|
|
type: 'DELETE',
|
|
|
dataType: 'json',
|
|
@@ -1112,15 +983,16 @@
|
|
|
$.ajax({
|
|
|
url: baseUrl + '/api/pay/v5/trialCodeConfig/getConfigByPhoneType',
|
|
|
headers: {
|
|
|
- Authorization: token,
|
|
|
+ Authorization: form.token,
|
|
|
},
|
|
|
data: {
|
|
|
- userCardId: userCardId,
|
|
|
- phoneType: mealType,
|
|
|
+ userCardId: form.userCardId,
|
|
|
+ phoneType: form.mealType,
|
|
|
},
|
|
|
type: 'get',
|
|
|
dataType: 'json',
|
|
|
success: function (res) {
|
|
|
+ console.log(res);
|
|
|
let obj = res.data;
|
|
|
if (res.status === 0) {
|
|
|
resolve(obj);
|
|
@@ -1137,7 +1009,7 @@
|
|
|
$.ajax({
|
|
|
url: baseUrl + '/api/resources/v4/freetrial/setmeal/list',
|
|
|
headers: {
|
|
|
- Authorization: token,
|
|
|
+ Authorization: form.token,
|
|
|
},
|
|
|
type: 'get',
|
|
|
dataType: 'json',
|
|
@@ -1171,7 +1043,7 @@
|
|
|
return $.ajax({
|
|
|
url: baseUrl + '/api/public/v5/advertising/getAdInfoByAdPlace',
|
|
|
headers: {
|
|
|
- Authorization: token,
|
|
|
+ Authorization: form.token,
|
|
|
},
|
|
|
data: JSON.stringify({
|
|
|
adPlace: adType,
|
|
@@ -1382,10 +1254,10 @@
|
|
|
$.ajax({
|
|
|
url: baseUrl + '/api/resources/v1/trial/report',
|
|
|
headers: {
|
|
|
- Authorization: token,
|
|
|
+ Authorization: form.token,
|
|
|
},
|
|
|
data: JSON.stringify({
|
|
|
- userCardId: userCardId,
|
|
|
+ userCardId: form.userCardId,
|
|
|
reportType: type,
|
|
|
}),
|
|
|
type: 'POST',
|
|
@@ -1396,6 +1268,9 @@
|
|
|
}
|
|
|
//关闭广告
|
|
|
$('.time-close-wrap')[0].addEventListener('click', () => {
|
|
|
+ if(videoTime == 0) {
|
|
|
+ reportFrequency()
|
|
|
+ }
|
|
|
$('.buy-phone-wrap').eq(0).show();
|
|
|
});
|
|
|
// 点击取消
|
|
@@ -1448,12 +1323,7 @@
|
|
|
} else {
|
|
|
// 过期续费按钮进入
|
|
|
wx.miniProgram.navigateTo({
|
|
|
- url:
|
|
|
- `/packageA/order/renew/index?buyType=${
|
|
|
- sourceType == 1
|
|
|
- ? '试用弹窗购买按钮进入-普通试用'
|
|
|
- : '试用弹窗购买按钮进入-激活码试用'
|
|
|
- }&record=` + userCardId,
|
|
|
+ url: `/packageA/order/renew/index?buyType=${sourceType == 1 ? '试用弹窗购买按钮进入-普通试用' : '试用弹窗购买按钮进入-激活码试用'}&record=` + form.userCardId,
|
|
|
});
|
|
|
}
|
|
|
});
|
|
@@ -1480,7 +1350,7 @@
|
|
|
$.ajax({
|
|
|
url: baseUrl + '/api/public/v1/systemBuriedPoint/stat',
|
|
|
headers: {
|
|
|
- Authorization: token,
|
|
|
+ Authorization: form.token,
|
|
|
},
|
|
|
type: 'post',
|
|
|
data: JSON.stringify({
|
|
@@ -1491,6 +1361,19 @@
|
|
|
success: function (res) {},
|
|
|
});
|
|
|
}
|
|
|
+ // 观看广告次数上报
|
|
|
+ function reportFrequency() {
|
|
|
+ $.ajax({
|
|
|
+ url: baseUrl + '/api/resoures/v1/trial/reportFrequency/' + form.userCardId,
|
|
|
+ headers: {
|
|
|
+ Authorization: form.token
|
|
|
+ },
|
|
|
+ type: 'post',
|
|
|
+ contentType: 'application/json',
|
|
|
+ dataType: 'json',
|
|
|
+ success: function (res) {},
|
|
|
+ });
|
|
|
+ }
|
|
|
function quit() {
|
|
|
if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
|
|
|
tt.miniProgram.switchTab({
|
|
@@ -1511,7 +1394,6 @@
|
|
|
wsss.close();
|
|
|
};
|
|
|
</script>
|
|
|
- <script type="text/javascript" src="WXdraw.js"></script>
|
|
|
<script type="text/javascript" src="aac.js"></script>
|
|
|
</body>
|
|
|
</html>
|