提交 81133883 编写于 作者: 芊里

积分查询

上级 ec8d8dbd
......@@ -181,10 +181,17 @@
uni.showLoading({
mask: true
})
db.collection(dbCollectionName).field('score,balance').get().then((res) => {
db.collection(dbCollectionName).where('user_id == $env.uid').field('score,balance').get().then((res) => {
const data = res.result.data[0];
console.log(data);
let msg = '';
if(data){
msg = '当前积分为' + data.balance
} else{
msg = '当前无积分';
}
uni.showToast({
title: '当前积分为' + data.balance,
title: msg,
icon: 'none'
});
}).catch((err) => {
......
<template>
<view class="container">
<unicloud-db ref="udb" v-slot:default="{data, pagination, loading, hasMore, error}" :where="where" orderby="update_date desc" collection="opendb-news-favorite">
<view v-if="error">{{error.message}}</view>
<view v-else-if="data">
<unicloud-db ref="udb" v-slot:default="{data, pagination, loading, hasMore, error}" where="user_id == $env.uid"
orderby="update_date desc" collection="opendb-news-favorite" @load="isLoading == false" @error="isLoading == false">
<view v-if="data && data.length">
<uni-list>
<uni-list-item v-for="(item, index) in data" :key="index" :clickable="true" @click="handleItemClick(item)">
<uni-list-item v-for="(item, index) in data" :key="index" :clickable="true"
@click="handleItemClick(item)">
<view slot="body">
<text>{{item.article_title || item.article_id}}</text>
<uni-dateformat class="article-date" :date="item.update_date" format="yyyy-MM-dd hh:mm"
......@@ -13,16 +14,17 @@
</uni-list-item>
</uni-list>
</view>
<uni-nodata v-else :isLoading="isLoading" @retry="refreshData"></uni-nodata>
<uni-load-more :status="loading?'loading':(hasMore ? 'more' : 'noMore')"></uni-load-more>
</unicloud-db>
</view>
</template>
<script>
import { mapGetters } from 'vuex';
export default {
data() {
return {
isLoading: true,
loadMore: {
contentdown: '',
contentrefresh: '',
......@@ -31,27 +33,23 @@
}
},
onPullDownRefresh() {
this.$refs.udb.loadData({
clear: true
}, () => {
uni.stopPullDownRefresh()
})
this.refreshData();
},
onReachBottom() {
this.$refs.udb.loadMore()
},
computed:{
...mapGetters({
userInfo:'user/info'
}),
where(){
return `user_id == '${this.userInfo._id}'`
}
},
methods: {
refreshData() {
this.$refs.udb.loadData({
clear: true
}, (res) => {
console.log(res);
uni.stopPullDownRefresh()
})
},
handleItemClick(item) {
uni.navigateTo({
url: '/pages/list/detail?id='+item.article_id+'&title='+(item.article_title || '')
url: '/pages/list/detail?id=' + item.article_id + '&title=' + (item.article_title || '')
})
}
}
......@@ -59,7 +57,7 @@
</script>
<style>
.article-date{
.article-date {
color: #C8C7CC;
}
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册