Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
csssp-xcx-h5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
劳广强
csssp-xcx-h5
Commits
9c3e144d
提交
9c3e144d
authored
12月 27, 2022
作者:
劳广强
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 首页页面 接入接口
上级
39e63a41
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
94 行增加
和
12 行删除
+94
-12
main.js
main.js
+4
-0
manifest.json
manifest.json
+3
-2
index.vue
pages/index/index.vue
+52
-10
request.js
utils/request.js
+35
-0
没有找到文件。
main.js
浏览文件 @
9c3e144d
...
...
@@ -14,6 +14,10 @@ App.mpType = 'app';
const
app
=
new
Vue
({
...
App
,
});
// 引入请求封装,将app参数传递到配置中
require
(
'@/utils/request.js'
)(
app
);
app
.
$mount
();
// #endif
...
...
manifest.json
浏览文件 @
9c3e144d
...
...
@@ -73,9 +73,10 @@
"devServer"
:
{
"proxy"
:
{
"/api"
:
{
"target"
:
"https://csssptest.yuhuofei.cn"
,
//
"target"
:
"https://csssptest.yuhuofei.cn"
,
"target"
:
"https://devrxssph5.yuhuofei.cn/"
,
"pathRewrite"
:
{
"^/api"
:
""
//
"^/api"
:
""
}
}
}
...
...
pages/index/index.vue
浏览文件 @
9c3e144d
<
template
>
<view>
<view
class=
"wrapper"
>
<view
style=
"height: 256rpx"
/>
<!--
<view
style=
"height: 256rpx"
/>
-->
<view
style=
"height: 28rpx"
/>
<view
style=
"display: flex; justify-content: space-between; align-items: center; padding: 0 30rpx"
>
<image
class=
"logo"
mode=
"widthFix"
src=
"/static/text_sy_tit@2x.png"
/>
<view
class=
"address"
>
...
...
@@ -43,7 +44,7 @@
<view
:class=
"[articleTypeAction === index ? 'article-task-line--action' : 'article-task-line--none']"
/>
</view>
</view>
<view
v-for=
"(item, index) in articleList"
:key=
"item.id"
>
<view
v-for=
"(item, index) in articleList"
:key=
"item.id"
@
click=
"onArticleClick(item, index)"
>
<view
v-if=
"index
<
3
"
class=
"article-content"
>
<view
class=
"article-left"
>
<view
class=
"article-title"
>
{{
item
.
title
}}
</view>
...
...
@@ -68,7 +69,7 @@
<!--
<navigator
hover-class=
"none"
class=
"article_container"
url=
"/package-one/article-detail/article-detail?id=
{{
item
.
id
}}
">
</navigator>
-->
</view>
</view>
<view
class=
"look_more"
bindtap
=
"articleMore"
>
查看更多
</view>
<view
class=
"look_more"
@
click
=
"articleMore"
>
查看更多
</view>
</view>
<view
style=
"background-color: #f6f6f6; width: 100%; height: 20rpx"
/>
...
...
@@ -77,21 +78,52 @@
</
template
>
<
script
>
import
{
articleList
,
articleTypeList
,
bannerList
,
noticeList
}
from
'@/pages/index/mock'
;
export
default
{
data
()
{
return
{
address
:
'获取位置'
,
bannerList
,
noticeList
,
articleTypeList
,
bannerList
:
[]
,
noticeList
:
[]
,
articleTypeList
:
[]
,
articleTypeAction
:
0
,
articleList
,
articleTypeId
:
0
,
articleList
:
[],
};
},
onLoad
(
query
)
{},
onLoad
(
query
)
{
this
.
fetchBannerData
();
this
.
fetchNoticeData
();
this
.
fetchArticleTypeData
();
},
methods
:
{
async
fetchBannerData
()
{
const
{
list
}
=
await
uni
.
$u
.
http
.
get
(
'/api/app/banner/list'
);
this
.
bannerList
=
list
;
},
async
fetchNoticeData
()
{
const
{
list
}
=
await
uni
.
$u
.
http
.
get
(
'/api/app/notice/list'
);
this
.
noticeList
=
list
;
},
async
fetchArticleTypeData
()
{
const
{
list
}
=
await
uni
.
$u
.
http
.
get
(
'/api/app/articletype/list'
);
this
.
articleTypeList
=
list
;
this
.
articleTypeId
=
list
[
0
]?.
id
??
0
;
this
.
fetchArticleData
();
},
async
fetchArticleData
()
{
const
{
list
}
=
await
uni
.
$u
.
http
.
get
(
'/api/article/list'
,
{
params
:
{
article_type_id
:
this
.
articleTypeId
,
},
});
this
.
articleList
=
list
;
},
selectAddress
()
{
console
.
log
(
'获取位置'
);
},
...
...
@@ -99,6 +131,16 @@ export default {
onArticleTypeClick
(
item
,
index
)
{
if
(
this
.
articleTypeAction
===
index
)
return
;
this
.
articleTypeAction
=
index
;
this
.
articleTypeId
=
item
.
id
;
this
.
fetchArticleData
();
},
articleMore
()
{
uni
.
$u
.
route
({
url
:
'pages/article-list/index'
});
},
onArticleClick
(
item
,
index
)
{
uni
.
$u
.
route
({
url
:
'pages/article-detail/index'
,
params
:
{
id
:
item
.
id
}
});
},
},
};
...
...
utils/request.js
0 → 100644
浏览文件 @
9c3e144d
// 此vm参数为页面的实例,可以通过它引用vuex中的变量
module
.
exports
=
(
vm
)
=>
{
// 初始化请求配置
uni
.
$u
.
http
.
setConfig
((
config
)
=>
{
return
config
;
});
// 请求拦截
uni
.
$u
.
http
.
interceptors
.
request
.
use
(
(
config
)
=>
{
config
.
data
=
config
.
data
||
{};
// config.header.token = '1234qwer1234';
config
.
params
.
token
=
'1234qwer1234'
;
return
config
;
},
(
config
)
=>
{
return
Promise
.
reject
(
config
);
}
);
// 响应拦截
uni
.
$u
.
http
.
interceptors
.
response
.
use
(
(
response
)
=>
{
const
data
=
response
.
data
;
if
(
data
.
errcode
)
uni
.
$u
.
toast
(
data
.
msg
);
return
data
.
data
===
undefined
?
{}
:
data
.
data
;
},
(
response
)
=>
{
// 对响应错误做点什么 (statusCode !== 200)
return
Promise
.
reject
(
response
);
}
);
};
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论