| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 | <!-- 微信公众号的登录回调页 --><template>	<!-- 空登陆页 -->	<view />	<su-popup :show="state.isPopup" round="10" :showClose="false" @close="closeAuthModal">		<view>			<view class="head-box ">				<view class="ss-flex ss-m-b-20">					<view class="isActive head-title">						您首次登录,请输入手机号验证					</view>				</view>			</view>			<!-- 表单项 -->			<uni-forms ref="smsLoginRef" v-model="state.model" :rules="state.rules" validateTrigger="bind" labelWidth="140"				labelAlign="center" class="loginUniForm">				<uni-forms-item name="mobile" label="手机号" class="loginUniFormItem">					<uni-easyinput placeholder="请输入手机号" v-model="state.model.mobile" :inputBorder="false" type="number">						<template v-slot:right>							<button class="ss-reset-button code-btn code-btn-start" :disabled="state.isMobileEnd"								:class="{ 'code-btn-end': state.isMobileEnd }"								@tap="getSmsCode('smsLogin', state.model.mobile)">								{{ getSmsTimer('smsLogin') }}							</button>						</template>					</uni-easyinput>				</uni-forms-item>						<uni-forms-item name="code" label="验证码" class="loginUniFormItem">					<uni-easyinput placeholder="请输入验证码" v-model="state.model.code" :inputBorder="false" type="number"						maxlength="4">					</uni-easyinput>				</uni-forms-item>			</uni-forms>			<view style="display: flex;justify-content: space-between;margin-top: 20rpx;">				<button class="ss-reset-button login-btn-start" @tap="OfficialEnterLogin"> 继续登录 </button>			</view>		</view>	</su-popup></template><script setup>	import {		ref,		reactive,		unref,		computed	} from 'vue';	import sheep from '@/sheep';	import {		onLoad	} from '@dcloudio/uni-app';	import {		showAuthModal,		closeAuthModal,		getSmsCode,		getSmsTimer	} from '@/sheep/hooks/useModal';	import {		code,		mobile	} from '@/sheep/validate/form';	import AuthUtil from '@/sheep/api/member/auth';	const smsLoginRef = ref(null);	// 数据	const state = reactive({		isPopup:true,		loginReqVO:{			type:31,			code:"",			state:"",		},		isMobileEnd: false, // 手机号输入完毕		codeText: '获取验证码',		model: {			mobile: '', // 手机号			code: '', // 验证码			scene: 1		},		rules: {			code,			mobile,		},	});		// 短信登录	async function OfficialEnterLogin() {		// 参数校验		const validate = await unref(smsLoginRef)			.validate()			.catch((error) => {				console.log('error: ', error);			});		if (!validate) {			return;		}		// 提交数据		const {			code		} = await AuthUtil.OfficialEnterLogin(state.model,state.loginReqVO);		if (code === 0) {			closeAuthModal();			// 检测 H5 登录回调			let returnUrl = uni.getStorageSync('returnUrl');			if (returnUrl) {				uni.removeStorage('returnUrl');				location.replace(returnUrl);			} else {				uni.switchTab({					url: '/',				});			}		}	}	onLoad(async (options) => {		// #ifdef H5		// 将 search 参数赋值到 options 中,方便下面解析		new URLSearchParams(location.search).forEach((value, key) => {			options[key] = value;		});		const event = options.event;		const code = options.code;		const state = options.state;		state.loginReqVO.code = options.code		state.loginReqVO.state = options.state		console.log("state.loginReqVO",state.loginReqVO)		if (event === 'login') { // 场景一:登录			const res = await sheep.$platform.useProvider().login(code, state)			if(!res){				state.isPopup = true				return false			}		} else if (event === 'bind') { // 场景二:绑定			sheep.$platform.useProvider().bind(code, state);		}		// 检测 H5 登录回调		let returnUrl = uni.getStorageSync('returnUrl');		if (returnUrl) {			uni.removeStorage('returnUrl');			location.replace(returnUrl);		} else {			uni.switchTab({				url: '/',			});		}		// #endif	});</script><style lang="scss" scoped>		.login-btn-start {	  width: 158rpx;	  height: 56rpx;	  line-height: normal;	  background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));	  border-radius: 28rpx;	  font-size: 26rpx;	  font-weight: 500;	  color: #fff;	}				.login-wrap {	  padding: 50rpx 34rpx;	  min-height: 500rpx;	  background-color: #fff;	  border-radius: 20rpx 20rpx 0 0;	}		.code-btn-start {	  width: 160rpx;	  height: 56rpx;	  line-height: normal;	  border: 2rpx solid var(--ui-BG-Main);	  border-radius: 28rpx;	  font-size: 26rpx;	  font-weight: 400;	  color: var(--ui-BG-Main);	  opacity: 1;	}		.forgot-btn {	  width: 160rpx;	  line-height: 56rpx;	  font-size: 30rpx;	  font-weight: 500;	  color: #999;	}		.login-btn-start {	  width: 158rpx;	  height: 56rpx;	  line-height: normal;	  background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));	  border-radius: 28rpx;	  font-size: 26rpx;	  font-weight: 500;	  color: #fff;	}		.type-btn {	  padding: 20rpx;	  margin: 40rpx auto;	  width: 200rpx;	  font-size: 30rpx;	  font-weight: 500;	  color: #999999;	}		.auto-login-box {	  width: 100%;	  .auto-login-btn {	    width: 68rpx;	    height: 68rpx;	    border-radius: 50%;	    margin: 0 30rpx;	  }	  .auto-login-img {	    width: 68rpx;	    height: 68rpx;	    border-radius: 50%;	  }	}			.code-btn-start {		color: #55b774;		border: 1px solid #55b774;	}</style>
 |