<template>
	<view id="sign">
	    <view class="sign_head">
	        <view class="user_picture">
	        <image :src="userImg==''?'https://ibrand-miniprogram.oss-cn-hangzhou.aliyuncs.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%A4%B4%E5%83%8F_%E7%94%BB%E6%9D%BF%201.png':userImg"  />
	
	        </view>
	        <view class="sign_message">
	            <view class="user_name">{{userName}}</view>
	            <view class="user_message">
	                <view class="fs_12">积分：{{point}}</view>
	                <view @tap="sign_rule" class="fs_10 activity_rule">活动规则</view>
	            </view>
	        </view>
	    </view>
	    <view class="back" @tap="goBack">
	        返回签到
	    </view>
	    <view class="sign_data"> 
	        <!-- <signData list="{{list}}"></signData> -->
	        <view class="signData_box">
	            <view class="title">
	                <view class="sign_time">签到时间</view>
	                <view class="sign_prize">获得奖励</view>
	            </view>
	            <view class="signData_message" v-for="(item,index) in signlist" :key="index">
	                <view class="sign_time">{{item.created_at}}</view>
	                <view class="sign_prize">{{item.reward_text}}</view>
	            </view> 
	        </view>
	    </view>
	    <view class="mask_form" v-if="show" @tap="close"  catchtouchmove="true">
	        <view class="rule_box">
				<!-- <view class="mask" v-html="rule"></view> -->
	            <text class="mask" decode="decode">
	            {{rule}}
	            </text>
	            <view @tap="close" class="close_rule">
	            <i class="iconfont icon-close"></i>
	            </view>       
	        </view> 
	    </view> 
	</view>
</template>

<script>
	var app = getApp();
	import {pageLogin, getUrl} from '@/common/js/utils.js';
	export default {
		data() {
			return {
				point: '',
				text: "This is page data.",
				signlist: [],
				userImg: '',
				userName: '',
				rule: '',
				list: {},
				show:false
			};
		},
		methods:{
			 //关闭活动规则
			    close(){
			            this.show=false
			    },
			    //显示活动规则
			    sign_rule() {
			            this.show=true
			    },
			    onLoad: function(options) {
			        this.getSignReword()
			    },
			
			    onShow: function() {
			        this.record()
			
			    },
			    getSignReword() {
			        this.$http.get({
			            api: 'api/sign/getSignReward',
			            header: {
			                Authorization: this.$cookieStorage.get('user_token')
			            },
			        }).then(res => {
			            if (res.statusCode == 200) {
			                    this.point= res.data.data.point,
			                    this.list= res.data.data.item,
			                    this.rule=res.data.data.sign_rule
								console.log("积分",this.point)
			            }
			        })
					this.userImg=this.$cookieStorage.get('userInfoImg'),
					this.userName=this.$cookieStorage.get('userInfoName')
					console.log("this.userImg",this.userImg)
					console.log("this.userName",this.userName)
			    },
			    record() {
			        this.$http.get({
			            api: 'api/sign/record',
			            header: {
			                Authorization: this.$cookieStorage.get('user_token')
			            },
			        }).then(res => {
			            console.log(res)
			                this.signlist=res.data.data.record
			            console.log("signlist", this.signlist)
			        })
			    },
			    goBack() {
			        wx.navigateBack({
			            url: '/pages/user/sign/sign'
			        })
			    },
			
			    onTabItemTap(item) {
			        // tab 点击时执行
			        console.log(item.index)
			        console.log(item.pagePath)
			        console.log(item.text)
			    },
			    // 事件响应函数
			    viewTap: function() {
			        this.setData({
			            text: 'Set some data for updating view.'
			        }, function() {
			            // this is setData callback
			        })
			    },
		}
	}
</script>

<style lang="less">
	@import "signData.less";
</style>
