<template>
		<view class="flex-col items-start relative page">
		  <view class="section_2"></view>
		  <image
		    class="image"
		    src="https://carbon2.obs.cn-north-4.myhuaweicloud.com:443/feiyi%2Ftest%2F0%2FRAQucIRR-flower.png"
		  />
		  
			<text class="font pos_2">泠</text>
			<text class="font pos_4">珑</text>

		  <view class="section_3 pos_5"></view>
		  <view class="flex-col justify-start items-center text-wrapper pos_6" @click="login">
				<text class="text">微信登陆</text>
			</view>
		</view>
	<!-- </view> -->

</template>

<script setup>
import { ref } from 'vue'
import { baseUrl, testUrl , suiUrl} from '@/api/request';
import { onMounted } from 'vue';
import { onLoad } from "@dcloudio/uni-app";
import { getFonts } from '../../common/globalFont';

onLoad(() => {
	getFonts()
})
const login = () => {
	uni.login({
		provider: 'weixin', //使用微信登录
		success: function (loginRes) {
			if (loginRes.code !== null) {
				console.log("获取code:" + loginRes.code)
				loginUser(loginRes.code);
			} else {
				console.log("code为空");
			}
		}
	})
}
//非遗
const loginUser = async ( code ) =>{
	const res = await uni.request({
		url: baseUrl + '/user/login/wx_open',
		method: 'GET',
		data: {
			code: code
		}  
	})
	console.log('loginUser后台返回的==>',res.header['Set-Cookie']);
	uni.removeStorageSync('cookie'); 
	uni.setStorageSync("cookie",res.header['Set-Cookie']);  //保存setStorageSync到
	if(res.data.code == 1) {
		uni.showToast({
			title: '登录成功',
			duration: 2000  //提示两秒
		})
		uni.setStorageSync('userInfo',res.data.data);
		uni.switchTab({
			url: '/pages/home/home'
		})
	} else {
		uni.showToast({
			icon: 'error',
			title: "登录失败，请重试"
		})
		return;
	}
}

</script>

<style lang="scss" scoped>
	
.page {
  background-image: url('https://carbon2.obs.cn-north-4.myhuaweicloud.com:443/feiyi%2Ftest%2F0%2FQfLHXSAU-feiyigongfangbeijin.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100vh;
  position: relative
}
.section_2 {
  margin: 0 auto;
  background-color: #9d2624;
  width: 1.88rpx;
  height: 25vh;
}
.image {
  opacity: 0.35;
  width: 631.88rpx;
  height: 907.5rpx;
  position: absolute;
  right: 0;
  bottom: 0;
}
.font {
  font-size: 240rpx;
  font-family: FangZhengXiaoZhuan;
  line-height: 288.75rpx;
  color: #9d2624;
}
.pos_2 {
  position: absolute;
  right: 50%;
  top: 30vh;
  transform: translateX(50%);
}
.pos_4 {
  position: absolute;
  left: 50%;
  bottom: 30vh;
  transform: translateX(-50%);
}
.section_3 {
  background-color: #9d2624;
  width: 1.88rpx;
  height: 25vh;
}
.pos_5 {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
}
.text-wrapper {
  padding: 27.54rpx 0 28.82rpx;
  background-color: #ffffff;
  border-radius: 37.5rpx 0 0 37.5rpx;
  width: 204rpx;
}
.pos_6 {
  position: absolute;
  right: 0;
  top: 1348.13rpx;
}
.text {
  color: #000000;
  font-size: 30rpx;
  font-family: FZSongKeBenXiuKaiS-R-GB;
  line-height: 28.01rpx;
  text-transform: capitalize;
}
@import url(../../common/css/global.css);
</style>