Browse Source

1.0.0:完善我的收藏

feature-1.0
penny 4 years ago
parent
commit
207b5d9e86
  1. 1
      api/myCollection.js
  2. 2
      main.js
  3. 17
      pages/userInfo/myCollection/myCollection.vue
  4. 13
      utils/request.js

1
api/myCollection.js

@ -9,6 +9,5 @@ export function getCollectionList(data) {
url: `${serviceTitle}/img/mini/tiktok/listTiktokCollection`, url: `${serviceTitle}/img/mini/tiktok/listTiktokCollection`,
method: 'post', method: 'post',
data: data data: data
}) })
} }

2
main.js

@ -1,7 +1,7 @@
import App from './App' import App from './App'
import store from './store/' import store from './store/'
const baseURL = 'http://81.69.47.31:7010' const baseURL = 'http://localhost:7010'
Vue.prototype.baseURL = baseURL; Vue.prototype.baseURL = baseURL;

17
pages/userInfo/myCollection/myCollection.vue

@ -1,6 +1,9 @@
<template> <template>
<view> <view>
<text>这是我的收藏</text> <text>这是我的收藏</text>
<view v-for="(item,index) in myCollection" :key="index">
<image :src="item.imgUrl"></image>
</view>
</view> </view>
</template> </template>
@ -9,20 +12,20 @@
export default { export default {
data() { data() {
return { return {
myCollection:[]
} }
}, },
onLoad() { onLoad() {
this.getMyCollection(JSON.stringify(1)) this.getMyCollection(1)
}, },
methods: { methods: {
getMyCollection(userId){ async getMyCollection(userId){
const data = { let data = {
"userId" : userId userId : userId
} }
const res = getCollectionList(JSON.stringify(data)) const res = await getCollectionList(data)
if(res.data.code === 200){ if(res.data.code === 200){
//this.banner = res.data.data this.myCollection = res.data.data
console.log(res) console.log(res)
}else{ }else{
uni.showModal({ uni.showModal({

13
utils/request.js

@ -9,6 +9,7 @@ const service = axios.create({
timeout: 10000 timeout: 10000
}) })
// request拦截器,在请求之前做一些处理 // request拦截器,在请求之前做一些处理
service.interceptors.request.use( service.interceptors.request.use(
config => { config => {
@ -16,12 +17,14 @@ service.interceptors.request.use(
// // 给请求头添加user-token // // 给请求头添加user-token
// config.headers["user-token"] = store.state.token; // config.headers["user-token"] = store.state.token;
// } // }
config.method === 'post' ? config.headers['Content-Type'] = 'application/json'
config.data = qs.stringify({ ...config.data // config.method === 'post' ?
}) : // config.data = qs.stringify({ ...config.data
config.params = { ...config.params // }) :
}; // config.params = { ...config.params
// };
console.log('请求拦截成功') console.log('请求拦截成功')
console.log(config)
return config; return config;
}, },
error => { error => {

Loading…
Cancel
Save