parent
4b250d5acb
commit
7da7471724
@ -1,2 +1,3 @@ |
||||
TARO_APP_API=https://yjx.dev.yaojiankang.top |
||||
TARO_APP_LGOIN=true |
||||
|
||||
|
@ -1,2 +1,6 @@ |
||||
export * from './user' |
||||
export * from './curriculum' |
||||
export * from './login' |
||||
export * from './meeting' |
||||
export * from './public' |
||||
export * from './manage' |
||||
|
@ -0,0 +1,7 @@ |
||||
import {request} from "@/api/request"; |
||||
|
||||
export const meetingAPi={ |
||||
qrcodeKey() { |
||||
return request('/api/v1/auth/login/qrcode/key', "GET") |
||||
} |
||||
} |
@ -0,0 +1,6 @@ |
||||
/** 白名单 */ |
||||
export const whiteList: string[] = [ |
||||
'/pages/check/check', |
||||
'/pages/login/login', |
||||
'/pages/meeting/meeting' |
||||
] |
@ -1,94 +0,0 @@ |
||||
import {FC} from "react"; |
||||
import {Button, Form, Input, View} from "@tarojs/components"; |
||||
import Taro, {useLoad, useRouter} from "@tarojs/taro"; |
||||
import {userApi} from "@/api"; |
||||
import {Profile} from '@/store' |
||||
|
||||
const BingUser: FC = () => { |
||||
// const {depid, start_time, end_time} = getCurrentInstance()?.router?.params as unknown as Offline
|
||||
const {setUser, setToken, setCompany} = Profile.useContainer() |
||||
const router = useRouter() |
||||
|
||||
useLoad(() => { |
||||
if (!router.params.ticket) { |
||||
Taro.reLaunch({ |
||||
url: "/pages/index/index" |
||||
}) |
||||
} |
||||
}) |
||||
|
||||
|
||||
// Taro.useLoad(() => {
|
||||
// const time = Date.now()
|
||||
// if (!depid
|
||||
// || !start_time
|
||||
// || !end_time
|
||||
// || time > new Date(end_time).getTime()
|
||||
// || time < new Date(start_time).getTime()) {
|
||||
// Taro.showModal({
|
||||
// title: '二维码已过期',
|
||||
// success() {
|
||||
// Taro.reLaunch({url: '/pages/login/login'})
|
||||
// }
|
||||
// })
|
||||
// return
|
||||
// }
|
||||
// })
|
||||
|
||||
function submit(e) { |
||||
const value = e.detail.value |
||||
// if (!value.user_name || !value.phone_number) {
|
||||
// Taro.showToast({title: '请认真填写', icon: "error"})
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// if (!regexTel.exec(value.phone_number)) {
|
||||
// Taro.showToast({title: '手机号错误', icon: 'error'})
|
||||
// return
|
||||
// }
|
||||
|
||||
Taro.showLoading() |
||||
|
||||
Taro.login({ |
||||
success: async (res) => { |
||||
const data = await userApi.meetingSave({ |
||||
...value, |
||||
code: res.code, |
||||
ticket: router.params.ticket, |
||||
}) |
||||
setCompany(data.company) |
||||
setUser(data.user) |
||||
setToken(data.token) |
||||
Taro.switchTab({url: '/pages/index/index'}) |
||||
}, |
||||
fail: () => { |
||||
Taro.showToast({title: '获取微信登录失败', icon: "error"}) |
||||
}, |
||||
complete() { |
||||
Taro.hideLoading() |
||||
} |
||||
}) |
||||
} |
||||
|
||||
return ( |
||||
<View className='h-10 bg-white p-2'> |
||||
<Form className='form' onSubmit={submit}> |
||||
|
||||
<View className='item'> |
||||
<View>用户名</View> |
||||
<Input placeholder='请输入用户名' focus name='user_name'/> |
||||
</View> |
||||
|
||||
<View className='item'> |
||||
<View>手机号</View> |
||||
<Input type='number' placeholder='请输入手机号' name='phone_number'/> |
||||
</View> |
||||
|
||||
<Button className='button mt-3' formType='submit'>登记</Button> |
||||
</Form> |
||||
</View> |
||||
) |
||||
} |
||||
|
||||
|
||||
export default BingUser |
@ -0,0 +1,105 @@ |
||||
import {FC, useEffect, useState} from "react"; |
||||
import {Button, Form, Input, View} from "@tarojs/components"; |
||||
import Taro, {useRouter} from "@tarojs/taro"; |
||||
import {userApi, loginApi, LoginParams} from "@/api"; |
||||
import {Profile} from '@/store' |
||||
import {getCurrentInstance} from "@tarojs/runtime"; |
||||
import {regexTel} from "@/utils/regu"; |
||||
|
||||
const Meeting: FC = () => { |
||||
const {depid, start_time, end_time} = getCurrentInstance()?.router?.params as unknown as Offline |
||||
const {setUser, setToken, setCompany} = Profile.useContainer() |
||||
const [h5params, setH5Params] = useState<LoginParams | null>(null) |
||||
const router = useRouter() |
||||
|
||||
useEffect(() => { |
||||
loginApi.getMeetingParams().then((res) => { |
||||
setH5Params(res) |
||||
}) |
||||
}, []) |
||||
|
||||
|
||||
Taro.useLoad(() => { |
||||
const time = Date.now() |
||||
if (!depid |
||||
|| !start_time |
||||
|| !end_time |
||||
|| time > new Date(end_time).getTime() |
||||
|| time < new Date(start_time).getTime()) { |
||||
Taro.showModal({ |
||||
title: '二维码已过期', |
||||
success() { |
||||
Taro.reLaunch({url: '/pages/login/login'}) |
||||
} |
||||
}) |
||||
return |
||||
} |
||||
}) |
||||
|
||||
function submit(e) { |
||||
const value = e.detail.value |
||||
if (!value.user_name || !value.phone_number) { |
||||
Taro.showToast({title: '请认真填写', icon: "error"}) |
||||
return |
||||
} |
||||
|
||||
if (!regexTel.exec(value.phone_number)) { |
||||
Taro.showToast({title: '手机号错误', icon: 'error'}) |
||||
return |
||||
} |
||||
|
||||
if (process.env.TARO_ENV === 'h5') { |
||||
if (h5params == null) { |
||||
Taro.showToast({title: '页面参数错误,请刷新页面!', icon: 'error'}) |
||||
return; |
||||
} |
||||
location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?" + |
||||
"appid=" + h5params!.appid + |
||||
"&redirect_uri=" + encodeURIComponent(h5params!.route + `?depid=1&phone_number=${value.phone_number}&user_name=${value.user_name}`) + |
||||
"&response_type=code" + |
||||
"&scope=snsapi_userinfo" + |
||||
"#wechat_redirect"; |
||||
|
||||
} else { |
||||
Taro.login({ |
||||
success: async (res) => { |
||||
const data = await userApi.meetingSave({ |
||||
...value, |
||||
code: res.code, |
||||
ticket: router.params.ticket, |
||||
}) |
||||
setCompany(data.company) |
||||
setUser(data.user) |
||||
setToken(data.token) |
||||
Taro.switchTab({url: '/pages/index/index'}) |
||||
}, |
||||
fail: () => { |
||||
Taro.showToast({title: '获取微信登录失败', icon: "error"}) |
||||
} |
||||
}) |
||||
|
||||
} |
||||
} |
||||
|
||||
return ( |
||||
<View className='h-10 bg-white p-2'> |
||||
<Form className='form' onSubmit={submit}> |
||||
|
||||
<View className='item'> |
||||
<View>用户名</View> |
||||
<Input placeholder='请输入用户名' focus name='user_name'/> |
||||
</View> |
||||
|
||||
<View className='item'> |
||||
<View>手机号</View> |
||||
<Input type='number' placeholder='请输入手机号' name='phone_number'/> |
||||
</View> |
||||
|
||||
<Button className='button mt-3' formType='submit'>登记</Button> |
||||
</Form> |
||||
</View> |
||||
) |
||||
} |
||||
|
||||
|
||||
export default Meeting |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 739 B |
After Width: | Height: | Size: 951 B |
After Width: | Height: | Size: 2.7 KiB |
Loading…
Reference in new issue