Last updated 2021-12-15 23:01:29

This commit is contained in:
blackmatrix7
2021-10-12 18:09:19 +00:00
parent 99b8eaa157
commit c0bfb34c43
3644 changed files with 2058868 additions and 440850 deletions

View File

@ -32,192 +32,173 @@ if (url.indexOf(path2) != -1) {
const floors = obj.floors;
const commodity_info = floors[floors.length - 1];
const shareUrl = commodity_info.data.property.shareUrl;
let msg = ""
let msg = "";
request_history_price(shareUrl)
.then(data => {
if (data.priceTrend.series.length == 0) throw new Error('Whoops!')
msg = priceSummary(data.priceTrend)
.then((data) => {
if (data.errno == -1) throw new Error("Whoops!");
msg = priceSummary(data.data);
})
.catch(error => msg = "暂无价格信息")
.catch((error) => (msg = "暂无价格信息"))
.finally(() => {
const lowerword = adword_obj()
lowerword.data.ad.textColor = "#fe0000"
let bestIndex = 0
const lowerword = adword_obj();
lowerword.data.ad.textColor = "#fe0000";
let bestIndex = 0;
for (let index = 0; index < floors.length; index++) {
const element = floors[index]
const element = floors[index];
if (element.mId == lowerword.mId) {
bestIndex = index + 1
break
bestIndex = index + 1;
break;
} else {
if (element.sortId > lowerword.sortId) {
bestIndex = index
break
bestIndex = index;
break;
}
}
}
lowerword.data.ad.adword = msg
floors.insert(bestIndex, lowerword)
$done({ body: JSON.stringify(obj) })
})
lowerword.data.ad.adword = msg;
floors.insert(bestIndex, lowerword);
$done({ body: JSON.stringify(obj) });
});
}
function priceSummary(data) {
data = data.series[0]
let summary = `🍵 当前: ${parseFloat(data.current / 100.0)}${getSpace(8)}最低: ${parseFloat(data.min / 100.0)}${getSpace(8)}最高: ${parseFloat(data.max / 100.0)}`;
const list = historySummary(data.data);
list.forEach((item, index) => {
summary += `\n${item.Name}${getSpace(8)}${item.Price}${getSpace(8)}${item.Date
}${getSpace(8)}${item.Difference}`;
});
return summary;
let summary = `🌨 当前: ${data.CurrentPrice}${getSpace(8)}最低: ${data.LowestPrice} (${data.LowestDate})`;
const list = historySummary(data.PricesHistory);
list.forEach((item, index) => {
summary += `\n${item.Name}${getSpace(8)}${item.Price}${getSpace(8)}${item.Date}${getSpace(8)}${item.Difference}`;
});
return summary;
}
function historySummary(list) {
let currentPrice, lowest30, lowest90, lowest180, lowest360, price11, price618;
list = list.reverse().slice(0, 360);
list.forEach((item, index) => {
const date = getExactTime(item.x);
let price = parseFloat(item.y / 100.0);
if (index == 0) {
currentPrice = price;
price618 = {
Name: "六一八价格",
Price: "-",
Date: "-",
Difference: "-",
price: "-",
};
price11 = {
Name: "双十一价格",
Price: "-",
Date: "-",
Difference: "-",
price: "-",
};
lowest30 = {
Name: "三十天最低",
Price: `¥${String(price)}`,
Date: date,
Difference: difference(currentPrice, price),
price,
};
lowest90 = {
Name: "九十天最低",
Price: `¥${String(price)}`,
Date: date,
Difference: difference(currentPrice, price),
price,
};
lowest180 = {
Name: "一百八最低",
Price: `¥${String(price)}`,
Date: date,
Difference: difference(currentPrice, price),
price,
};
lowest360 = {
Name: "三百六最低",
Price: `¥${String(price)}`,
Date: date,
Difference: difference(currentPrice, price),
price,
};
}
if (date.indexOf("06-18") != -1) {
price618.price = price;
price618.Price = `¥${String(price)}`;
price618.Date = date;
price618.Difference = difference(currentPrice, price);
}
if (date.indexOf("11-11") != -1) {
price11.price = price;
price11.Price = `¥${String(price)}`;
price11.Date = date;
price11.Difference = difference(currentPrice, price);
}
if (index < 30 && price < lowest30.price) {
lowest30.price = price;
lowest30.Price = `¥${String(price)}`;
lowest30.Date = date;
lowest30.Difference = difference(currentPrice, price);
}
if (index < 90 && price < lowest90.price) {
lowest90.price = price;
lowest90.Price = `¥${String(price)}`;
lowest90.Date = date;
lowest90.Difference = difference(currentPrice, price);
}
if (index < 180 && price < lowest180.price) {
lowest180.price = price;
lowest180.Price = `¥${String(price)}`;
lowest180.Date = date;
lowest180.Difference = difference(currentPrice, price);
}
if (index < 360 && price < lowest360.price) {
lowest360.price = price;
lowest360.Price = `¥${String(price)}`;
lowest360.Date = date;
lowest360.Difference = difference(currentPrice, price);
}
});
return [lowest30, lowest90, lowest180, lowest360, price618, price11];
let currentPrice, lowest30, lowest90, lowest180, lowest360, price11, price618;
list = list.reverse().slice(0, 360);
list.forEach((item, index) => {
const date = item.Date;
let price = item.Price;
if (index == 0) {
currentPrice = price;
price618 = {
Name: "六一八价格",
Price: "-",
Date: "-",
Difference: "-",
price: "-",
};
price11 = {
Name: "双十一价格",
Price: "-",
Date: "-",
Difference: "-",
price: "-",
};
lowest30 = {
Name: "三十天最低",
Price: `¥${String(price)}`,
Date: date,
Difference: difference(currentPrice, price),
price,
};
lowest90 = {
Name: "九十天最低",
Price: `¥${String(price)}`,
Date: date,
Difference: difference(currentPrice, price),
price,
};
lowest180 = {
Name: "一百八最低",
Price: `¥${String(price)}`,
Date: date,
Difference: difference(currentPrice, price),
price,
};
lowest360 = {
Name: "三百六最低",
Price: `¥${String(price)}`,
Date: date,
Difference: difference(currentPrice, price),
price,
};
}
if (date.indexOf("06-18") != -1) {
price618.price = price;
price618.Price = `¥${String(price)}`;
price618.Date = date;
price618.Difference = difference(currentPrice, price);
}
if (date.indexOf("11-11") != -1) {
price11.price = price;
price11.Price = `¥${String(price)}`;
price11.Date = date;
price11.Difference = difference(currentPrice, price);
}
if (index < 30 && price < lowest30.price) {
lowest30.price = price;
lowest30.Price = `¥${String(price)}`;
lowest30.Date = date;
lowest30.Difference = difference(currentPrice, price);
}
if (index < 90 && price < lowest90.price) {
lowest90.price = price;
lowest90.Price = `¥${String(price)}`;
lowest90.Date = date;
lowest90.Difference = difference(currentPrice, price);
}
if (index < 180 && price < lowest180.price) {
lowest180.price = price;
lowest180.Price = `¥${String(price)}`;
lowest180.Date = date;
lowest180.Difference = difference(currentPrice, price);
}
if (index < 360 && price < lowest360.price) {
lowest360.price = price;
lowest360.Price = `¥${String(price)}`;
lowest360.Date = date;
lowest360.Difference = difference(currentPrice, price);
}
});
return [lowest30, lowest90, lowest180, lowest360, price618, price11];
}
async function request_history_price(share_url) {
const options = {
headers: {
"User-Agent":
"bijiago/1.4.2 (com.bijiago.app; build:65; iOS 14.5.1) Alamofire/4.9.1",
"Content-Type": "application/x-www-form-urlencoded",
},
};
const options = {
headers: {
"Content-Type": "application/json; charset=utf-8",
},
};
const rid = new Promise(function (resolve, reject) {
options.url = "https://app.bijiago.com/service/product?app_platform=ios&app_version=65&device=750%2A1334&opt=product&posi=default&url=" + encodeURIComponent(share_url);
$tool.get(options, function (error, response, data) {
if (!error) {
resolve(JSON.parse(data))
} else {
reject(error)
}
})
})
const priceTrend = (rid, dq_id) => {
return new Promise(function (resolve, reject) {
options.url = "https://app.bijiago.com/service/product"
options.body = `app_platform=ios&app_version=10000&append_promo=1&dp_id=${dq_id}&from=url&opt=priceTrend&rid=${rid}`
$tool.post(options, function (error, response, data) {
if (!error) {
resolve(JSON.parse(data));
} else {
reject(error)
}
})
})
}
const ridData = await (rid)
const priceTrendData = await (priceTrend(ridData.rid, ridData.product.dp_id))
return priceTrendData
const priceTrend = new Promise(function (resolve, reject) {
options.url = "https://price.icharle.com/?product_id=" + share_url;
$tool.get(options, function (error, response, data) {
if (!error) {
resolve(JSON.parse(data));
} else {
reject(error);
}
});
});
const priceTrendData = await priceTrend;
return priceTrendData;
}
function getExactTime(time) {
var date = new Date(time * 1000);
var year = date.getFullYear() + "-";
var month =
(date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) + "-";
var dates = date.getDate();
return year + month + dates;
var date = new Date(time * 1000);
var year = date.getFullYear() + "-";
var month =
(date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) + "-";
var dates = date.getDate();
return year + month + dates;
}
function difference(currentPrice, price) {
let difference = sub(currentPrice, price)
let difference = sub(currentPrice, price);
if (difference == 0) {
return "-"
return "-";
} else {
return `${difference > 0 ? "↑" : "↓"}${String(Math.abs(difference))}`
return `${difference > 0 ? "↑" : "↓"}${String(Math.abs(difference))}`;
}
}
@ -226,13 +207,16 @@ function sub(arg1, arg2) {
}
function add(arg1, arg2) {
arg1 = arg1.toString(), arg2 = arg2.toString();
var arg1Arr = arg1.split("."), arg2Arr = arg2.split("."), d1 = arg1Arr.length == 2 ? arg1Arr[1] : "", d2 = arg2Arr.length == 2 ? arg2Arr[1] : "";
(arg1 = arg1.toString()), (arg2 = arg2.toString());
var arg1Arr = arg1.split("."),
arg2Arr = arg2.split("."),
d1 = arg1Arr.length == 2 ? arg1Arr[1] : "",
d2 = arg2Arr.length == 2 ? arg2Arr[1] : "";
var maxLen = Math.max(d1.length, d2.length);
var m = Math.pow(10, maxLen);
var result = Number(((arg1 * m + arg2 * m) / m).toFixed(maxLen));
var d = arguments[2];
return typeof d === "number" ? Number((result).toFixed(d)) : result;
return typeof d === "number" ? Number(result.toFixed(d)) : result;
}
function getSpace(length) {
@ -245,101 +229,108 @@ function getSpace(length) {
function adword_obj() {
return {
"bId": "eCustom_flo_199",
"cf": {
"bgc": "#ffffff",
"spl": "empty"
bId: "eCustom_flo_199",
cf: {
bgc: "#ffffff",
spl: "empty",
},
"data": {
"ad": {
"adword": "",
"textColor": "#8C8C8C",
"color": "#f23030",
"newALContent": true,
"hasFold": true,
"class": "com.jd.app.server.warecoresoa.domain.AdWordInfo.AdWordInfo",
"adLinkContent": "",
"adLink": ""
}
data: {
ad: {
adword: "",
textColor: "#8C8C8C",
color: "#f23030",
newALContent: true,
hasFold: true,
class: "com.jd.app.server.warecoresoa.domain.AdWordInfo.AdWordInfo",
adLinkContent: "",
adLink: "",
},
},
"mId": "bpAdword",
"refId": "eAdword_0000000028",
"sortId": 13
}
mId: "bpAdword",
refId: "eAdword_0000000028",
sortId: 13,
};
}
function tool() {
const isSurge = typeof $httpClient != "undefined"
const isQuanX = typeof $task != "undefined"
const isResponse = typeof $response != "undefined"
const isSurge = typeof $httpClient != "undefined";
const isQuanX = typeof $task != "undefined";
const isResponse = typeof $response != "undefined";
const node = (() => {
if (typeof require == "function") {
const request = require('request')
return ({ request })
const request = require("request");
return { request };
} else {
return (null)
return null;
}
})()
})();
const notify = (title, subtitle, message) => {
if (isQuanX) $notify(title, subtitle, message)
if (isSurge) $notification.post(title, subtitle, message)
if (isQuanX) $notify(title, subtitle, message);
if (isSurge) $notification.post(title, subtitle, message);
if (node) console.log(JSON.stringify({ title, subtitle, message }));
}
};
const write = (value, key) => {
if (isQuanX) return $prefs.setValueForKey(value, key)
if (isSurge) return $persistentStore.write(value, key)
}
if (isQuanX) return $prefs.setValueForKey(value, key);
if (isSurge) return $persistentStore.write(value, key);
};
const read = (key) => {
if (isQuanX) return $prefs.valueForKey(key)
if (isSurge) return $persistentStore.read(key)
}
if (isQuanX) return $prefs.valueForKey(key);
if (isSurge) return $persistentStore.read(key);
};
const adapterStatus = (response) => {
if (response) {
if (response.status) {
response["statusCode"] = response.status
response["statusCode"] = response.status;
} else if (response.statusCode) {
response["status"] = response.statusCode
response["status"] = response.statusCode;
}
}
return response
}
return response;
};
const get = (options, callback) => {
if (isQuanX) {
if (typeof options == "string") options = { url: options }
options["method"] = "GET"
$task.fetch(options).then(response => {
callback(null, adapterStatus(response), response.body)
}, reason => callback(reason.error, null, null))
if (typeof options == "string") options = { url: options };
options["method"] = "GET";
$task.fetch(options).then(
(response) => {
callback(null, adapterStatus(response), response.body);
},
(reason) => callback(reason.error, null, null)
);
}
if (isSurge) $httpClient.get(options, (error, response, body) => {
callback(error, adapterStatus(response), body)
})
if (isSurge)
$httpClient.get(options, (error, response, body) => {
callback(error, adapterStatus(response), body);
});
if (node) {
node.request(options, (error, response, body) => {
callback(error, adapterStatus(response), body)
})
callback(error, adapterStatus(response), body);
});
}
}
};
const post = (options, callback) => {
if (isQuanX) {
if (typeof options == "string") options = { url: options }
options["method"] = "POST"
$task.fetch(options).then(response => {
callback(null, adapterStatus(response), response.body)
}, reason => callback(reason.error, null, null))
if (typeof options == "string") options = { url: options };
options["method"] = "POST";
$task.fetch(options).then(
(response) => {
callback(null, adapterStatus(response), response.body);
},
(reason) => callback(reason.error, null, null)
);
}
if (isSurge) {
$httpClient.post(options, (error, response, body) => {
callback(error, adapterStatus(response), body)
})
callback(error, adapterStatus(response), body);
});
}
if (node) {
node.request.post(options, (error, response, body) => {
callback(error, adapterStatus(response), body)
})
callback(error, adapterStatus(response), body);
});
}
}
return { isQuanX, isSurge, isResponse, notify, write, read, get, post }
};
return { isQuanX, isSurge, isResponse, notify, write, read, get, post };
}
Array.prototype.insert = function (index, item) {
@ -355,22 +346,28 @@ Date.prototype.format = function (fmt) {
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3),
"S+": this.getMilliseconds()
"S+": this.getMilliseconds(),
};
for (var k in o) {
if (new RegExp("(" + k + ")").test(fmt)) {
if (k == "y+") {
fmt = fmt.replace(RegExp.$1, ("" + o[k]).substr(4 - RegExp.$1.length));
}
else if (k == "S+") {
} else if (k == "S+") {
var lens = RegExp.$1.length;
lens = lens == 1 ? 3 : lens;
fmt = fmt.replace(RegExp.$1, ("00" + o[k]).substr(("" + o[k]).length - 1, lens));
}
else {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
fmt = fmt.replace(
RegExp.$1,
("00" + o[k]).substr(("" + o[k]).length - 1, lens)
);
} else {
fmt = fmt.replace(
RegExp.$1,
RegExp.$1.length == 1
? o[k]
: ("00" + o[k]).substr(("" + o[k]).length)
);
}
}
}
return fmt;
}
};

View File

@ -56,8 +56,8 @@ if (url.indexOf(path2) != -1) {
let msg
request_history_price(shareUrl)
.then(data => {
if (data.errno == -1) throw new Error('Whoops!')
msg = data
if (msg.priceTrend.series.length == 0) throw new Error('Whoops!')
})
.catch(error => msg = "暂无价格信息")
.finally(() => {
@ -99,24 +99,24 @@ if (url.indexOf(path2) != -1) {
}
function sendNotify(data) {
if (typeof data == "string") {
$tool.notify("", "", `${data}`)
if (data.data.PricesHistory == null) {
$tool.notify("", "", `暂无历史价格`)
} else {
const detail = priceSummary(data)[1]
$tool.notify("", "", `🍵 ${detail}`)
const detail = priceSummary(data.data)
$tool.notify("", "", `${detail}`)
}
}
function setConsumerProtection(data, consumerProtection) {
let basicService = consumerProtection.serviceProtection.basicService
let items = consumerProtection.items
if (typeof data == "string") {
let item = customItem(data, [])
if (data.data.PricesHistory == null) {
let item = customItem("暂无历史价格", [])
basicService.services.unshift(item)
items.unshift(item)
} else {
const summary = priceSummary(data.priceTrend)[1]
const item = customItem("价格详情", [`${summary}`])
const summary = priceSummary(data.data)[1]
const item = customItem("🌨 历史价格详情", [`${summary}`])
basicService.services.unshift(item)
items.unshift(item)
}
@ -125,26 +125,25 @@ function setConsumerProtection(data, consumerProtection) {
function setTradeConsumerProtection(data, tradeConsumerProtection) {
let service = tradeConsumerProtection.tradeConsumerService.service
if (typeof data == "string") {
service.items.unshift(customItem(data, ""))
if (data.data.PricesHistory == null) {
service.items.unshift(customItem("暂无历史价格", ""))
} else {
const tbitems = priceSummary(data.priceTrend)[0]
const tbitems = priceSummary(data.data)[0]
let nonService = tradeConsumerProtection.tradeConsumerService.nonService
service.items = service.items.concat(nonService.items)
nonService.title = "价格详情"
nonService.title = "🌨 历史价格详情"
nonService.items = tbitems
}
return tradeConsumerProtection
}
function priceSummary(data) {
data = data.series[0]
let summary = `当前: ${parseFloat(data.current / 100.0)}${getSpace(4)}最低: ${parseFloat(data.min / 100.0)}${getSpace(4)}最高: ${parseFloat(data.max / 100.0)}`
let summary = `当前: ${data.CurrentPrice}${getSpace(8)}最低: ${data.LowestPrice} (${data.LowestDate})`
let tbitems = [customItem(summary)]
const list = historySummary(data.data)
const list = historySummary(data.PricesHistory)
list.forEach((item, index) => {
summary += `\n${item.Name}${getSpace(4)}${item.Price}${getSpace(4)}${item.Date}${getSpace(4)}${item.Difference}`
let summaryItem = `${item.Name}${getSpace(4)}${item.Price}${getSpace(4)}${item.Date}${getSpace(4)}${item.Difference}`
let summaryItem = `${item.Name}${getSpace(3)}${item.Price}${getSpace(3)}${item.Date}${getSpace(3)}${item.Difference}`
tbitems.push(customItem(summaryItem))
});
return [tbitems, summary]
@ -154,8 +153,8 @@ function historySummary(list) {
let currentPrice, lowest30, lowest90, lowest180, lowest360, price11, price618;
list = list.reverse().slice(0, 360);
list.forEach((item, index) => {
const date = getExactTime(item.x);
let price = parseFloat(item.y / 100.0);
const date = item.Date;
let price = item.Price;
if (index == 0) {
currentPrice = price;
price618 = {
@ -244,39 +243,22 @@ function historySummary(list) {
async function request_history_price(share_url) {
const options = {
headers: {
"User-Agent":
"bijiago/1.4.2 (com.bijiago.app; build:65; iOS 14.5.1) Alamofire/4.9.1",
"Content-Type": "application/x-www-form-urlencoded",
"Content-Type": "application/json; charset=utf-8",
},
};
const rid = new Promise(function (resolve, reject) {
options.url = "https://app.bijiago.com/service/product?app_platform=ios&app_version=65&device=750%2A1334&opt=product&posi=default&url=" + encodeURIComponent(share_url);
const priceTrend = new Promise(function (resolve, reject) {
options.url = "https://price.icharle.com/?product_id=" + share_url;
$tool.get(options, function (error, response, data) {
if (!error) {
resolve(JSON.parse(data))
resolve(JSON.parse(data));
} else {
reject(error)
reject(error);
}
})
})
const priceTrend = (rid, dq_id) => {
return new Promise(function (resolve, reject) {
options.url = "https://app.bijiago.com/service/product"
options.body = `app_platform=ios&app_version=10000&append_promo=1&dp_id=${dq_id}&from=url&opt=priceTrend&rid=${rid}`
$tool.post(options, function (error, response, data) {
if (!error) {
resolve(JSON.parse(data));
} else {
reject(error)
}
})
})
}
const ridData = await (rid)
const priceTrendData = await (priceTrend(ridData.rid, ridData.product.dp_id))
return priceTrendData
});
});
const priceTrendData = await priceTrend;
return priceTrendData;
}
function getExactTime(time) {