Browse Source

上传api接口,对接首页接口

master
前端-胡立永 11 months ago
parent
commit
03edf9c0c2
10 changed files with 122 additions and 129 deletions
  1. +12
    -1
      api/api.js
  2. +5
    -15
      api/http.js
  3. +2
    -2
      components/post/actorList.vue
  4. +4
    -4
      components/post/postList.vue
  5. +2
    -2
      config.js
  6. +7
    -7
      pages.json
  7. +33
    -49
      pages/index/index.vue
  8. +21
    -22
      pages/publish/actorList.vue
  9. +11
    -2
      pages/publish/postDetail.vue
  10. +25
    -25
      pages/publish/postList.vue

+ 12
- 1
api/api.js View File

@ -8,6 +8,17 @@ const config = {
// },
getConfig : {url : '/api/getConfig', method : 'GET', limit : 500},
//获取banner列表
indexGetBanner : {url : '/api/index/getBanner', method : 'GET'},
//获取认证演员
indexGetActorList : {url : '/api/index/getActorList', method : 'GET'},
//获取动态列表带分页
indexGetTrendsPage : {url : '/api/index/getTrendsPage', method : 'GET'},
//获取动态列表带分页
indexGetActorSetPage : {url : '/api/index/getActorSetPage', method : 'GET'},
//获取动态详情
indexGetTrendsDetail : {url : '/api/index/getTrendsDetail', method : 'GET'},
}
@ -43,7 +54,7 @@ export function api(key, data, callback, loadingTitle){
if (req.auth) {
if (!uni.getStorageSync('token')) {
uni.navigateTo({
url: '/pages/login/mobile'
url: '/pages/auth/login'
})
console.error('需要登录')
return


+ 5
- 15
api/http.js View File

@ -15,7 +15,7 @@ function http(uri, data, callback, method = 'GET', showLoading, title) {
data: enhanceData(data),
method: method,
header: {
'X-Access-Token': localStorage.getItem('token'),
'X-Access-Token': uni.getStorageSync('token'),
'Content-Type' : method == 'POST' ? 'application/x-www-form-urlencoded' : 'application/json'
},
success: (res) => {
@ -24,22 +24,12 @@ function http(uri, data, callback, method = 'GET', showLoading, title) {
uni.hideLoading();
}
if(res.statusCode == 401){
localStorage.removeItem('token')
localStorage.removeItem('userInfo')
if(res.statusCode == 401 ||
res.data.message == '操作失败,token非法无效!'){
uni.removeStorageSync('token')
console.error('登录过期');
uni.navigateTo({
url: '/pages/login/login'
})
}
//后端接口token出现问题
if(res.data && res.data.code == 500 && res.data.message == '操作失败,token非法无效!'){
localStorage.removeItem('token')
localStorage.removeItem('userInfo')
console.error('登录过期');
uni.navigateTo({
url: '/pages/login/login'
url: '/pages/auth/login'
})
}


+ 2
- 2
components/post/actorList.vue View File

@ -3,11 +3,11 @@
<view class="item" v-for="(item, index) in list"
@click="$utils.navigateTo('/publish/postDetail?id=123')"
:key="index">
<image src="/static/image/index/p1.png" mode="aspectFill"></image>
<image :src="item.image" mode="aspectFill"></image>
<view class="text">
<view class="title">
<view class="t">
{{ item.title }}
{{ item.name }}
</view>
<view class="auth">
已认证


+ 4
- 4
components/post/postList.vue View File

@ -1,22 +1,22 @@
<template>
<view class="postList">
<view class="item" v-for="(item, index) in list"
@click="$utils.navigateTo('/publish/postDetail?id=123')"
@click="$utils.navigateTo('/publish/postDetail?id=' + item.id)"
:key="index">
<image src="/static/image/index/p1.png" mode="aspectFill"></image>
<image :src="item.image" mode="aspectFill"></image>
<view class="text">
<view class="title">
{{ item.title }}
</view>
<view class="createBy">
<view class="">
发布人{{ item.createBy }}
发布人{{ item.userId }}
</view>
<view class="">
<uv-icon
size="26rpx"
name="thumb-up"></uv-icon>
100
{{ item.dropNum }}
</view>
</view>
<view class="createTime">


+ 2
- 2
config.js View File

@ -11,10 +11,10 @@ const type = 'dev'
// 环境配置
const config = {
dev : {
baseUrl : 'http://www.gcosc.fun:82',
baseUrl : 'http://admin.anqi.shop/a-notice-api',
},
prod : {
baseUrl : 'http://xxx.xxx.xxx/xxx',
baseUrl : 'http://admin.anqi.shop/a-notice-api',
}
}


+ 7
- 7
pages.json View File

@ -6,6 +6,13 @@
"navigationBarTitleText": ""
}
},
{
"path" : "pages/publish/actorRelease",
"style" :
{
"navigationBarTitleText" : ""
}
},
{
"path" : "pages/publish/publishPost",
"style" :
@ -90,13 +97,6 @@
"navigationBarTitleText" : ""
}
},
{
"path" : "pages/publish/actorRelease",
"style" :
{
"navigationBarTitleText" : ""
}
},
{
"path" : "pages/publish/postList",
"style" :


+ 33
- 49
pages/index/index.vue View File

@ -28,10 +28,9 @@
<view class="swipe">
<uv-swiper
:list="list"
keyName="url"
height="320rpx"
:autoplay="false"></uv-swiper>
:list="banner"
keyName="image"
height="320rpx"></uv-swiper>
</view>
</view>
@ -50,8 +49,8 @@
</view>
<view class="ACTORS">
<uv-swiper
:list="ACTORS"
keyName="url"
:list="actorList"
keyName="logo"
height="320rpx"></uv-swiper>
</view>
</view>
@ -70,7 +69,7 @@
</view>
</view>
<postList :list="postList"/>
<postList :list="trends"/>
</view>
<tabber :select="0"/>
@ -87,53 +86,38 @@
},
data() {
return {
list : [
{
url : '/static/image/index/123123.png'
}
],
ACTORS : [
{
url : '/static/image/index/a1.png'
},
{
url : '/static/image/index/a2.png'
},
{
url : '/static/image/index/a3.png'
},
],
postList : [
{
title : "这是一条动态",
createTime : '2024-08-22 09:00:00',
createBy : "小飞",
},
{
title : "这是一条动态",
createTime : '2024-08-22 09:00:00',
createBy : "小飞",
},
{
title : "这是一条动态",
createTime : '2024-08-22 09:00:00',
createBy : "小飞",
},
{
title : "这是一条动态",
createTime : '2024-08-22 09:00:00',
createBy : "小飞",
},
],
banner : [],
actorList : [],
postList : [],
trends : [],
}
},
computed : {
locale(){
return this.$t('pages.index.index')
}
},
onShow() {
this.getData()
},
methods: {
getData(){
this.$api('indexGetBanner', res => {
if(res.code == 200){
this.banner = res.result
}
})
this.$api('indexGetActorList', res => {
if(res.code == 200){
this.actorList = res.result
}
})
this.$api('indexGetTrendsPage', {
pageNo : 1,
pageSize : 10,
}, res => {
if(res.code == 200){
this.trends = res.result.records
}
})
},
}
}
</script>


+ 21
- 22
pages/publish/actorList.vue View File

@ -37,31 +37,30 @@
},
data() {
return {
actorList : [
{
title : "创作人名称创作人名称创作人名称创作人名称",
createTime : '2024-08-22 09:00:00',
createBy : "小飞",
},
{
title : "创作人名称",
createTime : '2024-08-22 09:00:00',
createBy : "小飞",
},
{
title : "创作人名称",
createTime : '2024-08-22 09:00:00',
createBy : "小飞",
},
{
title : "创作人名称",
createTime : '2024-08-22 09:00:00',
createBy : "小飞",
},
],
actorList : [],
total : 0,
}
},
onShow() {
this.getData()
},
onReachBottom(){
let allTotal = this.queryParams.pageNo * this.queryParams.pageSize
if(allTotal < this.total){
//
this.queryParams.pageSize += 10
this.getData() //
}
},
methods: {
getData(){
this.$api('indexGetActorSetPage', this.queryParams, res => {
if(res.code == 200){
this.actorList = res.result.records
this.total = res.result.total
}
})
},
}
}
</script>


+ 11
- 2
pages/publish/postDetail.vue View File

@ -14,7 +14,7 @@
<view class="createBy">
<view class="">
发布人{{ item.createBy }}
发布人{{ item.userId }}
</view>
<view class="">
发布时间{{ item.createTime }}
@ -61,9 +61,18 @@
onLoad(options) {
// this.$route.query
console.log(options)
this.getData(options.id)
},
methods: {
getData(id){
this.$api('indexGetTrendsDetail', {
id
}, res => {
if(res.code == 200){
this.item = res.result
}
})
},
}
}
</script>


+ 25
- 25
pages/publish/postList.vue View File

@ -36,34 +36,34 @@
},
data() {
return {
postList : [
{
title : "这是一条动态",
createTime : '2024-08-22 09:00:00',
createBy : "小飞",
},
{
title : "这是一条动态",
createTime : '2024-08-22 09:00:00',
createBy : "小飞",
},
{
title : "这是一条动态",
createTime : '2024-08-22 09:00:00',
createBy : "小飞",
},
{
title : "这是一条动态",
createTime : '2024-08-22 09:00:00',
createBy : "小飞",
},
],
postList : [],
total : 0,
queryParams : {
pageNo : 1,
pageSize : 10,
}
}
},
methods: {
leftClick(){
onShow() {
this.getData()
},
onReachBottom(){
let allTotal = this.queryParams.pageNo * this.queryParams.pageSize
if(allTotal < this.total){
//
this.queryParams.pageSize += 10
this.getData() //
}
},
methods: {
getData(){
this.$api('indexGetTrendsPage', this.queryParams, res => {
if(res.code == 200){
this.postList = res.result.records
this.total = res.result.total
}
})
},
}
}
</script>


Loading…
Cancel
Save