Commit 22d1556d authored by 刘燕芳's avatar 刘燕芳

save

parent 5919c7e2
...@@ -16,12 +16,12 @@ let taIssueId:any = null ...@@ -16,12 +16,12 @@ let taIssueId:any = null
chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) { chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
// console.log('message1',message,sender); // console.log('message1',message,sender);
if (message.action === ACTION.task) { if (message.action === ACTION.task) {
if (JSON.stringify(tb_user) === "{}") { if (JSON.stringify(tb_user) === "{}") {
chrome.storage.sync.set({"info":'当前千牛登录账号信息获取失败'}) chrome.storage.sync.set({"info":'当前千牛登录账号信息获取失败'})
console.log(111); console.log(111);
sendResponse({status:-200,task_id:message.value.task_id,msg:"当前千牛登录账号信息获取失败,请登录千牛账号后重试!"}); sendResponse({status:-200,task_id:message.value.task_id,msg:"当前千牛登录账号信息获取失败,请登录千牛账号后重试!"});
return true return true
}else{ }else{
chrome.storage.sync.remove("info") chrome.storage.sync.remove("info")
if(message.value.seller.seller_name!==tb_user.userNick){ if(message.value.seller.seller_name!==tb_user.userNick){
chrome.storage.sync.set({"info":'当前登录的千牛账号与图动力授权的账号信息不一致,请统一登录后重试!'}) chrome.storage.sync.set({"info":'当前登录的千牛账号与图动力授权的账号信息不一致,请统一登录后重试!'})
...@@ -29,8 +29,8 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) { ...@@ -29,8 +29,8 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
sendResponse({status:-200,task_id:message.value.task_id,msg:"当前登录的千牛账号与图动力授权的账号信息不一致,请统一登录后重试!"}); sendResponse({status:-200,task_id:message.value.task_id,msg:"当前登录的千牛账号与图动力授权的账号信息不一致,请统一登录后重试!"});
return true return true
} }
} }
chrome.tabs.query({ chrome.tabs.query({
url:tbIssueUrls url:tbIssueUrls
},function (tabs) { },function (tabs) {
// 如果图动力登录的账号和千牛云登录的账号不一致,则popup页面爆红 // 如果图动力登录的账号和千牛云登录的账号不一致,则popup页面爆红
...@@ -51,7 +51,7 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) { ...@@ -51,7 +51,7 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
sendResponse({status:-200,task_id:message.value.task_id,msg:"请打开千牛商家工作台"}); sendResponse({status:-200,task_id:message.value.task_id,msg:"请打开千牛商家工作台"});
alert('请打开千牛商家工作台') alert('请打开千牛商家工作台')
} }
}) })
}else if(message.action==='getUserLoginData'){ }else if(message.action==='getUserLoginData'){
getUserLoginData() getUserLoginData()
let awaitResultFun = ()=>{ let awaitResultFun = ()=>{
...@@ -145,7 +145,6 @@ chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => { ...@@ -145,7 +145,6 @@ chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => {
chrome.tabs.remove(id); chrome.tabs.remove(id);
} }
} }
}) })
async function getUserLoginData(){ async function getUserLoginData(){
......
...@@ -24,14 +24,8 @@ async function booking(info: any) { ...@@ -24,14 +24,8 @@ async function booking(info: any) {
let default_info = JSON.parse(goods) let default_info = JSON.parse(goods)
tbIssueJsonDataV2 = default_info tbIssueJsonDataV2 = default_info
result = await tbDataJoinAndIssueV2(userDataJson, goodsData, goodsId); result = await tbDataJoinAndIssueV2(userDataJson, goodsData, goodsId);
// let {data:result} = await axios.post('https://item.upload.taobao.com/sell/v2/submit.htm', data, {
// headers: {
// 'Content-Type': 'application/x-www-form-urlencoded',
// 'Accept':'application/json',
// 'x-xsrf-token': userDataJson.token
// }
// })
let rJson = result let rJson = result
console.log('rJson',rJson);
try { try {
if (rJson.hasOwnProperty("ret")) { if (rJson.hasOwnProperty("ret")) {
if (JSON.stringify(rJson.ret).indexOf("被挤爆啦") != -1) { if (JSON.stringify(rJson.ret).indexOf("被挤爆啦") != -1) {
...@@ -45,8 +39,8 @@ async function booking(info: any) { ...@@ -45,8 +39,8 @@ async function booking(info: any) {
let rmg = rJson.models.globalMessage; let rmg = rJson.models.globalMessage;
let rSuccessUrl = rmg.successUrl; let rSuccessUrl = rmg.successUrl;
let rType = rmg.type; let rType = rmg.type;
reqMsg.status = rType == "status"?10:-200 reqMsg.status = rType == "success"?10:-200
if (rType != "status") { if (rType != "success") {
let msg = JSON.stringify(rJson.models); let msg = JSON.stringify(rJson.models);
reqMsg.msg = msg; reqMsg.msg = msg;
} }
...@@ -342,7 +336,7 @@ async function tbDataJoinAndIssueV2(userData:any, goodsData:any, goodsId:number) ...@@ -342,7 +336,7 @@ async function tbDataJoinAndIssueV2(userData:any, goodsData:any, goodsId:number)
console.log('tbDataJoinAndIssueV2',tbIssueJsonDataV2,goodsId); console.log('tbDataJoinAndIssueV2',tbIssueJsonDataV2,goodsId);
let data = { let data = {
jsonBody: JSON.stringify(tbIssueJsonDataV2), jsonBody: JSON.stringify(tbIssueJsonDataV2),
catId: 150704,//tbIssueJsonDataV2.catId, catId: tbIssueJsonDataV2.catId,
itemId: goodsId, itemId: goodsId,
copyItemMode: 0 copyItemMode: 0
} }
...@@ -382,10 +376,10 @@ async function tbGetIssueGoodsIdV2(userData:any, goodsData:any,data:any) { ...@@ -382,10 +376,10 @@ async function tbGetIssueGoodsIdV2(userData:any, goodsData:any,data:any) {
} }
}) })
let issueGoodsIdRd = result.data let issueGoodsIdRd = result.data
console.log('issueGoodsIdRd',issueGoodsIdRd); // console.log('issueGoodsIdRd',issueGoodsIdRd);
let link = "https:" + issueGoodsIdRd.link; let link = "https:" + issueGoodsIdRd.link;
let {data:goodsHtml}:any = await axios.get(link); let {data:goodsHtml}:any = await axios.get(link);
console.log("goodsHtml",goodsHtml); // console.log("goodsHtml",goodsHtml);
let index = goodsHtml.indexOf('data":{"itemId":'); let index = goodsHtml.indexOf('data":{"itemId":');
let startIndex = index + 16; let startIndex = index + 16;
let goodsId = goodsHtml.substring(startIndex, startIndex + 12); let goodsId = goodsHtml.substring(startIndex, startIndex + 12);
......
...@@ -89,9 +89,6 @@ const WayBillModel = function () { ...@@ -89,9 +89,6 @@ const WayBillModel = function () {
initTime++ initTime++
getLogin() getLogin()
chrome.runtime.sendMessage({ action: 'getUserLoginData' },async()=>{ chrome.runtime.sendMessage({ action: 'getUserLoginData' },async()=>{
console.log(111,new Date().getTime());
// await delayDate(1000)
// console.log(222,new Date().getTime());
let userData:any = await getStorageItem("tb_user") let userData:any = await getStorageItem("tb_user")
console.log('userData',userData,new Date().getMinutes(),new Date().getSeconds()); console.log('userData',userData,new Date().getMinutes(),new Date().getSeconds());
if (userData == null) { if (userData == null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment