<template>
	<view class="body">
		<view class="">
			
		</view>
		<view class="bntton" >
			<button type="primary" @click="look()" class="">
				<p class="xiugai3">扫码签到</p>
			</button>
		</view>
	</view>
</template>

<script>
	export default {
		components: {

		},
		data() {
			return {
				level: 3,
			};
		},
		onPullDownRefresh() {
			
		},
		onShow() {
			var globalUser = uni.getStorageSync("globalUser");
			this.level = uni.getStorageSync("level");
			var gid = globalUser.id;
			if (gid != 1) {
				this.gid = true;
			}
			var token = uni.getStorageSync("token");
			if (token.length > 1) {
				var name = uni.getStorageSync("name");
				this.name = name;
				var listName = uni.getStorageSync("listName");
				this.listName = listName;
			} else {
				uni.reLaunch({
					url: '../Login/Login',
				});
			}
			var newparm = uni.getStorageSync("newparm");
			if (newparm.toString().length > 1) {
				if (newparm.avatarUrl.length > 1) {
					
				}
			}
	
		},
		onLoad() {
	
		},
		methods: {
			look() {
				var that = this;
				var serverUrl = that.serverurl;
				uni.scanCode({
					success(res) {
						var code = res.result;
						var newparm = uni.getStorageSync("newparm");
						if (newparm.toString().length > 1) {
							if (newparm.openId.length > 1) {
								if(code!=null||code!=''){
									// var that = this;
									// var serverUrl = that.serverurl;
									var token = uni.getStorageSync("token");
									var openId = newparm.openId;
									uni.request({
										url: serverUrl + "/TSign/sign?code=" + code+"&openId="+openId,
										method: "GET",
										header: {
											'token': token
										},
										success: (Result) => {
											// console.log(Result);
											var res = Result;
											if (res.data.code == true) {
												uni.showModal({
													title: '提示',
													content: "签到成功！",
												});
											} else {
												uni.showModal({
													title: '提示',
													content: res.data.message,
												});
											}
										}
									});
								}
							}
						}else{
							uni.showModal({
								title: '提示',
								content: "微信登录才能打卡",
							});
						}
						
					}
				});
			},
			
			
		}
	}
</script>

<style>
/* 	page{
		background:#1F1635;
		width: 750upx;
		background-color: #000000;
		overflow-x: hidden;
	} */
	.body{
		background:#1F1635;
		width: 750upx;
		height: 1500upx;
	}
	.xiugai3 {
		height: 80upx;
		font-family: "PingFang-SC-Bold";
		font-weight: bold;
		margin: auto;
		font-size: 40upx;
		color: #363D44;
	}
	.bntton{
		position: absolute;
		bottom: 0;
		left: 50%;
		transform: translate(-50%, 0%);
		padding-bottom: 40upx;
	}
</style>
