优化代码
This commit is contained in:
@@ -15,11 +15,11 @@
|
||||
class="nav-item"
|
||||
hover-class="text-hover"
|
||||
v-for="(item, index) in topic" :key="index" @click="$linkTo('./TopicDetail?themeId=' + item.id + '&name=' + item.title)">
|
||||
<image :src="item.picUrl" mode="aspectFill" />
|
||||
<image :src="item.picUrl" mode="aspectFill"/>
|
||||
<h2>{{ item.title }}</h2>
|
||||
</div>
|
||||
<div class="nav-item" hover-class="text-hover" @click="$linkTo('./Topic')" v-if="topicList.length > 6">
|
||||
<image src="https://cdn.cunwuyun.cn/wxmp/fengdu/ic-more.png" />
|
||||
<image src="https://cdn.cunwuyun.cn/wxmp/fengdu/ic-more.png"/>
|
||||
<h2>更多</h2>
|
||||
</div>
|
||||
</div>
|
||||
@@ -31,31 +31,33 @@
|
||||
hover-stop-propagation
|
||||
@click="$linkTo('./Detail?id=' + item.id + '&name=' + item.topicName + '&themeId=' + item.themeId)">
|
||||
<div class="item-top">
|
||||
<image :src="item.createUserAvatar || 'https://cdn.cunwuyun.cn/wxmp/fengdu/avatar.png'" />
|
||||
<image :src="item.createUserAvatar || 'https://cdn.cunwuyun.cn/wxmp/fengdu/avatar.png'"/>
|
||||
<div class="right">
|
||||
<h3>{{ item.createUserName }}</h3>
|
||||
<span v-if="item.publishDepartName">{{ item.publishDepartName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="item-content">
|
||||
<span hover-stop-propagation v-if="item.themeId" @click.stop="$linkTo('./TopicDetail?themeId=' + item.themeId + '&name=' + item.topicName)">#【{{ item.topicName }}】</span>
|
||||
<span hover-stop-propagation v-if="item.themeId"
|
||||
@click.stop="$linkTo('./TopicDetail?themeId=' + item.themeId + '&name=' + item.topicName)">#【{{ item.topicName }}】</span>
|
||||
<text>{{ item.content }}</text>
|
||||
</div>
|
||||
<div class="item-imgs" v-if="item.files.length">
|
||||
<image mode="aspectFill" @click.stop="previewImage(e.url, item.files)" v-for="(e, i) in item.files" :key="i" :src="e.url" />
|
||||
<image mode="aspectFill" @click.stop="previewImage(e.url, item.files)" v-for="(e, i) in item.files" :key="i" :src="e.url"/>
|
||||
</div>
|
||||
<p>{{ item.createTime }}</p>
|
||||
<div class="item-bottom">
|
||||
<button hover-stop-propagation @click.stop="onBtnClick" open-type="share" :data-content="item.content" :data-themeid="item.themeId" :data-id="item.id" :data-name="item.topicName">
|
||||
<image src="https://cdn.cunwuyun.cn/wxmp/fengdu/ic-zhuanfa.png" />
|
||||
<button hover-stop-propagation @click.stop="onBtnClick" open-type="share" :data-content="item.content" :data-themeid="item.themeId" :data-id="item.id"
|
||||
:data-name="item.topicName">
|
||||
<image src="https://cdn.cunwuyun.cn/wxmp/fengdu/ic-zhuanfa.png"/>
|
||||
<i>{{ item.sharedCount }}</i>
|
||||
</button>
|
||||
<div hover-stop-propagation @click.stop="reciate(item.id, item.appreciateStatus)">
|
||||
<image :src="item.appreciateStatus ? 'https://cdn.cunwuyun.cn/wxmp/fengdu/zan-active.png' : 'https://cdn.cunwuyun.cn/wxmp/fengdu/zan.png'" />
|
||||
<image :src="item.appreciateStatus ? 'https://cdn.cunwuyun.cn/wxmp/fengdu/zan-active.png' : 'https://cdn.cunwuyun.cn/wxmp/fengdu/zan.png'"/>
|
||||
<i>{{ item.appreciateCount }}</i>
|
||||
</div>
|
||||
<div>
|
||||
<image src="https://cdn.cunwuyun.cn/wxmp/fengdu/ic-pinglun.png" />
|
||||
<image src="https://cdn.cunwuyun.cn/wxmp/fengdu/ic-pinglun.png"/>
|
||||
<i>{{ item.commentCount }}</i>
|
||||
</div>
|
||||
</div>
|
||||
@@ -63,21 +65,21 @@
|
||||
<AiEmpty v-if="!list.length"></AiEmpty>
|
||||
</div>
|
||||
<div class="add" hover-class="text-hover" @click="toAdd">
|
||||
<image src="https://cdn.cunwuyun.cn/wxmp/fengdu/ic-fatie.png" />
|
||||
<image src="https://cdn.cunwuyun.cn/wxmp/fengdu/ic-fatie.png"/>
|
||||
</div>
|
||||
<AiLogin ref="login"/>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { mapActions, mapState } from 'vuex'
|
||||
import {mapActions, mapState} from 'vuex'
|
||||
|
||||
export default {
|
||||
export default {
|
||||
name: 'AppCircle',
|
||||
appName: '邻里互助',
|
||||
navigationBarBackgroundColor: '#ffffff',
|
||||
navigationBarTextStyle: 'black',
|
||||
|
||||
data () {
|
||||
data() {
|
||||
return {
|
||||
currIndex: 0,
|
||||
topicList: [],
|
||||
@@ -91,12 +93,12 @@
|
||||
computed: {
|
||||
...mapState(['user', 'token']),
|
||||
|
||||
topic () {
|
||||
topic() {
|
||||
return this.topicList.filter((v, index) => index < 7)
|
||||
}
|
||||
},
|
||||
|
||||
onLoad () {
|
||||
onLoad() {
|
||||
this.getTopicList()
|
||||
|
||||
uni.$on('updateList', () => {
|
||||
@@ -113,24 +115,24 @@
|
||||
}
|
||||
},
|
||||
|
||||
onUnload () {
|
||||
onUnload() {
|
||||
uni.$off('updateList')
|
||||
},
|
||||
|
||||
methods: {
|
||||
...mapActions(['autoLogin']),
|
||||
|
||||
previewImage (url, files) {
|
||||
previewImage(url, files) {
|
||||
uni.previewImage({
|
||||
current: url,
|
||||
urls: files.map(v => v.url)
|
||||
})
|
||||
},
|
||||
|
||||
onBtnClick (e) {
|
||||
onBtnClick(e) {
|
||||
},
|
||||
|
||||
reciate (id, appreciateStatus) {
|
||||
reciate(id, appreciateStatus) {
|
||||
this.$instance.post(`/app/appneighborhoodassistance/appreciate?id=${id}`).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.$toast(appreciateStatus ? '取消点赞' : '点赞成功')
|
||||
@@ -140,7 +142,7 @@
|
||||
})
|
||||
},
|
||||
|
||||
getMyPublishCount () {
|
||||
getMyPublishCount() {
|
||||
this.$instance.post(`/app/appneighborhoodassistance/list`, null, {
|
||||
params: {
|
||||
current: 1,
|
||||
@@ -155,7 +157,7 @@
|
||||
})
|
||||
},
|
||||
|
||||
toAdd () {
|
||||
toAdd() {
|
||||
if (this.user.areaId) {
|
||||
this.$linkTo('./Add')
|
||||
} else {
|
||||
@@ -169,7 +171,7 @@
|
||||
}
|
||||
},
|
||||
|
||||
getTopicList () {
|
||||
getTopicList() {
|
||||
this.$instance.post(`/app/appneighborhoodassistancetheme/list`, null, {
|
||||
withoutToken: true,
|
||||
params: {
|
||||
@@ -184,22 +186,20 @@
|
||||
})
|
||||
},
|
||||
|
||||
changeTab (index) {
|
||||
changeTab(index) {
|
||||
this.currIndex = index
|
||||
this.isMore = false
|
||||
this.current = 1
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.getList()
|
||||
})
|
||||
},
|
||||
|
||||
getList () {
|
||||
getList() {
|
||||
if (this.isMore) return
|
||||
|
||||
this.$loading()
|
||||
this.$instance.post(`/app/appneighborhoodassistance/list`, null, {
|
||||
withoutToken: this.token ? false : true,
|
||||
withoutToken: !this.token,
|
||||
params: {
|
||||
current: this.current,
|
||||
size: 10,
|
||||
@@ -207,7 +207,6 @@
|
||||
}
|
||||
}).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.$hideLoading()
|
||||
if (this.current > 1) {
|
||||
this.list = [...this.list, ...res.data.records.map(e => {
|
||||
return {
|
||||
@@ -234,17 +233,15 @@
|
||||
} else {
|
||||
this.isMore = true
|
||||
}
|
||||
}).catch(() => {
|
||||
this.$hideLoading()
|
||||
})
|
||||
}).finally(() => this.$hideLoading())
|
||||
}
|
||||
},
|
||||
|
||||
onReachBottom () {
|
||||
onReachBottom() {
|
||||
this.getList()
|
||||
},
|
||||
|
||||
onShareAppMessage (e) {
|
||||
onShareAppMessage(e) {
|
||||
this.$instance.post(`/app/appneighborhoodassistance/share?id=${e.target.dataset.id}`).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.changeTab(this.currIndex)
|
||||
@@ -256,11 +253,11 @@
|
||||
path: `/pages/AppCircle/Detail?id=${e.target.dataset.id}&themeId=${e.target.dataset.themeid}&name=${e.target.dataset.name}`
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.AppCircle {
|
||||
.AppCircle {
|
||||
padding-top: 120px;
|
||||
padding-bottom: 40px;
|
||||
|
||||
@@ -500,5 +497,5 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user