This commit is contained in:
linfeng 2023-03-13 09:22:40 +08:00
commit d2550c6b09
4 changed files with 356 additions and 354 deletions

View File

@ -1,20 +1,22 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<script> <script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)')) CSS.supports('top: constant(a)'))
document.write( document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + '<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />') (coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script> </script>
<title></title> <title></title>
<!--preload-links--> <!--preload-links-->
<!--app-context--> <!--app-context-->
</head> </head>
<body> <body>
<div id="app"><!--app-html--></div> <div id="app">
<script type="module" src="/main.js"></script> <!--app-html-->
</body> </div>
<script type="module" src="/main.js"></script>
</body>
</html> </html>

View File

@ -1,250 +1,250 @@
<template> <template>
<view> <view>
<!-- navbar --> <!-- navbar -->
<u-navbar :is-back="false" :border-bottom="false"> <u-navbar :is-back="false" :border-bottom="false">
<u-icon name="plus-circle" :size="40" class="add-icon" @click="goPostAdd"></u-icon> <u-icon name="plus-circle" :size="40" class="add-icon" @click="goPostAdd"></u-icon>
<u-tabs :list="pageTab" :current="pageCurrent" @change="pageTabChange"></u-tabs> <u-tabs :list="pageTab" :current="pageCurrent" @change="pageTabChange"></u-tabs>
</u-navbar> </u-navbar>
<!-- 创作广场 --> <!-- 创作广场 -->
<view v-show="pageCurrent == 0"> <view v-show="pageCurrent == 0">
<!-- 分类 --> <!-- 分类 -->
<view class="tabs-wrap"> <view class="tabs-wrap">
<u-tabs :list="classList" name="cateName" :current="current" @change="tabChange"></u-tabs> <u-tabs :list="classList" name="cateName" :current="current" @change="tabChange"></u-tabs>
</view> </view>
<view v-show="current == 0"> <view v-show="current == 0">
<!-- 轮播图 --> <!-- 轮播图 -->
<view class="wrap"> <view class="wrap">
<u-swiper :list="swiperList" name="img" border-radius="20" mode="dot" :effect3d="true"></u-swiper> <u-swiper :list="swiperList" name="img" border-radius="20" mode="dot" :effect3d="true"></u-swiper>
</view> </view>
</view> </view>
<!-- 帖子列表 --> <!-- 帖子列表 -->
<post-list :list="postList" :loadStatus="loadPostStatus"></post-list> <post-list :list="postList" :loadStatus="loadPostStatus"></post-list>
</view> </view>
<!-- 发帖达人 --> <!-- 发帖达人 -->
<view v-show="pageCurrent == 1"> <view v-show="pageCurrent == 1">
<navigator :url="'/pages/user/home?uid=' + item.uid" class="user-item" hover-class="none" <navigator :url="'/pages/user/home?uid=' + item.uid" class="user-item" hover-class="none"
v-for="(item, index) in userList" :key="index"> v-for="(item, index) in userList" :key="index">
<view v-if="index < 10" class="user-index-hot">{{ index + 1 }}</view> <view v-if="index < 10" class="user-index-hot">{{ index + 1 }}</view>
<view v-else class="user-index">{{ index + 1 }}</view> <view v-else class="user-index">{{ index + 1 }}</view>
<image class="avatar" mode="aspectFill" :src="item.avatar"></image> <image class="avatar" mode="aspectFill" :src="item.avatar"></image>
<view class="right"> <view class="right">
<text class="username">{{ item.username }}</text> <text class="username">{{ item.username }}</text>
<view class="tag-wrap"> <view class="tag-wrap">
<text class="tag" :key="index2">{{ item.intro }}</text> <text class="tag" :key="index2">{{ item.intro }}</text>
<text class="tag" :key="index2">+{{ item.postNumber }}</text> <text class="tag" :key="index2">+{{ item.postNumber }}</text>
</view> </view>
</view> </view>
</navigator> </navigator>
<!-- 加载状态 --> <!-- 加载状态 -->
<block v-if="userList.length === 0 && loadStatus == 'nomore'"> <block v-if="userList.length === 0 && loadStatus == 'nomore'">
<u-empty margin-top="100" text="暂无内容" mode="favor"></u-empty> <u-empty margin-top="100" text="暂无内容" mode="favor"></u-empty>
</block> </block>
<block v-else> <block v-else>
<view class="no-info"> <view class="no-info">
<u-loadmore :status="loadStatus" /> <u-loadmore :status="loadStatus" />
</view> </view>
</block> </block>
</view> </view>
<!-- 发帖入口 --> <!-- 发帖入口 -->
<add-post-tag></add-post-tag> <add-post-tag></add-post-tag>
</view> </view>
</template> </template>
<script> <script>
import addPostTag from '../../components/add-post-tag/add-post-tag.vue' import addPostTag from '../../components/add-post-tag/add-post-tag.vue'
export default { export default {
data() { data() {
return { return {
pageCurrent: 0, pageCurrent: 0,
current: 0, current: 0,
pageTab: [{ pageTab: [{
name: '创作广场' name: '创作广场'
}, },
{ {
name: '发帖达人' name: '发帖达人'
} }
], ],
classList: [{ classList: [{
cateId: 0, cateId: 0,
cateName: '推荐' cateName: '推荐'
}], }],
swiperList: [], swiperList: [],
postList: [], postList: [],
loadPostStatus: 'loadmore', loadPostStatus: 'loadmore',
classId: 0, classId: 0,
page: 1, page: 1,
userList: [], userList: [],
loadStatus: 'nomore' loadStatus: 'nomore'
} }
}, },
onLoad() { onLoad() {
this.getBannerList(); this.getBannerList();
this.getPostList(); this.getPostList();
this.getClassList(); this.getClassList();
this.getUserRanking(); this.getUserRanking();
}, },
onReachBottom() { onReachBottom() {
if (this.pageCurrent == 0) { if (this.pageCurrent == 0) {
this.page++; this.page++;
this.getPostList() this.getPostList()
} }
if (this.pageCurrent == 1) { if (this.pageCurrent == 1) {
this.userList = []; this.userList = [];
this.getUserRanking(); this.getUserRanking();
} }
}, },
onPullDownRefresh() { onPullDownRefresh() {
if (this.pageCurrent == 0) { if (this.pageCurrent == 0) {
this.page = 1 this.page = 1
this.pageList = [] this.pageList = []
this.getPostList() this.getPostList()
} else if (this.pageCurrent == 1) { } else if (this.pageCurrent == 1) {
this.userList = []; this.userList = [];
this.getUserRanking(); this.getUserRanking();
} }
}, },
methods: { methods: {
getBannerList() { getBannerList() {
this.$H.get('link/list').then(res => { this.$H.get('link/list').then(res => {
if (res.code == 0) { if (res.code == 0) {
this.swiperList = res.result this.swiperList = res.result
} }
}) })
}, },
toSearch() { toSearch() {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '暂无搜索' title: '暂无搜索'
}) })
}, },
goPostAdd() { goPostAdd() {
uni.navigateTo({ uni.navigateTo({
url: '/pages/post/add' url: '/pages/post/add'
}) })
}, },
pageTabChange(index) { pageTabChange(index) {
this.pageCurrent = index this.pageCurrent = index
}, },
tabChange(index) { tabChange(index) {
this.current = index this.current = index
this.page = 1 this.page = 1
this.classId = this.classList[index].cateId this.classId = this.classList[index].cateId
this.postList = [] this.postList = []
this.getPostList() this.getPostList()
}, },
getClassList() { getClassList() {
this.$H.get('topic/classList').then(res => { this.$H.get('topic/classList').then(res => {
this.classList = this.classList.concat(res.result) this.classList = this.classList.concat(res.result)
}) })
}, },
getUserRanking() { getUserRanking() {
this.$H this.$H
.post('user/userRank') .post('user/userRank')
.then(res => { .then(res => {
this.userList = res.result; this.userList = res.result;
}); });
}, },
// //
getPostList() { getPostList() {
console.log('classId:', this.classId) console.log('classId:', this.classId)
this.loadPostStatus = 'loading'; this.loadPostStatus = 'loading';
this.$H this.$H
.post('post/list', { .post('post/list', {
classId: this.classId, classId: this.classId,
page: this.page page: this.page
}) })
.then(res => { .then(res => {
this.postList = this.postList.concat(res.result.data); this.postList = this.postList.concat(res.result.data);
if (res.result.current_page === res.result.last_page || res.result.last_page === 0) { if (res.result.current_page === res.result.last_page || res.result.last_page === 0) {
this.loadPostStatus = 'nomore'; this.loadPostStatus = 'nomore';
} else { } else {
this.loadPostStatus = 'loadmore'; this.loadPostStatus = 'loadmore';
} }
}); });
}, },
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.add-icon { .add-icon {
margin-left: 20rpx; margin-left: 20rpx;
margin-right: 30%; margin-right: 30%;
} }
.tabs-wrap { .tabs-wrap {
position: sticky; position: sticky;
z-index: 999; z-index: 999;
} }
.wrap { .wrap {
padding: 0 40rpx; padding: 0 40rpx;
} }
// //
.user-item { .user-item {
margin: 30rpx; margin: 30rpx;
padding: 20rpx; padding: 20rpx;
display: flex; display: flex;
border-bottom: 1px solid #f5f5f5; border-bottom: 1px solid #f5f5f5;
.user-index-hot { .user-index-hot {
margin-right: 20rpx; margin-right: 20rpx;
color: #fff; color: #fff;
background-image: linear-gradient(#e64340, #ffaac3); background-image: linear-gradient(#e64340, #ffaac3);
width: 55rpx; width: 55rpx;
height: 55rpx; height: 55rpx;
border-radius: 50%; border-radius: 50%;
text-align: center; text-align: center;
line-height: 55rpx; line-height: 55rpx;
} }
.user-index { .user-index {
margin-right: 20rpx; margin-right: 20rpx;
color: #aaaaff; color: #aaaaff;
font-weight: bold; font-weight: bold;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.avatar { .avatar {
width: 100rpx; width: 100rpx;
height: 100rpx; height: 100rpx;
border-radius: 10rpx; border-radius: 10rpx;
margin-right: 20rpx; margin-right: 20rpx;
} }
.right { .right {
flex: 1; flex: 1;
.username { .username {
font-weight: bold; font-weight: bold;
} }
.tag-wrap { .tag-wrap {
font-size: 20rpx; font-size: 20rpx;
.tag { .tag {
display: inline-block; display: inline-block;
padding: 5rpx 20rpx; padding: 5rpx 20rpx;
border-radius: 10rpx; border-radius: 10rpx;
margin-right: 20rpx; margin-right: 20rpx;
margin-bottom: 20rpx; margin-bottom: 20rpx;
background-color: #7da9bd; background-color: #7da9bd;
&:nth-child(2n) { &:nth-child(2n) {
background-color: #ccb3ff; background-color: #ccb3ff;
} }
} }
} }
} }
.no-info { .no-info {
margin: 30rpx 0; margin: 30rpx 0;
} }
} }
</style> </style>

View File

@ -1,21 +1,21 @@
const miniappName = "林风社交论坛"; //分享时的标题 const miniappName = "林风社交论坛"; //分享时的标题
const shareH5Url = "https://www.linfeng.tech/#/"; //H5分享路径 const shareH5Url = "https://www.linfeng.tech/#/"; //H5分享路径
//本地环境配置 //本地环境配置
// const baseUrl = "localhost:8080"; // const baseUrl = "localhost:8080";
// const domain = 'http://' + baseUrl + "/app/"; // const domain = 'http://' + baseUrl + "/app/";
//线上环境配置 //线上环境配置
const baseUrl = "wxapi.linfeng.tech"; const baseUrl = "wxapi.linfeng.tech";
const domain = 'https://' + baseUrl + "/app/"; const domain = 'https://' + baseUrl + "/app/";
export default { export default {
baseUrl: baseUrl, baseUrl: baseUrl,
domain: domain, domain: domain,
miniappName: miniappName, miniappName: miniappName,
shareH5Url: shareH5Url shareH5Url: shareH5Url
} }

View File

@ -1,67 +1,67 @@
import config from './config.js'; import config from './config.js';
export default { export default {
request(options = {}) { request(options = {}) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let url = options.url; let url = options.url;
if (url.indexOf("http://") == -1 && url.indexOf("https://") == -1) { if (url.indexOf("http://") == -1 && url.indexOf("https://") == -1) {
options.url = config.domain + url; options.url = config.domain + url;
} }
options.header.token = uni.getStorageSync("token"); options.header.token = uni.getStorageSync("token");
options.complete = (response) => { options.complete = (response) => {
if (response.statusCode == 200 || response.statusCode == 0) { if (response.statusCode == 200 || response.statusCode == 0) {
if (response.data.code == 401 || response.data.code == 420) { if (response.data.code == 401 || response.data.code == 420) {
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
uni.navigateTo({ uni.navigateTo({
url: "/pages/login/weixin" url: "/pages/login/weixin"
}) })
// #endif // #endif
// #ifdef H5 // #ifdef H5
uni.navigateTo({ uni.navigateTo({
url: "/pages/login/login" url: "/pages/login/login"
}) })
// #endif // #endif
} }
if (response.data.code == 500) { if (response.data.code == 500) {
uni.showToast({ uni.showToast({
title: response.data.msg, title: response.data.msg,
icon: "none", icon: "none",
duration: 2000 duration: 2000
}); });
} }
resolve(response.data) resolve(response.data)
} else { } else {
uni.showToast({ uni.showToast({
title: '请求异常!', title: '请求异常!',
icon: "none" icon: "none"
}); });
} }
} }
uni.request(options) uni.request(options)
}) })
}, },
post(url, data = {}, header = {}) { post(url, data = {}, header = {}) {
let options = { let options = {
url: url, url: url,
data: data, data: data,
header: header, header: header,
method: "POST" method: "POST"
} }
return this.request(options); return this.request(options);
}, },
get(url, data = {}, header = {}) { get(url, data = {}, header = {}) {
let options = { let options = {
url: url, url: url,
data: data, data: data,
header: header header: header
} }
return this.request(options); return this.request(options);
} }
}; };