
const fetch = require('node-fetch'); // Node.js 18以下版本需要安装 node-fetch
const config  = require('../../../etc/config.json');
const redis_help = require('../../use_redis');
const helper = require('../../helper');
const CMD = {}
//24 = 短篇小说分销
//29 = 抖音小说分销
CMD.get_yw_account_list = async function(coopid=24) {
    // let res =  await require('./yw_login').yw_login()
    // console.log("res:",res.headers)
    await require('./switchApp').switchApp(0,coopid)
    await new Promise(resolve => setTimeout(resolve,1000));
    let OPENSESSID = await redis_help.getKeyValue("OPENSESSID")
    let timestamp = helper.getCurrentUnixTimestamp()
    console.log("OPENSESSID:",OPENSESSID)
    let response =  await fetch(`https://open.yuewen.com/api/product/getCoopAppList?coopid=${coopid}&page=1&status=0`, {
        "headers": {
            "accept": "application/json, text/plain, */*",
            "cookie": `Hm_lvt_990f9ab9737a266517417cc2949bb3f4=${timestamp}; csrfToken=NkSA9rxV9WELfeTlA6-LhiYv; OPENSESSID=${OPENSESSID}; yw_open_token=681a43e8b15bc; is_read_notice=681a43e8b15bc; sidebarStatus=0`,
        },
        "body": null,
        "method": "GET"
      });
      return await response.json()
}

module.exports = CMD;