<template>
	<view class="app">
		<view class="background">
			<view class="content">
				<image src="/pagesB/static/Behave.png" mode=""></image>
				<view class="name">我的积分
				</view>
				<view class="number">{{score?score:0}}
				</view>
				<view class="PointsMall" @tap='gointegral'>
					积分商城
				</view>
				<view class="Exchangerecords" @tap="goexchange">
					兑换记录
				</view>
			</view>
			<view class="bottomitem">
				<view class="PointsRecord">
					积分记录
				</view>
				<view class="" v-if="list&&list.length>0">
					<view class="item" v-for="item in list">
						<view class="Establishingarchives">
							{{item.actName}}
						</view>
						<view class="integral" v-if="item.score>0">
							{{'+'+item.score}}
						</view>
						<view class="integral integraltwo" v-else>
							{{item.score}}
						</view>
						<view class="timeone">
							{{item.scoreDate}}
						</view>
					</view>
				</view>
				<u-empty v-else mode="list" icon-size='220' text='暂无积分记录'></u-empty>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		scorelist,
		scoretotal
	} from '@/api/pagesB/Behaviorpoints/index.js'
	// import {
	// 	mapActions
	// } from "vuex";
	export default {
		data() {
			return {
				query: {
					identity: uni.getStorageSync('userinfo').cardNo,
					pageNum: 1,
					pageSize: 10,
				},
				list: null,
				total: 0,
				score: 0,
			};
		},
		onLoad() {
			this.info();
			this.scoretotalinfo();
		},
		methods: {
			scoretotalinfo() {
				scoretotal(this.query.identity).then(res => {
					this.score = res.data
				})
			},
			info() {
				scorelist(this.query).then(res => {
					this.list = res.rows
					this.total = res.total
				})
			},
			goexchange() {
				uni.navigateTo({
					url: '/pagesB/exchangerecords/exchangerecords'
				})
			},
			//积分页面
			// ...mapActions(["integralopenPopup"]),
			gointegral() {
				// const value = uni.getStorageSync('openid');
				// const value2 = uni.getStorageSync('patientId');
				// if (value && value2) {
				// 	setTimeout(e => {
				// 		uni.navigateTo({
				// 			url: `/pagesB/healthybeans/healthybeans?integral=${this.appPersonallist.integral}`
				// 		})
				// 	}, 0)
				// } else {
				uni.navigateTo({
					url: '/pagesB/PointsMall/PointsMall'
				})
				// this.gologin();
				// }
			},
		},

		onReachBottom() { //下滑加载
			if (this.list.length >= this.total) {} else {
				this.query.pageNum++
				scorelist(this.query).then(res => {
					if (res.rows) {
						res.rows.forEach(e => {
							this.list.push(e)
						})
					}
				})
			}
		},
		onPullDownRefresh() { //下拉刷新
			this.query.pageNum = 1;
			this.info();
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
	}
</script>
<style lang="scss">
	@import './Behaviorpoints.scss'
</style>
