解决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

@@ -2,7 +2,7 @@
<div class="admin">
<div class="admin-top">
<div class="logo">
<img src="../assets/images/logo.png" />
<img src="../assets/images/logo.png"/>
<span>v{{ version }}</span>
</div>
<div class="admin-right">
@@ -22,7 +22,7 @@
<el-dropdown @command="handleClick">
<div class="userinfo">
<span>{{ $store.state.userInfo.name + "(" + $store.state.userInfo.phone + ")" }}</span>
<img src="../assets/images/bottom.png" />
<img src="../assets/images/bottom.png"/>
</div>
<el-dropdown-menu slot="dropdown">
<!-- <el-dropdown-item command="phone">修改手机</el-dropdown-item> -->
@@ -164,10 +164,11 @@
<script>
import {mapMutations, mapState} from 'vuex'
import AiPayment from "@/components/AiPayment.vue";
import {sendAliexpressAPIMessage} from "@/api/chromeApi";
export default {
export default {
components: {AiPayment},
data () {
data() {
return {
isCollapse: false,
activePath: '/home',
@@ -177,7 +178,7 @@ import AiPayment from "@/components/AiPayment.vue";
code: ''
},
version: '',
vipType: ["体验会员","月会员","半年会员","年会员","多店通用年会员"]
vipType: ["体验会员", "月会员", "半年会员", "年会员", "多店通用年会员"]
}
},
computed: {
@@ -187,9 +188,9 @@ import AiPayment from "@/components/AiPayment.vue";
return '未激活';
} else if (this.$store.state.userInfo.flag == 1) {
if (this.$store.state.userInfo.type != 4) {
return `(${this.$store.state.userInfo.mallName})` + this.vipType[this.$store.state.userInfo.type] + '(' + this.$store.state.userInfo.expireTime.substring(0,10) + ')';
return `(${this.$store.state.userInfo.mallName})` + this.vipType[this.$store.state.userInfo.type] + '(' + this.$store.state.userInfo.expireTime.substring(0, 10) + ')';
} else {
return this.vipType[this.$store.state.userInfo.type] + '(' + this.$store.state.userInfo.expireTime.substring(0,10) + ')'
return this.vipType[this.$store.state.userInfo.type] + '(' + this.$store.state.userInfo.expireTime.substring(0, 10) + ')'
}
} else {
@@ -201,12 +202,12 @@ import AiPayment from "@/components/AiPayment.vue";
},
watch: {
$route (v) {
$route(v) {
this.activePath = v.fullPath
}
},
created () {
created() {
const devVersion = require('../manifest.development.json').version
const prodVersion = require('../manifest.production.json').version
this.version = process.env.NODE_ENV === 'production' ? prodVersion : devVersion
@@ -215,7 +216,7 @@ import AiPayment from "@/components/AiPayment.vue";
methods: {
...mapMutations(['setActiveDlgShow']),
handleClick (e) {
handleClick(e) {
if (e === 'logout') {
this.$store.dispatch('SignOut', false)
} else if (e === 'pwd') {
@@ -271,7 +272,7 @@ import AiPayment from "@/components/AiPayment.vue";
}
})
},
sign () {
sign() {
this.$http.post(`/api/malluser/sign`).then(res => {
if (res.code == 0) {
this.$message.success('签到成功')
@@ -281,13 +282,30 @@ 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>
<style lang="scss" scoped>
.admin {
.admin {
width: 100%;
height: 100vh;
overflow: hidden;
@@ -313,7 +331,7 @@ import AiPayment from "@/components/AiPayment.vue";
align-items: center;
height: calc(100% - 64px);
overflow: hidden;
border-top: 1px solid rgba(0,0,0,0.15);
border-top: 1px solid rgba(0, 0, 0, 0.15);
.container {
flex: 1;
@@ -461,17 +479,18 @@ import AiPayment from "@/components/AiPayment.vue";
}
}
}
}
}
#kefu {
#kefu {
position: fixed;
right: 20px;
bottom: 40px;
z-index: 999;
width: 60px;
height: 60px;
}
#kefu .topBtn {
}
#kefu .topBtn {
width: 60px;
height: 60px;
background-color: #fff;
@@ -486,5 +505,5 @@ import AiPayment from "@/components/AiPayment.vue";
-webkit-animation: wobble 250ms infinite;
animation: wobble 250ms infinite;
background-image: url('data:image/svg+xml;%20charset=utf8,%3Csvg%20t%3D%221575450105478%22%20class%3D%22icon%22%20viewBox%3D%220%200%201220%201024%22%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20p-id%3D%222883%22%20width%3D%2248%22%20height%3D%2248%22%3E%3Cpath%20d%3D%22M609.524%20103.522c-222.89%200-403.712%20178.472-403.712%20398.78%200%20220.31%20180.823%20398.782%20403.712%20398.782%20222.889%200%20403.712-178.473%20403.712-398.781%200-220.309-180.823-398.781-403.712-398.781v48.762c196.1%200%20354.95%20156.785%20354.95%20350.019s-158.85%20350.019-354.95%20350.019-354.95-156.785-354.95-350.02c0-193.233%20158.85-350.018%20354.95-350.018v-48.762z%22%20fill%3D%22%231296db%22%20p-id%3D%222884%22%3E%3C%2Fpath%3E%3Cpath%20d%3D%22M786.578%20916.34c166.45-69.217%20278.408-231.055%20278.408-414.035%200-248.026-203.847-449.219-455.457-449.219-251.619%200-455.457%20201.188-455.457%20449.22%200%2055.397%2010.152%20109.367%2029.718%20159.975%204.855%2012.56-1.39%2026.677-13.949%2031.533-12.56%204.855-26.677-1.39-31.532-13.949a490.396%20490.396%200%200%201-3.042-8.078c-1.85%200.077-3.711%200.116-5.581%200.116C58.06%20671.903%200%20614.597%200%20543.903c0-65.005%2049.09-118.69%20112.68-126.91C153.65%20182.56%20360.56%204.324%20609.528%204.324c248.962%200%20455.877%20178.24%20496.85%20412.67%2063.583%208.225%20112.669%2061.907%20112.669%20126.909%200%2070.694-58.06%20128-129.686%20128-1.89%200-3.771-0.04-5.642-0.119-47.536%20129.702-148.34%20235.841-279.493%20290.027-1.161%2033.464-29.012%2060.24-63.2%2060.24-34.925%200-63.237-27.944-63.237-62.416%200-34.471%2028.312-62.415%2063.237-62.415%2017.892%200%2034.048%207.333%2045.551%2019.12z%22%20fill%3D%22%231296db%22%20p-id%3D%222885%22%3E%3C%2Fpath%3E%3Cpath%20d%3D%22M609.528%20611.405c-58.933%200-112.056-10.644-158.472-28.342-16.123-6.147-30.211-12.702-42.138-19.208-6.926-3.777-11.447-6.59-13.437-7.972-19.24-13.373-44.428%205.446-37.059%2027.688%2035.296%20106.527%20136.054%20179.913%20251.106%20179.913%20115.05%200%20215.796-73.384%20251.092-179.913%207.37-22.243-17.82-41.062-37.06-27.687-1.99%201.383-6.51%204.195-13.434%207.972-11.926%206.505-26.012%2013.06-42.133%2019.207-46.413%2017.698-99.533%2028.342-158.465%2028.342z%22%20fill%3D%22%231296db%22%20p-id%3D%222886%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E');
}
}
</style>

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>