From 207b5d9e86d6243384974e032d11e3773513f724 Mon Sep 17 00:00:00 2001 From: penny <2500338766@qq.com> Date: Thu, 5 May 2022 21:21:59 +0800 Subject: [PATCH] =?UTF-8?q?1.0.0=EF=BC=9A=E5=AE=8C=E5=96=84=E6=88=91?= =?UTF-8?q?=E7=9A=84=E6=94=B6=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/myCollection.js | 1 - main.js | 2 +- pages/userInfo/myCollection/myCollection.vue | 17 ++++++++++------- utils/request.js | 13 ++++++++----- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/api/myCollection.js b/api/myCollection.js index db6de4a..679a48b 100644 --- a/api/myCollection.js +++ b/api/myCollection.js @@ -9,6 +9,5 @@ export function getCollectionList(data) { url: `${serviceTitle}/img/mini/tiktok/listTiktokCollection`, method: 'post', data: data - }) } diff --git a/main.js b/main.js index 755bb99..a8cfb6b 100644 --- a/main.js +++ b/main.js @@ -1,7 +1,7 @@ import App from './App' import store from './store/' -const baseURL = 'http://81.69.47.31:7010' +const baseURL = 'http://localhost:7010' Vue.prototype.baseURL = baseURL; diff --git a/pages/userInfo/myCollection/myCollection.vue b/pages/userInfo/myCollection/myCollection.vue index b6f6fc8..979301d 100644 --- a/pages/userInfo/myCollection/myCollection.vue +++ b/pages/userInfo/myCollection/myCollection.vue @@ -1,6 +1,9 @@ @@ -9,20 +12,20 @@ export default { data() { return { - + myCollection:[] } }, onLoad() { - this.getMyCollection(JSON.stringify(1)) + this.getMyCollection(1) }, methods: { - getMyCollection(userId){ - const data = { - "userId" : userId + async getMyCollection(userId){ + let data = { + userId : userId } - const res = getCollectionList(JSON.stringify(data)) + const res = await getCollectionList(data) if(res.data.code === 200){ - //this.banner = res.data.data + this.myCollection = res.data.data console.log(res) }else{ uni.showModal({ diff --git a/utils/request.js b/utils/request.js index f29aabf..db91d45 100644 --- a/utils/request.js +++ b/utils/request.js @@ -9,6 +9,7 @@ const service = axios.create({ timeout: 10000 }) + // request拦截器,在请求之前做一些处理 service.interceptors.request.use( config => { @@ -16,12 +17,14 @@ service.interceptors.request.use( // // 给请求头添加user-token // config.headers["user-token"] = store.state.token; // } - config.method === 'post' ? - config.data = qs.stringify({ ...config.data - }) : - config.params = { ...config.params - }; + config.headers['Content-Type'] = 'application/json' + // config.method === 'post' ? + // config.data = qs.stringify({ ...config.data + // }) : + // config.params = { ...config.params + // }; console.log('请求拦截成功') + console.log(config) return config; }, error => {