代码格式化

This commit is contained in:
linfeng 2022-09-19 16:51:53 +08:00
parent c8fa1fc36f
commit 0f654e23bb
8 changed files with 242 additions and 230 deletions

View File

@ -10,13 +10,13 @@
export default { export default {
data() { data() {
return { return {
}; };
}, },
methods: { methods: {
goPostAdd() { goPostAdd() {
uni.navigateTo({ uni.navigateTo({
url:'/pages/post/add' url: '/pages/post/add'
}) })
} }
} }
@ -24,18 +24,17 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.add-post {
.add-post{ position: fixed;
position: fixed; right: 20rpx;
right: 20rpx; bottom: 180rpx;
bottom: 180rpx; width: 100rpx;
width: 100rpx; height: 100rpx;
height: 100rpx; border-radius: 50%;
border-radius: 50%; background-color: #333333;
background-color: #333333; box-shadow: 0 0 20rpx #999;
box-shadow: 0 0 20rpx #999; display: flex;
display: flex; justify-content: center;
justify-content: center; align-items: center;
align-items: center; }
}
</style> </style>

View File

@ -3,24 +3,25 @@
<block v-for="(item, index) in list" :key="item.id"> <block v-for="(item, index) in list" :key="item.id">
<view @click="jump(item)"> <view @click="jump(item)">
<view class="post-item"> <view class="post-item">
<view class="post-list-item"> <view class="post-list-item">
<view @click.stop="toUser(item.uid)"> <view @click.stop="toUser(item.uid)">
<u-avatar class="avatar" :src="item.userInfo.avatar" :show-level='item.userInfo.type == 1' level-bg-color="#000000"></u-avatar> <u-avatar class="avatar" :src="item.userInfo.avatar" :show-level='item.userInfo.type == 1'
</view> level-bg-color="#000000"></u-avatar>
<view class="center">
<view style="display: flex;align-items: center;">
<text v-if="item.userInfo.type == 1" class="official">官方</text>
<text class="username">{{ item.userInfo.username.substring(0, 10) }}</text>
<text v-if="item.postTop>0" class="officials">置顶</text>
<text v-if="item.status==1" class="officials">审核中</text>
<text v-if="item.status==2" class="officials">已下架</text>
</view> </view>
<view> <view class="center">
<text class="time">{{ item.createTime}}</text> <view style="display: flex;align-items: center;">
<text v-if="item.userInfo.type == 1" class="official">官方</text>
<text class="username">{{ item.userInfo.username.substring(0, 10) }}</text>
<text v-if="item.postTop>0" class="officials">置顶</text>
<text v-if="item.status==1" class="officials">审核中</text>
<text v-if="item.status==2" class="officials">已下架</text>
</view>
<view>
<text class="time">{{ item.createTime}}</text>
</view>
</view> </view>
</view> </view>
</view>
<view class="post-content"> <view class="post-content">
<rich-text class="post-text" :nodes="item.content"></rich-text> <rich-text class="post-text" :nodes="item.content"></rich-text>
<!-- 帖子类型 --> <!-- 帖子类型 -->
@ -56,9 +57,9 @@
</block> </block>
</block> </block>
</view> </view>
<!-- 位置 --> <!-- 位置 -->
<view class="address" v-if="item.address"> <view class="address" v-if="item.address">
<u-icon class="icon" name="map-fill"></u-icon> <u-icon class="icon" name="map-fill"></u-icon>
@ -78,17 +79,17 @@
<u-icon name="heart"></u-icon> <u-icon name="heart"></u-icon>
<text class="count">{{ item.collectionCount }}</text> <text class="count">{{ item.collectionCount }}</text>
</view> </view>
<view class="p-item margin50"> <view class="p-item margin50">
<text class="iconfont icon-pinglun"></text> <text class="iconfont icon-pinglun"></text>
<text class="count">{{ item.commentCount }}</text> <text class="count">{{ item.commentCount }}</text>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</block> </block>
<!-- 加载状态 --> <!-- 加载状态 -->
<block v-if="list.length === 0 && loadStatus == 'nomore'"> <block v-if="list.length === 0 && loadStatus == 'nomore'">
<u-empty margin-top="100" text="暂无内容" mode="favor"></u-empty> <u-empty margin-top="100" text="暂无内容" mode="favor"></u-empty>
@ -128,7 +129,7 @@
}, },
methods: { methods: {
cancelCollection(id, index) { cancelCollection(id, index) {
this.$H this.$H
.post('post/cancelCollection', { .post('post/cancelCollection', {
@ -160,7 +161,7 @@
urls: urls // http urls: urls // http
}); });
}, },
jump(e) { jump(e) {
let url; let url;
@ -173,7 +174,7 @@
url: url url: url
}); });
}, },
toUser(uid) { toUser(uid) {
uni.navigateTo({ uni.navigateTo({
url: '/pages/user/home?uid=' + uid url: '/pages/user/home?uid=' + uid
@ -198,7 +199,7 @@
height: 600rpx; height: 600rpx;
border-radius: 5px; border-radius: 5px;
overflow: hidden; overflow: hidden;
} }
.img-style-2 { .img-style-2 {
@ -206,7 +207,7 @@
image { image {
margin: 5rpx; margin: 5rpx;
width: 100%; width: 100%;
height: 305rpx; height: 305rpx;
} }
@ -220,19 +221,19 @@
width: 31.3%; width: 31.3%;
height: 200rpx; height: 200rpx;
margin: 0.6%; margin: 0.6%;
} }
} }
.img-style-4 { .img-style-4 {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
image { image {
width: 48%; width: 48%;
height: 320rpx; height: 320rpx;
margin: 0.5%; margin: 0.5%;
} }
} }
} }
@ -255,26 +256,28 @@
.post-list-item { .post-list-item {
display: flex; display: flex;
align-items: center; align-items: center;
.avatar { .avatar {
width: 85rpx; width: 85rpx;
height: 85rpx; height: 85rpx;
border-radius: 50%; border-radius: 50%;
margin-right: 20rpx; margin-right: 20rpx;
} }
.center{ .center {
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
font-size: 24rpx; font-size: 24rpx;
color: #999; color: #999;
.username{
.username {
font-size: 32rpx; font-size: 32rpx;
font-weight: 600; font-weight: 600;
color: #616161; color: #616161;
} }
.official{ .official {
display: inline-block; display: inline-block;
font-size: 20rpx; font-size: 20rpx;
color: #ffffff; color: #ffffff;
@ -283,7 +286,8 @@
border-radius: 10rpx; border-radius: 10rpx;
margin-right: 10rpx; margin-right: 10rpx;
} }
.officials{
.officials {
display: inline-block; display: inline-block;
font-size: 25rpx; font-size: 25rpx;
color: #ffffff; color: #ffffff;
@ -293,11 +297,13 @@
margin-left: 30rpx; margin-left: 30rpx;
} }
} }
.right{
.right {
height: 85rpx; height: 85rpx;
.arrow-down{
.arrow-down {
color: #999; color: #999;
} }
} }
} }
@ -330,9 +336,4 @@
display: none !important; display: none !important;
} }
} }
</style> </style>

View File

@ -8,102 +8,113 @@
<text v-if="item.gender == 1" class="iconfont icon-nan"></text> <text v-if="item.gender == 1" class="iconfont icon-nan"></text>
<text v-if="item.gender == 2" class="iconfont icon-nv"></text> <text v-if="item.gender == 2" class="iconfont icon-nv"></text>
</view> </view>
<u-button @click="follow(index, item.uid)" v-if="item.hasFollow === 0" class="btn-gz" type="default" size="mini">关注</u-button> <u-button @click="follow(index, item.uid)" v-if="item.hasFollow === 0" class="btn-gz" type="default"
<u-button @click="cancelFollow(index, item.uid)" v-if="item.hasFollow === 1" class="btn-gz" type="default" size="mini" plain>互相关注</u-button> size="mini">关注</u-button>
<u-button @click="cancelFollow(index, item.uid)" v-if="item.hasFollow === 2" class="btn-gz" type="default" size="mini" plain>已关注</u-button> <u-button @click="cancelFollow(index, item.uid)" v-if="item.hasFollow === 1" class="btn-gz"
type="default" size="mini" plain>互相关注</u-button>
<u-button @click="cancelFollow(index, item.uid)" v-if="item.hasFollow === 2" class="btn-gz"
type="default" size="mini" plain>已关注</u-button>
</navigator> </navigator>
</block> </block>
<!-- 加载状态 --> <!-- 加载状态 -->
<block v-if="loadStatus != 'none'"> <block v-if="loadStatus != 'none'">
<block v-if="list.length === 0 && loadStatus == 'nomore'"><u-empty margin-top="100" text="暂无用户" mode="favor"></u-empty></block> <block v-if="list.length === 0 && loadStatus == 'nomore'">
<block v-else><u-loadmore margin-bottom="50" margin-top="50" :status="loadStatus" /></block> <u-empty margin-top="100" text="暂无用户" mode="favor"></u-empty>
</block>
<block v-else>
<u-loadmore margin-bottom="50" margin-top="50" :status="loadStatus" />
</block>
</block> </block>
</view> </view>
</template> </template>
<script> <script>
export default { export default {
props: { props: {
list: Array, list: Array,
loadStatus: String loadStatus: String
},
data() {
return {
userList: []
};
},
watch: {
list() {
this.userList = this.list;
}
},
methods: {
follow(index, uid) {
this.$H
.post('user/addFollow', {
id: uid
})
.then(res => {
if (res.code == 0) {
this.userList[index].hasFollow = 1;
}
});
}, },
cancelFollow(index, uid) { data() {
this.$H return {
.post('user/cancelFollow', { userList: []
id: uid };
}) },
.then(res => { watch: {
if (res.code === 0) { list() {
this.userList[index].hasFollow = 0; this.userList = this.list;
} }
}); },
methods: {
follow(index, uid) {
this.$H
.post('user/addFollow', {
id: uid
})
.then(res => {
if (res.code == 0) {
this.userList[index].hasFollow = 1;
}
});
},
cancelFollow(index, uid) {
this.$H
.post('user/cancelFollow', {
id: uid
})
.then(res => {
if (res.code === 0) {
this.userList[index].hasFollow = 0;
}
});
}
} }
} };
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.user-list-item { .user-list-item {
display: flex; display: flex;
align-items: center; align-items: center;
padding: 20rpx; padding: 20rpx;
border-bottom: 1px solid #f5f5f5; border-bottom: 1px solid #f5f5f5;
background-color: #ffffff; background-color: #ffffff;
&:last-child{
border-bottom: 0; &:last-child {
border-bottom: 0;
}
} }
}
.user-list-item .icon-nv { .user-list-item .icon-nv {
color: #ff4d94; color: #ff4d94;
} }
.user-list-item .icon-nan { .user-list-item .icon-nan {
color: #0091ff; color: #0091ff;
} }
.user-list-item .avatar { .user-list-item .avatar {
margin-right: 20rpx; margin-right: 20rpx;
} }
.user-list-item .user .name { .user-list-item .user .name {
margin-right: 20rpx; margin-right: 20rpx;
} }
.user-list-item .user .iconfont { .user-list-item .user .iconfont {
font-size: 12px; font-size: 12px;
} }
/* #ifdef H5 */
.user-list-item .btn-gz { /* #ifdef H5 */
margin-right: 20rpx; .user-list-item .btn-gz {
} margin-right: 20rpx;
/* #endif */ }
/* #ifdef MP */
.user-list-item .btn-gz { /* #endif */
margin-left: auto; /* #ifdef MP */
} .user-list-item .btn-gz {
/* #endif */ margin-left: auto;
}
/* #endif */
</style> </style>

View File

@ -43,7 +43,7 @@
} }
], ],
current: 1, current: 1,
}; };
}, },
computed: { computed: {
@ -97,15 +97,15 @@
}, },
tabChange(index) { tabChange(index) {
this.current = index; this.current = index;
this.followUserPost=[]; this.followUserPost = [];
this.lastPost=[]; this.lastPost = [];
if(index===0){ if (index === 0) {
this.page1 = 1; this.page1 = 1;
this.getFollowUserPost(); this.getFollowUserPost();
this.getMsgNum(); this.getMsgNum();
} }
if(index===1){ if (index === 1) {
this.page2 = 1; this.page2 = 1;
this.getLastPost(); this.getLastPost();
} }
@ -123,17 +123,17 @@
page: this.page1 page: this.page1
}) })
.then(res => { .then(res => {
if(res.code==0&&res.result){ if (res.code == 0 && res.result) {
this.followUserPost = this.followUserPost.concat(res.result.data); this.followUserPost = this.followUserPost.concat(res.result.data);
if (res.result.current_page >= res.result.total || res.result.last_page === 0) { if (res.result.current_page >= res.result.total || res.result.last_page === 0) {
this.loadStatus1 = 'nomore'; this.loadStatus1 = 'nomore';
} else { } else {
this.loadStatus1 = 'loadmore'; this.loadStatus1 = 'loadmore';
} }
}else{ } else {
this.loadStatus1 = 'nomore'; this.loadStatus1 = 'nomore';
} }
}); });
}, },
// //

View File

@ -1,70 +1,71 @@
<template> <template>
<view class="container"> <view class="container">
<view class="title">选择圈子类目</view> <view class="title">选择圈子类目</view>
<view class="class-wrap"> <view class="class-wrap">
<view class="class-item u-line-1" @click="chooseClass(item.cateId,item.cateName)" v-for="(item, index) in classList" :key="index">{{ item.cateName }}</view> <view class="class-item u-line-1" @click="chooseClass(item.cateId,item.cateName)"
v-for="(item, index) in classList" :key="index">{{ item.cateName }}</view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
classList: [] classList: []
}; };
},
created() {
this.getClassList();
},
methods: {
getClassList(){
this.$H.get('topic/classList').then(res=>{
this.classList=res.result
})
}, },
chooseClass(id,name){ created() {
console.log('id:',id) this.getClassList();
console.log('name:',name) },
let pages=getCurrentPages(); methods: {
let nowPage=pages[pages.length-1]; getClassList() {
let prevPage=pages[pages.length-2]; this.$H.get('topic/classList').then(res => {
prevPage.$vm.form.cut=id; this.classList = res.result
prevPage.$vm.cateName=name; })
uni.navigateBack(); },
chooseClass(id, name) {
console.log('id:', id)
console.log('name:', name)
let pages = getCurrentPages();
let nowPage = pages[pages.length - 1];
let prevPage = pages[pages.length - 2];
prevPage.$vm.form.cut = id;
prevPage.$vm.cateName = name;
uni.navigateBack();
}
} }
};
}
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.title { .title {
margin-bottom: 30rpx; margin-bottom: 30rpx;
} }
.class-wrap {
.class-item { .class-wrap {
width: 30%; .class-item {
display: inline-block; width: 30%;
border: 1px solid #999; display: inline-block;
padding: 20rpx; border: 1px solid #999;
font-size: 24rpx; padding: 20rpx;
color: #999; font-size: 24rpx;
text-align: center; color: #999;
margin-bottom: 20rpx; text-align: center;
border-radius: 10rpx; margin-bottom: 20rpx;
&:nth-child(3n + 2) { border-radius: 10rpx;
margin-left: 5%;
margin-right: 5%; &:nth-child(3n + 2) {
} margin-left: 5%;
margin-right: 5%;
&:active{ }
background-color: #333;
color: #fff; &:active {
background-color: #333;
color: #fff;
}
} }
} }
}
</style> </style>

View File

@ -55,7 +55,7 @@
</image> </image>
</view> </view>
</block> </block>
</block> </block>
</view> </view>
@ -108,7 +108,7 @@
<text class="time">{{ item.createTime }}</text> <text class="time">{{ item.createTime }}</text>
</view> </view>
</view> </view>
</view> </view>
<!-- 加载状态 --> <!-- 加载状态 -->
<block v-if="commentList.length > 0"> <block v-if="commentList.length > 0">
<view style="margin: 30rpx;"> <view style="margin: 30rpx;">
@ -251,9 +251,9 @@
success: function() { success: function() {
uni.hideToast(); uni.hideToast();
uni.showToast({ uni.showToast({
title: '复制成功快分享给好友叭~' , title: '复制成功快分享给好友叭~',
icon: 'success', icon: 'success',
duration: 2000, duration: 2000,
}) })
that.showShare = false; that.showShare = false;
} }

View File

@ -49,12 +49,12 @@
classList: [{ classList: [{
cateId: 0, cateId: 0,
cateName: '推荐' cateName: '推荐'
} ], }],
swiperList: [], swiperList: [],
postList: [], postList: [],
loadPostStatus: 'loadmore', loadPostStatus: 'loadmore',
classId:0, classId: 0,
page:1, page: 1,
} }
}, },
onLoad() { onLoad() {
@ -63,22 +63,22 @@
this.getClassList(); this.getClassList();
}, },
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) {
} }
}, },
onPullDownRefresh() { onPullDownRefresh() {
if(this.pageCurrent == 0){ if (this.pageCurrent == 0) {
this.page=1 this.page = 1
this.pageList=[] this.pageList = []
this.getPostList() this.getPostList()
} }
if(this.pageCurrent == 1){ if (this.pageCurrent == 1) {
} }
}, },
methods: { methods: {
@ -100,20 +100,20 @@
}, },
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 => {
console.log(res.result) console.log(res.result)
this.classList=this.classList.concat(res.result) this.classList = this.classList.concat(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', {

View File

@ -11,15 +11,15 @@ export default {
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
} }
@ -64,4 +64,4 @@ export default {
return this.request(options); return this.request(options);
} }
}; };