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`,
method: 'post',
data: data
})
}

2
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;

17
pages/userInfo/myCollection/myCollection.vue

@ -1,6 +1,9 @@
<template>
<view>
<text>这是我的收藏</text>
<view v-for="(item,index) in myCollection" :key="index">
<image :src="item.imgUrl"></image>
</view>
</view>
</template>
@ -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({

13
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 => {

Loading…
Cancel
Save