Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
ruitu-fahuoyi-exension
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
廖健文
ruitu-fahuoyi-exension
Commits
ec413ab4
Commit
ec413ab4
authored
Mar 20, 2024
by
刘燕芳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sasve
parent
b83f92d1
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
304 additions
and
256 deletions
+304
-256
icon.png
assets/icon.png
+0
-0
dist.crx
dist.crx
+0
-0
dist.zip
dist.zip
+0
-0
manifest.json
manifest.json
+3
-2
index.ts
src/background/index.ts
+242
-209
bookingV2.ts
src/content/bookingV2.ts
+55
-42
index.ts
src/content/index.ts
+3
-2
index.tsx
src/popup/components/WayBillModel/index.tsx
+1
-1
No files found.
assets/icon.png
View replaced file @
b83f92d1
View file @
ec413ab4
27.3 KB
|
W:
|
H:
32.2 KB
|
W:
|
H:
2-up
Swipe
Onion skin
dist.crx
View file @
ec413ab4
No preview for this file type
dist.zip
0 → 100644
View file @
ec413ab4
File added
manifest.json
View file @
ec413ab4
{
"name"
:
"图动力"
,
"version"
:
"1.0.0"
,
"description"
:
"辅助
手机壳厂家打印发货易的快递单
"
,
"description"
:
"辅助
上架
"
,
"manifest_version"
:
2
,
"background"
:
{
...
...
@@ -14,7 +14,7 @@
"browser_action"
:
{
"default_popup"
:
"popup.html"
,
"default_icon"
:
"icon.png"
,
"default_title"
:
"辅助
发货易打单
"
"default_title"
:
"辅助
上架
"
},
"icons"
:
{
"128"
:
"icon.png"
...
...
@@ -28,6 +28,7 @@
"*://myseller.taobao.com/*"
,
"*://admin.rtxmdz.com/*"
,
"http://localhost:10823/*"
,
"http://localhost:64032/*"
,
"*://*.rtxmdz.com/*"
,
"https://item.upload.taobao.com/*"
,
"https://sell.publish.tmall.com/*"
...
...
src/background/index.ts
View file @
ec413ab4
import
{
Tabs
}
from
"antd"
;
import
{
factoryContentUrls
,
bookingV2Urls
,
homeUrl
,
tmIssueUrl
,
tbIssueUrl
,
tbIssueUrls
}
from
"../config"
;
import
{
ACTION
}
from
"../types"
;
import
{
Tabs
}
from
'antd'
import
{
factoryContentUrls
,
bookingV2Urls
,
homeUrl
,
tmIssueUrl
,
tbIssueUrl
,
tbIssueUrls
,
}
from
'../config'
import
{
ACTION
}
from
'../types'
const
tmNameSiffix
=
[
'旗舰店'
,
'专卖店'
,
'专营店'
]
// platform: PlatformCode,// 平台编码,淘系及其他平台订单模板的为0,拼多多订单的为1,京东订单的为2
const
PlatfromsMap
=
new
Map
([
[
0
,
/.+:
\/\/
a.*
\.
fahuoyi.com
\/
scanPrinting
\/
index/
],
[
1
,
/.+:
\/\/
pdd.*
\.
fahuoyi.com
\/
scanPrinting
\/
index/
],
[
2
,
/.+:
\/\/
jd.*
\.
fahuoyi.com
\/
scanPrinting
\/
index/
]
])
let
monitoringRemoveTabId
=
new
Map
();
let
result_sendResponse
:
boolean
=
false
let
tb_user
:
any
=
{}
let
taIssueId
:
any
=
null
let
userId
:
any
=
null
let
monitoringRemoveTabId
=
new
Map
()
let
result_sendResponse
:
boolean
=
false
let
tb_user
:
any
=
{}
let
taIssueId
:
any
=
null
chrome
.
runtime
.
onMessage
.
addListener
(
function
(
message
,
sender
,
sendResponse
)
{
// console.log('message1',message,sender);
if
(
message
.
action
===
ACTION
.
task
)
{
if
(
JSON
.
stringify
(
tb_user
)
===
"{}"
)
{
chrome
.
storage
.
sync
.
set
({
"info"
:
'当前千牛登录账号信息获取失败'
})
console
.
log
(
111
);
sendResponse
({
status
:
-
200
,
task_id
:
message
.
value
.
task_id
,
msg
:
"当前千牛登录账号信息获取失败,请登录千牛账号后重试!"
});
return
true
}
else
{
chrome
.
storage
.
sync
.
remove
(
"info"
)
if
(
message
.
value
.
seller
.
seller_name
!==
tb_user
.
userNick
){
chrome
.
storage
.
sync
.
set
({
"info"
:
'当前登录的千牛账号与图动力授权的账号信息不一致,请统一登录后重试!'
})
sendResponse
({
status
:
-
200
,
task_id
:
message
.
value
.
task_id
,
msg
:
"当前登录的千牛账号与图动力授权的账号信息不一致,请统一登录后重试!"
});
return
true
}
// console.log('message1',message,sender);
if
(
message
.
action
===
ACTION
.
task
)
{
getUserLoginData
()
let
awaitResultFun
=
()
=>
{
console
.
log
(
'awaitResultFun'
,
result_sendResponse
);
if
(
result_sendResponse
)
{
if
(
JSON
.
stringify
(
tb_user
)
===
'{}'
)
{
chrome
.
storage
.
sync
.
set
({
info
:
'当前千牛登录账号信息获取失败'
})
sendResponse
({
status
:
-
200
,
task_id
:
message
.
value
.
task_id
,
msg
:
'当前千牛登录账号信息获取失败,请登录千牛账号后重试!'
,
})
return
true
}
else
{
chrome
.
storage
.
sync
.
remove
(
'info'
)
if
(
message
.
value
.
seller
.
nick
!==
tb_user
.
userNick
)
{
chrome
.
storage
.
sync
.
set
({
info
:
'当前登录的千牛账号与图动力授权的账号信息不一致,请统一登录后重试!'
,})
sendResponse
({
status
:
-
200
,
task_id
:
message
.
value
.
task_id
,
msg
:
'当前登录的千牛账号与图动力授权的账号信息不一致,请统一登录后重试!'
,
})
return
true
}
}
chrome
.
tabs
.
query
({
url
:
tbIssueUrls
},
function
(
tabs
)
{
// 如果图动力登录的账号和千牛云登录的账号不一致,则popup页面爆红
console
.
log
(
'tabs'
,
tabs
);
tabs
&&
tabs
.
forEach
(
tab
=>
{
chrome
.
tabs
.
update
(
tab
.
id
!
,
{
active
:
true
},
function
(
tab1
)
{});
chrome
.
tabs
.
sendMessage
(
tab
.
id
!
,
{
action
:
ACTION
.
task
,
value
:
message
.
value
},
res
=>
{
console
.
log
(
'res'
,
res
,
new
Date
().
getTime
());
if
(
res
){
console
.
log
(
3333
);
sendResponse
(
res
);
chrome
.
tabs
.
update
(
sender
.
tab
!
.
id
!
,
{
active
:
true
},
function
(
tab1
)
{});
}
})
})
if
(
tabs
.
length
==
0
){
console
.
log
(
444
);
sendResponse
({
status
:
-
200
,
task_id
:
message
.
value
.
task_id
,
msg
:
"请打开千牛商家工作台"
});
alert
(
'请打开千牛商家工作台'
)
}
})
}
else
if
(
message
.
action
===
'getUserLoginData'
){
getUserLoginData
()
let
awaitResultFun
=
()
=>
{
if
(
result_sendResponse
){
sendResponse
()
}
else
{
setTimeout
(()
=>
{
awaitResultFun
()
},
500
);
chrome
.
tabs
.
query
(
{
url
:
tbIssueUrls
,
},
function
(
tabs
)
{
// 如果图动力登录的账号和千牛云登录的账号不一致,则popup页面爆红
tabs
&&
tabs
.
forEach
((
tab
)
=>
{
// chrome.tabs.update(tab.id!,{ active: true },function (tab1) {})
chrome
.
tabs
.
sendMessage
(
tab
.
id
!
,{
action
:
ACTION
.
task
,
value
:
message
.
value
},(
res
)
=>
{
console
.
log
(
'res'
,
res
,
new
Date
().
getTime
())
if
(
res
)
{
sendResponse
(
res
)
// chrome.tabs.update(sender.tab!.id!,{ active: true },function (tab1) {})
}
}
)
})
if
(
tabs
.
length
==
0
)
{
sendResponse
({
status
:
-
200
,
task_id
:
message
.
value
.
task_id
,
msg
:
'请打开千牛商家工作台'
,
})
alert
(
'请打开千牛商家工作台'
)
}
}
awaitResultFun
()
}
)
}
else
{
setTimeout
(()
=>
{
awaitResultFun
()
},
500
)
}
}
return
true
;
awaitResultFun
()
}
else
if
(
message
.
action
===
'getUserLoginData'
)
{
getUserLoginData
()
let
awaitResultFun
=
()
=>
{
if
(
result_sendResponse
)
{
sendResponse
()
}
else
{
setTimeout
(()
=>
{
awaitResultFun
()
},
500
)
}
}
awaitResultFun
()
}
return
true
})
chrome
.
tabs
.
onUpdated
.
addListener
(
async
(
tabId
,
changeInfo
,
tab
)
=>
{
//加载完毕后在执行一些动作
if
(
tab
.
status
==
"complete"
)
{
//如果进入了千牛首页 则开始获取对应的数据信息
if
(
tab
.
url
&&
tab
.
url
.
indexOf
(
"loginmyseller.taobao.com"
)
!=
-
1
){
if
(
monitoringRemoveTabId
.
has
(
tab
.
id
)){
let
id
:
any
=
tab
.
id
chrome
.
tabs
.
remove
(
id
);
}
chrome
.
storage
.
sync
.
remove
(
"tb_user"
)
result_sendResponse
=
true
;
return
//加载完毕后在执行一些动作
if
(
tab
.
status
==
'complete'
)
{
//如果进入了千牛首页 则开始获取对应的数据信息
if
(
tab
.
url
&&
tab
.
url
.
indexOf
(
'loginmyseller.taobao.com'
)
!=
-
1
)
{
if
(
monitoringRemoveTabId
.
has
(
tab
.
id
))
{
let
id
:
any
=
tab
.
id
chrome
.
tabs
.
remove
(
id
)
}
chrome
.
storage
.
sync
.
remove
(
'tb_user'
)
result_sendResponse
=
true
return
}
if
(
tab
.
url
&&
tab
.
url
.
indexOf
(
'myseller.taobao.com/home.htm/QnworkbenchHome'
)
!=
-
1
)
{
let
userNickCookie
:
any
=
await
getCookies
(
tab
.
url
,
'sn'
)
if
(
userNickCookie
===
null
||
userNickCookie
===
undefined
||
userNickCookie
===
''
)
userNickCookie
=
await
getCookies
(
tab
.
url
,
'_nk_'
)
console
.
log
(
'userNickCookie'
,
userNickCookie
)
if
(
userNickCookie
===
null
||
userNickCookie
===
undefined
)
{
chrome
.
storage
.
sync
.
remove
(
'tb_user'
)
result_sendResponse
=
true
return
}
// let cnaui: any = await getCookies('https://*.mmstat.com', 'cnaui')
// console.log('cookie', 'https://.mmstat.com', cnaui.value)
// userId = cnaui.value
// taIssueId&&chrome.tabs.remove(taIssueId)
chrome
.
tabs
.
query
(
{
url
:
[
tbIssueUrl
],
},
async
function
(
tabs
)
{
console
.
log
(
'tabs'
,
tabs
)
let
complete_tabs
:
any
=
[]
if
(
tabs
.
length
)
{
complete_tabs
=
tabs
.
filter
((
item
)
=>
item
.
status
===
'complete'
)
}
console
.
log
(
'complete_tabs'
,
complete_tabs
)
if
(
!
complete_tabs
.
length
)
{
taIssueId
=
await
createTab
(
tbIssueUrl
)
}
}
if
(
tab
.
url
&&
tab
.
url
.
indexOf
(
"myseller.taobao.com/home.htm/QnworkbenchHome"
)
!=
-
1
)
{
let
userNickCookie
:
any
=
await
getCookies
(
tab
.
url
,
"sn"
);
if
(
userNickCookie
===
null
||
userNickCookie
===
undefined
||
userNickCookie
===
""
)
userNickCookie
=
await
getCookies
(
tab
.
url
,
"_nk_"
);
console
.
log
(
'userNickCookie'
,
userNickCookie
);
if
(
userNickCookie
===
null
||
userNickCookie
===
undefined
)
{
chrome
.
storage
.
sync
.
remove
(
"tb_user"
)
result_sendResponse
=
true
;
return
};
let
cnaui
:
any
=
await
getCookies
(
'https://*.mmstat.com'
,
'cnaui'
);
// let aui:any = await getCookies(tab.url, "cnaui");
console
.
log
(
'cookie'
,
'https://.mmstat.com'
,
cnaui
.
value
);
userId
=
cnaui
.
value
// taIssueId&&chrome.tabs.remove(taIssueId)
chrome
.
tabs
.
query
({
url
:[
tbIssueUrl
]
},
async
function
(
tabs
)
{
console
.
log
(
'tabs'
,
tabs
);
let
complete_tabs
:
any
=
[]
if
(
tabs
.
length
){
complete_tabs
=
tabs
.
filter
(
item
=>
item
.
status
===
'complete'
)
}
console
.
log
(
'complete_tabs'
,
complete_tabs
);
if
(
!
complete_tabs
.
length
){
taIssueId
=
await
createTab
(
tbIssueUrl
);
}
})
)
let
tuDe1
=
decodeURI
(
userNickCookie
.
value
);
let
tuDe2
=
unescape
(
tuDe1
.
replace
(
/
\\(
u
[
0-9a-fA-F
]{4})
/gm
,
'%$1'
));
if
(
tuDe2
.
indexOf
(
":"
)
!=
-
1
)
tuDe2
=
tuDe2
.
split
(
":"
)[
0
];
let
createUrl
=
isTm
(
tuDe2
)
?
tmIssueUrl
:
tbIssueUrl
;
let
tabId
=
await
createTab
(
createUrl
);
monitoringRemoveTabId
.
set
(
tabId
,
tuDe2
);
}
let
tuDe1
=
decodeURI
(
userNickCookie
.
value
)
let
tuDe2
=
unescape
(
tuDe1
.
replace
(
/
\\(
u
[
0-9a-fA-F
]{4})
/gm
,
'%$1'
))
if
(
tuDe2
.
indexOf
(
':'
)
!=
-
1
)
tuDe2
=
tuDe2
.
split
(
':'
)[
0
]
let
createUrl
=
isTm
(
tuDe2
)
?
tmIssueUrl
:
tbIssueUrl
let
tabId
=
await
createTab
(
createUrl
)
monitoringRemoveTabId
.
set
(
tabId
,
tuDe2
)
}
if
(
tab
.
url
&&
(
tab
.
url
.
indexOf
(
"item.upload.taobao.com/sell/merge"
)
!=
-
1
||
tab
.
url
.
indexOf
(
"sell.publish.tmall.com/tmall/smart"
)
!=
-
1
))
{
if
(
monitoringRemoveTabId
.
has
(
tab
.
id
))
{
let
userNick
:
string
=
monitoringRemoveTabId
.
get
(
tab
.
id
);
console
.
log
(
'monitoringRemoveTabId'
,
monitoringRemoveTabId
);
let
cookie
=
await
getCookieAll
(
tab
.
url
);
// console.log('cookie22',tab.url,cookie);
let
token
:
any
=
await
getCookies
(
tab
.
url
,
"XSRF-TOKEN"
);
let
userData
:
object
=
{
cookie
:
cookie
,
token
:
token
.
value
,
userId
:
userId
,
userNick
:
userNick
,
}
tb_user
=
userData
chrome
.
storage
.
sync
.
set
({
"tb_user"
:
JSON
.
stringify
(
userData
)})
console
.
log
(
"user data :"
,
userData
,
new
Date
().
getMinutes
(),
new
Date
().
getSeconds
());
// let serverNum = SoketDispatchManage.hosts[config.evn].length;
// if (SoketDispatchManage.userNick == null || SoketDispatchManage.userNick != userData.userNick || SoketDispatchManage.getActiveConnectNum() != serverNum) {
// //与服务器建立webSocket连接 后续与服务器通信将依赖此链接
// SoketDispatchManage.connection(userData.userNick);
// if (SoketDispatchManage.getActiveConnectNum() <= 0) {
// console.log("socket未连接至任何服务器!")
// }
// }
let
id
:
any
=
tab
.
id
result_sendResponse
=
true
;
}
else
{
console
.
log
(
5555
);
}
}
if
(
monitoringRemoveTabId
.
has
(
tab
.
id
)){
let
id
:
any
=
tab
.
id
chrome
.
tabs
.
remove
(
id
);
if
(
tab
.
url
&&
(
tab
.
url
.
indexOf
(
'item.upload.taobao.com/sell/merge'
)
!=
-
1
||
tab
.
url
.
indexOf
(
'sell.publish.tmall.com/tmall/smart'
)
!=
-
1
)
)
{
if
(
monitoringRemoveTabId
.
has
(
tab
.
id
))
{
let
userNick
:
string
=
monitoringRemoveTabId
.
get
(
tab
.
id
)
console
.
log
(
'monitoringRemoveTabId'
,
monitoringRemoveTabId
)
let
cookie
=
await
getCookieAll
(
tab
.
url
)
// console.log('cookie22',tab.url,cookie);
let
token
:
any
=
await
getCookies
(
tab
.
url
,
'XSRF-TOKEN'
)
let
userData
:
object
=
{
cookie
:
cookie
,
token
:
token
.
value
,
userNick
:
userNick
,
}
tb_user
=
userData
chrome
.
storage
.
sync
.
set
({
tb_user
:
JSON
.
stringify
(
userData
)
})
console
.
log
(
'user data :'
,
userData
,
new
Date
().
getMinutes
(),
new
Date
().
getSeconds
())
let
id
:
any
=
tab
.
id
result_sendResponse
=
true
}
}
if
(
monitoringRemoveTabId
.
has
(
tab
.
id
))
{
let
id
:
any
=
tab
.
id
chrome
.
tabs
.
remove
(
id
)
}
}
})
async
function
getUserLoginData
(){
result_sendResponse
=
false
monitoringRemoveTabId
.
clear
()
console
.
log
(
'taIssueId'
,
taIssueId
);
taIssueId
&&
chrome
.
tabs
.
remove
(
taIssueId
);
let
tabId
=
await
createTab
(
homeUrl
);
monitoringRemoveTabId
.
set
(
tabId
,
""
);
async
function
getUserLoginData
()
{
result_sendResponse
=
false
monitoringRemoveTabId
.
clear
()
//
console.log('taIssueId',taIssueId);
taIssueId
&&
chrome
.
tabs
.
remove
(
taIssueId
)
let
tabId
=
await
createTab
(
homeUrl
)
monitoringRemoveTabId
.
set
(
tabId
,
''
)
}
function
newTab
(){
return
new
Promise
<
void
>
((
resolve
,
reject
)
=>
{
if
(
result_sendResponse
)
{
resolve
()
}
else
{
setTimeout
(()
=>
{
newTab
()
},
500
);
}
})
function
newTab
()
{
return
new
Promise
<
void
>
((
resolve
,
reject
)
=>
{
if
(
result_sendResponse
)
{
resolve
()
}
else
{
setTimeout
(()
=>
{
newTab
()
},
500
)
}
})
}
async
function
createTab
(
url
:
string
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
chrome
.
tabs
.
create
({
url
:
url
,
active
:
false
},
async
(
tab
)
=>
{
resolve
(
tab
.
id
);
})
async
function
createTab
(
url
:
string
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
chrome
.
tabs
.
create
({
url
:
url
,
active
:
false
},
async
(
tab
)
=>
{
resolve
(
tab
.
id
)
})
})
}
function
getCookies
(
url
:
string
,
name
:
string
){
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
name
==
""
)
{
chrome
.
cookies
.
getAll
({
url
},
(
cookie
)
=>
{
resolve
(
cookie
);
})
}
else
{
chrome
.
cookies
.
get
({
url
:
url
,
name
:
name
},
(
cookies
)
=>
{
resolve
(
cookies
);
})
function
getCookies
(
url
:
string
,
name
:
string
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
name
==
''
)
{
chrome
.
cookies
.
getAll
({
url
},
(
cookie
)
=>
{
resolve
(
cookie
)
})
}
else
{
chrome
.
cookies
.
get
(
{
url
:
url
,
name
:
name
,
},
(
cookies
)
=>
{
resolve
(
cookies
)
}
})
)
}
})
}
function
getCookieAll
(
url
:
string
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
chrome
.
cookies
.
getAll
({
'url'
:
url
},
(
callback
)
=>
{
if
(
callback
.
length
<=
0
)
resolve
(
""
);
let
cookies
=
""
;
for
(
let
i
=
0
;
i
<
callback
.
length
;
i
++
)
{
cookies
+=
callback
[
i
].
name
+
'='
;
cookies
+=
callback
[
i
].
value
;
if
(
i
!=
callback
.
length
-
1
)
cookies
+=
"; "
;
}
resolve
(
cookies
);
})
})
function
getCookieAll
(
url
:
string
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
chrome
.
cookies
.
getAll
(
{
url
:
url
,
},
(
callback
)
=>
{
if
(
callback
.
length
<=
0
)
resolve
(
''
)
let
cookies
=
''
for
(
let
i
=
0
;
i
<
callback
.
length
;
i
++
)
{
cookies
+=
callback
[
i
].
name
+
'='
cookies
+=
callback
[
i
].
value
if
(
i
!=
callback
.
length
-
1
)
cookies
+=
'; '
}
resolve
(
cookies
)
}
)
})
}
function
isTm
(
userNick
:
string
)
{
for
(
const
suffix
of
tmNameSiffix
)
{
if
(
userNick
.
indexOf
(
suffix
)
!==
-
1
)
return
true
;
}
return
false
;
function
isTm
(
userNick
:
string
)
{
for
(
const
suffix
of
tmNameSiffix
)
{
if
(
userNick
.
indexOf
(
suffix
)
!==
-
1
)
return
true
}
return
false
}
function
getLocalStronges
(
url
:
string
,
name
:
string
){
return
new
Promise
((
resolve
,
reject
)
=>
{
chrome
.
storage
.
local
.
get
({
url
:
url
,
name
:
name
},
(
cookies
)
=>
{
resolve
(
cookies
);
})
})
function
getLocalStronges
(
url
:
string
,
name
:
string
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
chrome
.
storage
.
local
.
get
(
{
url
:
url
,
name
:
name
,
},
(
cookies
)
=>
{
resolve
(
cookies
)
}
)
})
}
src/content/bookingV2.ts
View file @
ec413ab4
...
...
@@ -5,8 +5,20 @@ import {default_tbEnsureIssueJsonV2,default_tbIssueJsonDataV2} from "../types";
let
tbEnsureIssueJsonV2
=
default_tbEnsureIssueJsonV2
let
tbIssueJsonDataV2
:
any
;
let
goodsData
:
any
;
let
userId
:
any
;
// let domEle = {
// logo: (): any => document.querySelector(
// '.user-area-pop-up-panel>div img'
// ),
// }
async
function
booking
(
info
:
any
)
{
let
userData
:
any
=
await
getStorageItem
(
"tb_user"
)
// if(domEle.logo()){
// let src = domEle.logo().getAttribute('src')
// let temp_str = src.split('!!')[1]
// userId = temp_str.split('_')[0]
// console.log('userId');
// }
let
reqMsg
=
{
msg
:
''
,
status
:
-
200
,
...
...
@@ -19,12 +31,13 @@ async function booking(info: any) {
}
let
goodsId
,
result
;
let
userDataJson
:
any
=
JSON
.
parse
(
userData
)
goodsId
=
await
tbGetIssueGoodsIdV2
(
userDataJson
,
goodsData
);
let
goods
=
info
.
goods
.
replaceAll
(
'775011740120'
,
goodsId
)
goods
=
goods
.
replaceAll
(
'88897371'
,
userDataJson
.
userId
)
userId
=
info
.
seller
.
user_id
goodsId
=
await
tbGetIssueGoodsIdV2
(
userDataJson
,
info
.
goods
);
let
goods
=
info
.
goods
.
replaceAll
(
'775011740120'
,
goodsId
+
''
)
goods
=
goods
.
replaceAll
(
'88897371'
,
userId
+
''
)
let
default_info
=
JSON
.
parse
(
goods
)
tbIssueJsonDataV2
=
default_info
result
=
await
tbDataJoinAndIssueV2
(
userDataJson
,
goods
Data
,
goods
Id
);
result
=
await
tbDataJoinAndIssueV2
(
userDataJson
,
goodsId
);
let
rJson
=
result
console
.
log
(
'rJson'
,
rJson
);
try
{
...
...
@@ -97,39 +110,39 @@ async function openVerifyTab(url:string) {
* @param {商品ID} goodsId
*/
function
setTbBaseDataV2
(
goodsData
:
any
,
goodsId
:
number
)
{
let
goodsDataV2
=
goodsData
.
data
;
let
goodsModel
=
goodsDataV2
.
goodsModel
;
let
userId
=
goodsDataV2
.
userId
;
tbIssueJsonDataV2
.
id
=
goodsId
;
//设置商品ID
tbIssueJsonDataV2
.
userId
=
goodsDataV2
.
userId
;
//设置用户ID
tbIssueJsonDataV2
.
tbExtractWay
.
template
=
goodsModel
.
postageId
+
""
;
//设置运费模板ID
tbIssueJsonDataV2
.
title
=
goodsModel
.
title
;
//设置标题
tbIssueJsonDataV2
.
price
=
goodsModel
.
price
;
//设置价格
tbIssueJsonDataV2
.
catProp
=
JSON
.
parse
(
goodsDataV2
.
specificParamToXytPlusParam
);
//设置类目属性
let
shelfProcessing
=
goodsDataV2
.
shelfProcessing
;
if
(
shelfProcessing
==
null
||
shelfProcessing
==
1
)
shelfProcessing
=
2
;
tbIssueJsonDataV2
.
startTime
.
type
=
shelfProcessing
;
//设置上架还是下架
let
shopCat
=
goodsModel
.
classifyId
;
//设置店铺分类信息
if
(
shopCat
!=
null
&&
shopCat
!=
undefined
&&
shopCat
!=
-
1
)
{
tbIssueJsonDataV2
.
shopcat
=
[
shopCat
];
}
else
{
tbIssueJsonDataV2
.
shopcat
=
[];
}
tbIssueJsonDataV2
.
outerId
=
goodsModel
.
outerId
;
//商品编码
tbIssueJsonDataV2
.
descRepublicOfSell
.
descPageRenderParam
.
userId
=
userId
;
tbIssueJsonDataV2
.
descRepublicOfSell
.
descPageRenderParam
.
itemId
=
goodsId
;
tbIssueJsonDataV2
.
descRepublicOfSell
.
descPageRenderModel
.
wholeConfigBO
.
userId
=
userId
;
tbIssueJsonDataV2
.
descRepublicOfSell
.
descPageRenderModel
.
extendConfig
.
wangpuEditorConfig
.
params
.
itemId
=
goodsId
;
//设置退换货承诺
let
sellPromise
=
goodsModel
.
expandParam
.
tbSJKTHHCN
;
if
(
sellPromise
)
{
tbIssueJsonDataV2
.
sellPromise
=
[{
text
:
"退换货承诺"
,
value
:
1
}];
}
}
//
function setTbBaseDataV2(goodsData:any, goodsId: number) {
//
let goodsDataV2 = goodsData.data;
//
let goodsModel = goodsDataV2.goodsModel;
//
let userId = goodsDataV2.userId;
//
tbIssueJsonDataV2.id = goodsId; //设置商品ID
//
tbIssueJsonDataV2.userId = goodsDataV2.userId; //设置用户ID
//
tbIssueJsonDataV2.tbExtractWay.template = goodsModel.postageId + ""; //设置运费模板ID
//
tbIssueJsonDataV2.title = goodsModel.title; //设置标题
//
tbIssueJsonDataV2.price = goodsModel.price; //设置价格
//
tbIssueJsonDataV2.catProp = JSON.parse(goodsDataV2.specificParamToXytPlusParam); //设置类目属性
//
let shelfProcessing = goodsDataV2.shelfProcessing;
//
if (shelfProcessing == null || shelfProcessing == 1) shelfProcessing = 2;
//
tbIssueJsonDataV2.startTime.type = shelfProcessing; //设置上架还是下架
//
let shopCat = goodsModel.classifyId; //设置店铺分类信息
//
if (shopCat != null && shopCat != undefined && shopCat != -1) {
//
tbIssueJsonDataV2.shopcat = [shopCat];
//
} else {
//
tbIssueJsonDataV2.shopcat = [];
//
}
//
tbIssueJsonDataV2.outerId = goodsModel.outerId; //商品编码
//
tbIssueJsonDataV2.descRepublicOfSell.descPageRenderParam.userId = userId;
//
tbIssueJsonDataV2.descRepublicOfSell.descPageRenderParam.itemId = goodsId;
//
tbIssueJsonDataV2.descRepublicOfSell.descPageRenderModel.wholeConfigBO.userId = userId;
//
tbIssueJsonDataV2.descRepublicOfSell.descPageRenderModel.extendConfig.wangpuEditorConfig.params.itemId = goodsId;
//
//设置退换货承诺
//
let sellPromise = goodsModel.expandParam.tbSJKTHHCN;
//
if (sellPromise) {
//
tbIssueJsonDataV2.sellPromise = [{ text: "退换货承诺", value: 1 }];
//
}
//
}
/**
...
...
@@ -329,7 +342,7 @@ function setTbBaseDataV2(goodsData:any, goodsId: number) {
// tbIssueJsonDataV2.saleProp = saleProp;
// }
async
function
tbDataJoinAndIssueV2
(
userData
:
any
,
goods
Data
:
any
,
goods
Id
:
number
)
{
async
function
tbDataJoinAndIssueV2
(
userData
:
any
,
goodsId
:
number
)
{
// setTbBaseDataV2(goodsData, goodsId);
// setTbImageV2(goodsData, goodsId);
// setTbSalePropV2(goodsData, goodsId);
...
...
@@ -364,10 +377,10 @@ async function tbGetIssueGoodsIdV2(userData:any, goodsData:any) {
// let goodsModel = goodsData.data.goodsModel;
// let picPath = goodsModel.masterPics[0];
// let userId = goodsData.data.userId;
tbEnsureIssueJsonV2
.
userId
=
userData
.
userId
;
tbEnsureIssueJsonV2
.
catImages
=
[{
"url"
:
'https://img.alicdn.com/imgextra/i3/88897371/O1CN01wCaCGh24JyKxMRdkR_!!88897371.jpg_100x100'
}];
// userData.userId
let
info
=
JSON
.
parse
(
goodsData
)
tbEnsureIssueJsonV2
.
userId
=
userId
;
tbEnsureIssueJsonV2
.
catImages
=
info
.
images
let
result
:
any
=
await
axios
.
post
(
"https://item.upload.taobao.com/sell/merge/submit.htm"
,{
jsonBody
:
JSON
.
stringify
(
tbEnsureIssueJsonV2
)
},
{
headers
:
{
'Content-Type'
:
'application/x-www-form-urlencoded'
,
...
...
src/content/index.ts
View file @
ec413ab4
...
...
@@ -19,8 +19,9 @@ interface Message {
window
.
addEventListener
(
"message"
,
function
(
message
:
any
){
// console.log('web页面通信1',message,new Date());
if
(
message
.
data
.
action
==
ACTION
.
task
){
window
.
postMessage
({
isResult
:
2
},
"*"
)
chrome
.
runtime
.
sendMessage
(
message
.
data
,(
ret
)
=>
{
console
.
log
(
2222
,
ret
,
new
Date
().
getTime
(),
new
Date
().
getSeconds
());
//
console.log(2222,ret,new Date().getTime(),new Date().getSeconds());
window
.
postMessage
({
isResult
:
1
,...
ret
},
"*"
)
console
.
log
(
"message ret:1"
,
ret
,
message
.
data
);
})
...
...
@@ -34,7 +35,7 @@ chrome.runtime.onMessage.addListener(function (message, sender, response) {
let
result
=
null
;
(
async
()
=>
{
result
=
await
BookingV2
.
booking
(
message
.
value
);
console
.
log
(
2222
,
result
,
new
Date
().
getTime
(),
new
Date
().
getSeconds
());
//
console.log(2222,result,new Date().getTime(),new Date().getSeconds());
response
(
result
);
})();
}
...
...
src/popup/components/WayBillModel/index.tsx
View file @
ec413ab4
...
...
@@ -116,7 +116,7 @@ const WayBillModel = function () {
<
div
className=
"waybill-model-title"
key=
"two"
>
通信状态:
{
link
?
'连接成功'
:
'连接中断'
}
</
div
>
<
div
className=
"waybill-model-title tips"
>
{
info
}
</
div
>
</
div
>
<
Button
className=
"btn"
type=
"primary"
loading=
{
loading
}
disabled=
{
loading
}
onClick=
{
refresh
}
>
刷新连接状态
</
Button
>
{
/* <Button className="btn" type="primary" loading={loading} disabled={loading} onClick={ refresh }>刷新连接状态</Button> */
}
</>
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment