解决token获取

This commit is contained in:
aixianling
2024-04-23 17:55:23 +08:00
parent fa9eba44cf
commit f5c64d0800
3 changed files with 324 additions and 316 deletions

View File

@@ -129,14 +129,14 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
new Promise((resolve) => {
let headers = {};
headers['Content-Type'] = 'text/html';
headers.cookie = getAliexpressCookie();
headers.cookie = getAliexpressCookie(request.url);
const {_m_h5_c, _m_h5_tk} = cookie2Obj(headers.cookie)
const {appKey, formData, token} = request
const {sign, t} = getSign(token || _m_h5_c || _m_h5_tk, appKey, formData)
const {appKey, formData} = request
const {sign, t} = getSign(_m_h5_c || _m_h5_tk, appKey, formData)
const url = new URL(request.url)
let params = new URLSearchParams(url.search);
params.append('sign', sign)
params.append('t', t)
params.append('sign', sign)
url.search = params.toString()
Promise.resolve().then(() => fetch(url.toString(), {
'headers': headers, 'method': 'POST', 'referrerPolicy': 'no-referrer', 'credentials': 'include', 'mode': 'cors'
@@ -251,8 +251,8 @@ function getSheinCookie() {
}
function getAliexpressCookie() {
const url = new URL("https://csp.aliexpress.com/");
function getAliexpressCookie(link = "https://csp.aliexpress.com/") {
const url = new URL(link);
let cStr = '';
chrome.cookies.getAll({domain: url.host}, (cookie) => {
cookie.map((c) => {

View File

@@ -164,6 +164,7 @@
<script>
import {mapMutations, mapState} from 'vuex'
import AiPayment from "@/components/AiPayment.vue";
import {sendAliexpressAPIMessage} from "@/api/chromeApi";
export default {
components: {AiPayment},
@@ -281,7 +282,24 @@ import AiPayment from "@/components/AiPayment.vue";
},
gotoKefu() {
window.open('https://work.weixin.qq.com/kfid/kfcaa4208f661131eba', '_blank')
}
},
getAliexpressGoodsList() {
sendAliexpressAPIMessage({
type: "aliexpress",
url: "https://seller-acs.aliexpress.com/h5/mtop.global.merchant.self.product.manager.render.list/1.0/?jsv=2.7.2&appKey=30267743&v=1.0&timeout=15000&H5Request=true&url=mtop.global.merchant.self.product.manager.render.list&__channel-id__=701301&api=mtop.global.merchant.self.product.manager.render.list&type=originaljson&dataType=json&valueType=original&x-i18n-regionID=AE&data=%7B%22channelId%22%3A%22701301%22%2C%22jsonBody%22%3A%22%7B%5C%22tab%5C%22%3A%5C%22online_product%5C%22%2C%5C%22sort%5C%22%3A%7B%7D%2C%5C%22filter%5C%22%3A%7B%5C%22queryCategory%5C%22%3Anull%2C%5C%22lowerPrice%5C%22%3Anull%2C%5C%22upperPrice%5C%22%3Anull%2C%5C%22status%5C%22%3A%5C%220%5C%22%2C%5C%22productId%5C%22%3Anull%7D%2C%5C%22pagination%5C%22%3A%7B%5C%22pageSize%5C%22%3A10%2C%5C%22current%5C%22%3A2%7D%7D%22%2C%22from%22%3A%22SELF%22%2C%22bizParam%22%3A%22%7B%5C%22version%5C%22%3A%5C%22simple%5C%22%7D%22%7D",
formData: JSON.stringify({
"channelId": "701301",
"jsonBody": "{\"tab\":\"online_product\",\"sort\":{},\"filter\":{\"queryCategory\":null,\"lowerPrice\":null,\"upperPrice\":null,\"status\":\"0\",\"productId\":null},\"pagination\":{\"pageSize\":10,\"current\":2}}",
"from": "SELF",
"bizParam": "{\"version\":\"simple\"}"
})
}).then(res => {
console.log(res)
})
},
},
mounted() {
this.getAliexpressGoodsList()
}
}
</script>
@@ -471,6 +489,7 @@ import AiPayment from "@/components/AiPayment.vue";
width: 60px;
height: 60px;
}
#kefu .topBtn {
width: 60px;
height: 60px;

View File

@@ -153,23 +153,12 @@ export default {
handleClose() {
this.copyFromDlgShow = false
},
getAliexpressGoodsList() {
sendAliexpressAPIMessage({
type: "aliexpress",
url: "https://seller-acs.aliexpress.com/h5/mtop.global.merchant.self.product.manager.render.list/1.0/?jsv=2.7.2&appKey=30267743&v=1.0&timeout=15000&H5Request=true&url=mtop.global.merchant.self.product.manager.render.list&__channel-id__=701301&api=mtop.global.merchant.self.product.manager.render.list&type=originaljson&dataType=json&valueType=original&x-i18n-regionID=AE&data=%7B%22channelId%22%3A%22701301%22%2C%22jsonBody%22%3A%22%7B%5C%22tab%5C%22%3A%5C%22online_product%5C%22%2C%5C%22sort%5C%22%3A%7B%7D%2C%5C%22filter%5C%22%3A%7B%5C%22queryCategory%5C%22%3Anull%2C%5C%22lowerPrice%5C%22%3Anull%2C%5C%22upperPrice%5C%22%3Anull%2C%5C%22status%5C%22%3A%5C%220%5C%22%2C%5C%22productId%5C%22%3Anull%7D%2C%5C%22pagination%5C%22%3A%7B%5C%22pageSize%5C%22%3A10%2C%5C%22current%5C%22%3A2%7D%7D%22%2C%22from%22%3A%22SELF%22%2C%22bizParam%22%3A%22%7B%5C%22version%5C%22%3A%5C%22simple%5C%22%7D%22%7D"
}).then(res => {
console.log(res)
})
},
// 添加模板成功
handleSuccess() {
this.copyFromDlgShow = false
this.getList()
}
},
mounted() {
this.getAliexpressGoodsList()
}
}
</script>