代码格式化

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

View File

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

View File

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

View File

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

View File

@ -1,70 +1,71 @@
<template>
<view class="container">
<view class="title">选择圈子类目</view>
<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>
</template>
<script>
export default {
data() {
return {
classList: []
};
},
created() {
this.getClassList();
},
methods: {
getClassList(){
this.$H.get('topic/classList').then(res=>{
this.classList=res.result
})
export default {
data() {
return {
classList: []
};
},
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();
created() {
this.getClassList();
},
methods: {
getClassList() {
this.$H.get('topic/classList').then(res => {
this.classList = res.result
})
},
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>
<style lang="scss" scoped>
.title {
margin-bottom: 30rpx;
}
.class-wrap {
.class-item {
width: 30%;
display: inline-block;
border: 1px solid #999;
padding: 20rpx;
font-size: 24rpx;
color: #999;
text-align: center;
margin-bottom: 20rpx;
border-radius: 10rpx;
&:nth-child(3n + 2) {
margin-left: 5%;
margin-right: 5%;
}
&:active{
background-color: #333;
color: #fff;
.title {
margin-bottom: 30rpx;
}
.class-wrap {
.class-item {
width: 30%;
display: inline-block;
border: 1px solid #999;
padding: 20rpx;
font-size: 24rpx;
color: #999;
text-align: center;
margin-bottom: 20rpx;
border-radius: 10rpx;
&:nth-child(3n + 2) {
margin-left: 5%;
margin-right: 5%;
}
&:active {
background-color: #333;
color: #fff;
}
}
}
}
</style>

View File

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

View File

@ -49,12 +49,12 @@
classList: [{
cateId: 0,
cateName: '推荐'
} ],
}],
swiperList: [],
postList: [],
loadPostStatus: 'loadmore',
classId:0,
page:1,
classId: 0,
page: 1,
}
},
onLoad() {
@ -63,22 +63,22 @@
this.getClassList();
},
onReachBottom() {
if(this.pageCurrent == 0){
if (this.pageCurrent == 0) {
this.page++;
this.getPostList()
}
if(this.pageCurrent == 1){
if (this.pageCurrent == 1) {
}
},
onPullDownRefresh() {
if(this.pageCurrent == 0){
this.page=1
this.pageList=[]
if (this.pageCurrent == 0) {
this.page = 1
this.pageList = []
this.getPostList()
}
if(this.pageCurrent == 1){
if (this.pageCurrent == 1) {
}
},
methods: {
@ -100,20 +100,20 @@
},
tabChange(index) {
this.current = index
this.page=1
this.classId=this.classList[index].cateId
this.postList=[]
this.page = 1
this.classId = this.classList[index].cateId
this.postList = []
this.getPostList()
},
getClassList(){
this.$H.get('topic/classList').then(res=>{
getClassList() {
this.$H.get('topic/classList').then(res => {
console.log(res.result)
this.classList=this.classList.concat(res.result)
this.classList = this.classList.concat(res.result)
})
},
//
getPostList() {
console.log('classId:',this.classId)
console.log('classId:', this.classId)
this.loadPostStatus = 'loading';
this.$H
.post('post/list', {

View File

@ -11,15 +11,15 @@ export default {
if (response.statusCode == 200 || response.statusCode == 0) {
if (response.data.code == 401 || response.data.code == 420) {
// #ifdef MP-WEIXIN
uni.navigateTo({
url: "/pages/login/weixin"
})
uni.navigateTo({
url: "/pages/login/weixin"
})
// #endif
// #ifdef H5
uni.navigateTo({
url: "/pages/login/login"
})
uni.navigateTo({
url: "/pages/login/login"
})
// #endif
}
@ -64,4 +64,4 @@ export default {
return this.request(options);
}
};
};