|
@@ -5,6 +5,8 @@ let get_hy_recharge_template = require('../src/api/hy/get_hy_recharge_template')
|
|
|
let get_hy_paid_point = require('../src/api/hy/get_hy_paid_point')
|
|
|
let get_hy_call_back_template = require('../src/api/hy/get_hy_call_back_template');
|
|
|
const tools = require('../tools');
|
|
|
+const HttpClient = require('../src/HttpClient');
|
|
|
+const helper = require('../src/helper');
|
|
|
//卡点
|
|
|
function get_paid_point(book_id,kadian_name,call_back){
|
|
|
let chapter_num = parseInt(kadian_name)
|
|
@@ -61,7 +63,7 @@ function get_recharge_template(book_id,chongzhi_name,call_back){
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-CMD. = function(data,main_info,PlatformInfo,call_back){
|
|
|
+CMD.runTask = function(data,main_info,PlatformInfo,call_back){
|
|
|
// console.log("data:",data)
|
|
|
// console.log("PlatformInfo:",PlatformInfo)
|
|
|
// console.log("main_info:",main_info.tg_link_config)
|
|
@@ -112,37 +114,58 @@ CMD. = function(data,main_info,PlatformInfo,call_back){
|
|
|
// start_page: 'pages/readPage/chapter',
|
|
|
// start_param: 'pid=1809545659599544322&bookId=1849369533770342401&linkId=1860983668277948418&channels=4&hyChannel=1'
|
|
|
let create_hy_link = async () =>{
|
|
|
- let topUpTemplateId = tg_config.chongzhi_key; //充值模板
|
|
|
- let passBackTemplateId = tg_config.huichuan_key; //回传模板
|
|
|
- let paidPoint = tg_config.kadian_key; //卡点
|
|
|
- console.log("tg_config:",tg_config)
|
|
|
- const postData = {
|
|
|
- cmd:"create_link",
|
|
|
- name:data.product_name,
|
|
|
- bookId:data.product_id,
|
|
|
- topUpTemplateId:topUpTemplateId,
|
|
|
- passBackTemplateId:passBackTemplateId,
|
|
|
- paidPoint:paidPoint,
|
|
|
- token:await tools.getHyToken()
|
|
|
- };
|
|
|
+ let topUpTemplateId = tg_config.chongzhi_key; //充值模板
|
|
|
+ let passBackTemplateId = tg_config.huichuan_key; //回传模板
|
|
|
+ let paidPoint = tg_config.kadian_key; //卡点
|
|
|
+ console.log("tg_config:",tg_config)
|
|
|
+ try{
|
|
|
+ let clinet = new HttpClient()
|
|
|
+ const postData = {
|
|
|
+ cmd:"create_link",
|
|
|
+ name:data.product_name,
|
|
|
+ bookId:data.product_id,
|
|
|
+ topUpTemplateId:topUpTemplateId,
|
|
|
+ passBackTemplateId:passBackTemplateId,
|
|
|
+ paidPoint:paidPoint,
|
|
|
+ token:await tools.getHyToken()
|
|
|
+ };
|
|
|
+ let data = {
|
|
|
+ "name": postData.name,
|
|
|
+ "bookId": postData.bookId,
|
|
|
+ "passBackTemplateId": postData.passBackTemplateId,
|
|
|
+ "adPassbackTemplateId": "",
|
|
|
+ "topUpTemplateId": postData.topUpTemplateId,
|
|
|
+ "mediaChannel": "1",
|
|
|
+ "group": "35",
|
|
|
+ "paidPoint": postData.paidPoint,
|
|
|
+ "site": "5"
|
|
|
+ }
|
|
|
+ let res = await clinet.otherPost( helper.getHyCreateLinkOpt(postData.token) ,data)
|
|
|
+ console.log("res:",res)
|
|
|
+
|
|
|
+ let response = {
|
|
|
+ "message": "create_link successfully",
|
|
|
+ "received_data":{"originalId":res["data"]["originalId"],
|
|
|
+ "appId":res["data"]["appId"],
|
|
|
+ "launchPath":res["data"]["launchPath"],
|
|
|
+ "fullPath":res["data"]["fullPath"],
|
|
|
+ "wxMountLink":res["data"]["wxMountLink"]}
|
|
|
+ }
|
|
|
|
|
|
- axios.post('http://127.0.0.1:8080', postData)
|
|
|
- .then(response => {
|
|
|
- let params = response.data.received_data.fullPath.split('?')
|
|
|
- // let appId = response.data.data.appId
|
|
|
- let start_page = params[0]
|
|
|
- let start_param = params[1]
|
|
|
- const linkId = start_param.match(/linkId=([^&]*)/)[1];
|
|
|
- data.promotion_id = linkId
|
|
|
- data.start_page = start_page
|
|
|
- data.start_param = start_param
|
|
|
- // console.log("response.data.received_data:",response.data.received_data)
|
|
|
- call_back(data)
|
|
|
- })
|
|
|
- .catch(error => {
|
|
|
+ let params = response.data.received_data.fullPath.split('?')
|
|
|
+ // let appId = response.data.data.appId
|
|
|
+ let start_page = params[0]
|
|
|
+ let start_param = params[1]
|
|
|
+ const linkId = start_param.match(/linkId=([^&]*)/)[1];
|
|
|
+ data.promotion_id = linkId
|
|
|
+ data.start_page = start_page
|
|
|
+ data.start_param = start_param
|
|
|
+ // console.log("response.data.received_data:",response.data.received_data)
|
|
|
+ call_back(data)
|
|
|
+ }catch(e){
|
|
|
call_back(null)
|
|
|
console.error('There was an error!', error);
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
let count_num = ()=>{
|
|
|
num++;
|