|
@@ -2,26 +2,18 @@ const fetch = require('node-fetch'); // Node.js 18以下版本需要安装 node-
|
|
|
const helper = require('../src/helper');
|
|
|
const config = require('../etc/config.json');
|
|
|
const redis_help = require('../src/use_redis');
|
|
|
+const tools = require('../tools');
|
|
|
const CMD = {}
|
|
|
-CMD.get_promotion_id_by_name = async function(name,yw_id) {
|
|
|
+CMD.get_promotion_id_by_name = async function(name,yw_id,coopid) {
|
|
|
try {
|
|
|
let OPENSESSID = await redis_help.getKeyValue("OPENSESSID")
|
|
|
let timestamp = helper.getCurrentUnixTimestamp()
|
|
|
- await require('../src/api/yw/switchApp').switchApp(yw_id)
|
|
|
+ await require('../src/api/yw/switchApp').switchApp(yw_id,coopid)
|
|
|
const response = await fetch(`https://open.yuewen.com/api/miniappspread/getPromotionList?recycle=0&startdate=&enddate=&name=${name}&id=&content_type=0&page=1&channeltype=1&pagename=`, {
|
|
|
"headers": {
|
|
|
"accept": "application/json, text/plain, */*",
|
|
|
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
|
|
|
- "priority": "u=1, i",
|
|
|
- "sec-ch-ua": "\"Microsoft Edge\";v=\"131\", \"Chromium\";v=\"131\", \"Not_A Brand\";v=\"24\"",
|
|
|
- "sec-ch-ua-mobile": "?0",
|
|
|
- "sec-ch-ua-platform": "\"Windows\"",
|
|
|
- "sec-fetch-dest": "empty",
|
|
|
- "sec-fetch-mode": "cors",
|
|
|
- "sec-fetch-site": "same-origin",
|
|
|
"cookie": `Hm_lvt_990f9ab9737a266517417cc2949bb3f4=${timestamp}; csrfToken=vEQbWeNTNVpt2aruM6_NwIpT; OPENSESSID=${OPENSESSID}; yw_open_token=67dab7f35b593; is_read_notice=67dab7f35b593; sidebarStatus=1`,
|
|
|
- "Referer": "https://open.yuewen.com/new/library",
|
|
|
- "Referrer-Policy": "strict-origin-when-cross-origin"
|
|
|
},
|
|
|
"body": null,
|
|
|
"method": "GET"
|
|
@@ -122,9 +114,6 @@ CMD.test = async function() {
|
|
|
}
|
|
|
CMD.runTask = async function(t_data,main_info,PlatformInfo,call_back){
|
|
|
try{
|
|
|
- let chapter_info = await require('../src/api/yw/get_book_tg_chapter_id').get_book_tg_chapter_id(t_data.product_id)
|
|
|
- console.log("main_info.yw_id:",main_info.yw_id)
|
|
|
- console.log("chapter_info:",chapter_info)
|
|
|
let coopid = 24
|
|
|
if(main_info.pay_type==0){
|
|
|
coopid = 29
|
|
@@ -133,6 +122,10 @@ CMD.runTask = async function(t_data,main_info,PlatformInfo,call_back){
|
|
|
}
|
|
|
|
|
|
await require('../src/api/yw/switchApp').switchApp(main_info.yw_id,coopid)
|
|
|
+ let chapter_info = await require('../src/api/yw/get_book_tg_chapter_id').get_book_tg_chapter_id(t_data.product_id)
|
|
|
+ console.log("main_info.yw_id:",main_info.yw_id)
|
|
|
+ console.log("chapter_info:",chapter_info)
|
|
|
+
|
|
|
let timestamp = helper.getCurrentUnixTimestamp()
|
|
|
let tg_link_config = JSON.parse(main_info.tg_link_config)
|
|
|
let chongzhi_id = tg_link_config['chongzhi_id']
|
|
@@ -165,21 +158,6 @@ CMD.runTask = async function(t_data,main_info,PlatformInfo,call_back){
|
|
|
// }
|
|
|
let OPENSESSID = await redis_help.getKeyValue("OPENSESSID")
|
|
|
console.log("OPENSESSID:",OPENSESSID)
|
|
|
- const headers = {
|
|
|
- "accept": "application/json, text/plain, */*",
|
|
|
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
|
|
|
- "content-type": "application/json",
|
|
|
- "priority": "u=1, i",
|
|
|
- "sec-ch-ua": "\"Chromium\";v=\"134\", \"Not:A-Brand\";v=\"24\", \"Microsoft Edge\";v=\"134\"",
|
|
|
- "sec-ch-ua-mobile": "?0",
|
|
|
- "sec-ch-ua-platform": "\"Windows\"",
|
|
|
- "sec-fetch-dest": "empty",
|
|
|
- "sec-fetch-mode": "cors",
|
|
|
- "sec-fetch-site": "same-origin",
|
|
|
- "cookie": `Hm_lvt_990f9ab9737a266517417cc2949bb3f4=${timestamp}; csrfToken=ffZRRnqo6A4ngGbvAVP_zK5_; OPENSESSID=${OPENSESSID}; yw_open_token=67db7bcd069db; is_read_notice=67db7bcd069db; sidebarStatus=0`,
|
|
|
- "Referer": "https://open.yuewen.com/new/library",
|
|
|
- "Referrer-Policy": "strict-origin-when-cross-origin"
|
|
|
- };
|
|
|
let postData = {
|
|
|
"cost": 0,
|
|
|
"name": `${promotion_name}_${main_info.id}`,
|
|
@@ -207,7 +185,7 @@ CMD.runTask = async function(t_data,main_info,PlatformInfo,call_back){
|
|
|
"name": `${promotion_name}_${main_info.id}`,
|
|
|
"cbid": t_data.product_id,
|
|
|
"ccid": chapter_info.ccid,
|
|
|
- "page_name": `《${t_data.product_name}》第1章 01`,
|
|
|
+ "page_name": `《${t_data.product_name}》`,
|
|
|
"backup_book_status": 2,
|
|
|
"channel_type": 1,
|
|
|
"force_style": "1"
|
|
@@ -215,18 +193,23 @@ CMD.runTask = async function(t_data,main_info,PlatformInfo,call_back){
|
|
|
}
|
|
|
console.log("postData:",postData)
|
|
|
|
|
|
- let response = await fetch("https://open.yuewen.com/api/miniappspread/addH5Spread", {
|
|
|
- method: "POST",
|
|
|
- headers: headers,
|
|
|
- body: JSON.stringify(postData)
|
|
|
- });
|
|
|
|
|
|
- const data = await response.json();
|
|
|
|
|
|
- if(data.code!=0){
|
|
|
- throw data
|
|
|
+ const url = 'https://open.yuewen.com/api/miniappspread/addH5Spread';
|
|
|
+ const headers = {
|
|
|
+ 'accept': 'application/json, text/plain, */*',
|
|
|
+ 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
|
|
+ 'content-type': 'application/json',
|
|
|
+ 'cookie': `Hm_lvt_990f9ab9737a266517417cc2949bb3f4=${timestamp}; csrfToken=ffZRRnqo6A4ngGbvAVP_zK5_; OPENSESSID=${OPENSESSID}; yw_open_token=67db7bcd069db; is_read_notice=67db7bcd069db; sidebarStatus=0`,
|
|
|
+ };
|
|
|
+ let client = tools.getOneNewClinet(headers)
|
|
|
+ const response = await client.post(url, postData);
|
|
|
+
|
|
|
+
|
|
|
+ if(response.data.code!=0){
|
|
|
+ throw response.data
|
|
|
}
|
|
|
- let promotion_info = await CMD.get_promotion_id_by_name(promotion_name,main_info.yw_id)
|
|
|
+ let promotion_info = await CMD.get_promotion_id_by_name(promotion_name,main_info.yw_id,coopid)
|
|
|
let t_params = promotion_info.path.split('?')
|
|
|
let start_page = t_params[0]
|
|
|
let start_param = t_params[1]
|
|
@@ -234,7 +217,6 @@ CMD.runTask = async function(t_data,main_info,PlatformInfo,call_back){
|
|
|
t_data.start_page = start_page
|
|
|
t_data.start_param = start_param
|
|
|
console.log('CMD.runTask::响应状态:', response.status);
|
|
|
- console.log('CMD.runTask:响应数据:', data);
|
|
|
console.log('t_data:',t_data)
|
|
|
call_back(t_data,null)
|
|
|
}catch(error){
|