<template>
	<view class="mypoints">
		<navbar ref="navbar" :config="config" backColor="#666"></navbar>
		<view class="top">
			<view class="top-item">
				<view class="own">
					<!-- <view class="image"  v-if="myMsg.head_photo">
						<image :src="myMsg.head_photo" mode=""></image>
					</view>
					<view class="image" v-else>
						<image :src="imgUrl+'/head-on.png'" mode=""></image>
					</view> -->
					<view class="name">
						{{myMsg.nickname}}
					</view>
					<view class="detailed" @click="goTodetailed()">
						<text class="iconfont">&#xe60a;</text>
						<div>积分明细</div>
					</view>
				</view>
				<view class="available">
					<view class="available-name">
						可使用积分
					</view>
					<view class="available-number">
						<text>{{myMsg.integral_able}}</text>积分
					</view>
				</view>
			</view>
		</view>
		<view class="content">
			<view class="content-top">
				<view class="task">
					积分任务
				</view>
				<view class="line">
					
				</view>
				<view class="do">
					做任务赚积分
				</view>
			</view>
			<view class="content-item">
				<view class="purchase">
					<view class="purchase-commodity">
						购买商品
					</view>
					<view class="introduce">
						购买商品越多，积分返利越多
					</view>
				</view>
				<view class="complete" @click="goToHomePage()">
					立即完成
				</view>
			</view>
			<!-- <view class="content-item">
				<view class="purchase">
					<view class="purchase-commodity">
						浏览作品/文章
					</view>
					<view class="introduce">
						{{integral.browse}}分/次，每天上限{{integral.browse_limit}}分
					</view>
				</view>
				<view class="complete" @click="goToRecommend()">
					立即完成
				</view>
			</view>
			<view class="content-item">
				<view class="purchase">
					<view class="purchase-commodity">
						点赞作品/文章
					</view>
					<view class="introduce">
						{{integral.like}}分/次，每天上限{{integral.like_limit}}分
					</view>
				</view>
				<view class="complete" @click="goToRecommend()">
					立即完成
				</view>
			</view>
			<view class="content-item">
				<view class="purchase">
					<view class="purchase-commodity">
						转发作品/文章
					</view>
					<view class="introduce">
						{{integral.share}}分/次，每天上限{{integral.share_limit}}分
					</view>
				</view>
				<view class="complete" @click="goToRecommend()">
					立即完成
				</view>
			</view>
			<view class="content-item">
				<view class="purchase">
					<view class="purchase-commodity">
						评论作品/文章
					</view>
					<view class="introduce">
						{{integral.comment}}分/每次提交评论，每天上限{{integral.comment_limit	}}分
					</view>
				</view>
				<view class="complete" @click="goToRecommend()">
					立即完成
				</view>
			</view>
			<view class="content-item">
				<view class="purchase">
					<view class="purchase-commodity">
						作品被浏览
					</view>
					<view class="introduce">
						{{integral.by_browse}}分/次，单个作品/每天 上限{{integral.by_browse_limit}}分
					</view>
				</view>
				<view class="complete" @click="goToCommunity()">
					立即完成
				</view>
			</view>
			<view class="content-item">
				<view class="purchase">
					<view class="purchase-commodity">
						作品被点赞
					</view>
					<view class="introduce">
						{{integral.by_like}}分/次，单个作品/每天 上限{{integral.by_like_limit}}分
					</view>
				</view>
				<view class="complete" @click="goToCommunity()">
					立即完成
				</view>
			</view>
			<view class="content-item">
				<view class="purchase">
					<view class="purchase-commodity">
						作品被评论
					</view>
					<view class="introduce">
						{{integral.by_comment}}分/每次提交评论，单个作品/每天 上限{{integral.by_comment_limit}}分
					</view>
				</view>
				<view class="complete" @click="goToCommunity()">
					立即完成
				</view>
			</view>
			<view class="content-item">
				<view class="purchase">
					<view class="purchase-commodity">
						作品被转发
					</view>
					<view class="introduce">
						{{integral.by_share}}分/次，单个作品/每天 上限{{integral.by_share_limit}}分
					</view>
				</view>
				<view class="complete" @click="goToCommunity()">
					立即完成
				</view>
			</view> -->
			
		</view>
	</view>
</template>

<script>
	import {recordInfo} from "../../../api/notice.js"
	import {getAccountInfo} from "@/api/login.js"
	export default{
		data(){
			return{
				config: {
					back: true, //false是tolbar页面 是则不写
					title: '我的积分',
					color: '#1A1A1A',
					//背景颜色;参数一：透明度（0-1）;参数二：背景颜色（array则为线性渐变，string为单色背景）
					backgroundColor: [1, "#FFFFFF"],
					statusBarFontColor: '#1A1A1A',
				},
				myMsg:{},			//我的个人信息
				integral:{},		//我的积分
				imgUrl: this.$mConfig.staticUrl,
				id: 0
			}
		},
		onShow() {
			this.getMyList()
			this.getMyMsg()
			this.getuserInfo()
		},
		methods:{
			getuserInfo(){
				let shop = uni.getStorageSync('shop')
				this.$http.get('/account/getAccountInfo/'+shop.id).then(async res => {
					if (res && res.code == 200) {
						this.id =res.data.id
					}
				})
			},
			//跳个人主页
			goToCommunity(){
				let that = this
				uni.navigateTo({
					url:"/pages/research/community/homepage?user_id=" + that.id
				})
			},
			//跳研吧
			goToRecommend(){
				// uni.navigateTo({
				// 	url:"/pages/index/recommend"
				// })
			},
			//跳主页
			goToHomePage(){
				uni.redirectTo({
					url:"/pages/index/lidaPage"
				})
			},
			//跳转积分明细
			goTodetailed(){
				uni.navigateTo({
					url:"./pointsDetails"
				})
			},
			//获取积分接口
			getMyList(){
				this.$http.get(recordInfo).then(res=>{
					if(res&&res.code==200){
						this.integral = res.data
						console.log(this.integral)
					}
				})
			},
			//获取我的信息
			getMyMsg(){
				this.$http.get(getAccountInfo).then(res=>{
					if(res&&res.code==200){
						this.myMsg = res.data
						
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		background-color: #ffffff;
		border-radius: 40rpx 40rpx 0 0;
		padding: 38rpx 30rpx 0;
		.content-item{
			display: flex;
			justify-content: space-between;
			align-items: center;
			border-bottom: 1rpx solid #E6E6E6;
			padding-bottom: 36rpx;
			.purchase{
				.purchase-commodity{
					margin-top: 30rpx;
					font-size: 28rpx;
					color: #1A1A1A;
					font-weight: 400;	
				}
				.introduce{
					font-size: 24rpx;
					margin-top: 17rpx;
					color: #999999;
					font-weight: 400;
					line-height: 30rpx;
				}
			}
			.complete{
				color: #ffffff;
				font-size: 28rpx;
				font-weight: 500;
				padding: 12rpx 35rpx;
				border-radius: 32rpx;
				background-color: rgb(64,194,213);
			}
		}
		.content-top{
			display: flex;
			align-items: center;
			.task{
				font-size: 36rpx;
				color: #1A1A1A;
				font-weight: 700;
			}
			.line{
				width: 1rpx;
				height: 32rpx;
				background-color: #707070;
				margin: 16rpx;
			}
			.do{
				font-size: 24rpx;
				font-weight: 400;
				color: #666666;
			}
		}
	}
	.mypoints{
		background-color: #F5F5F5;
	}
	.top{
		// margin: 25rpx 30rpx 0 30rpx ;
		
		padding: 25rpx 30rpx 0;
		.top-item{
			
			background-color: rgb(64,194,213);
			// background-repeat: no-repeat;
			// border-radius: 18rpx;
			border-top-right-radius: 18rpx;
			border-top-left-radius: 18rpx;
			padding: 30rpx 20rpx;
			.available{
				text-align: center;
				color: #ffffff;
					// margin-top: 50rpx;
				.available-name{
					margin-bottom: 6rpx;
					font-size: 30rpx;
					font-weight: 400;
					line-height: 24rpx;
					// text-shadow: 0rpx 11rpx 49rpx  #2A0709;
				}
				.available-number{
				
					font-size: 28rpx;
					font-weight: 700;
					color: #FFFFFF;
					text{
						font-size: 50rpx;
					}
				}
			}
			.own{
				display: flex;
				align-items: center;
				.image{
					image{
						width: 86rpx;
						height: 86rpx;
						border-radius: 50%;
					}
				}
				.name{
					flex: 1;
					margin-left: 20rpx;
					font-size: 36rpx;
					font-weight: 400;
					color: #ffffff;
					
				}
				.detailed{
					font-size: 24rpx;
					// line-height: 30rpx;
					color: rgb(64,194,213);
					font-weight: 400;
					// padding: 10rpx 30rpx 14rpx ;
					background-color: #ffffff;
					border-radius: 28rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					width: 195rpx;
					height: 55rpx;
					.iconfont{
						font-size: 30rpx;
						margin-right: 16rpx;
					}	
				}
			}
		}
	}
	
</style>
