parent
0d05ea82ac
commit
7f4092cc8a
@ -0,0 +1,18 @@ |
||||
import Taro from "@tarojs/taro"; |
||||
|
||||
/** 首页全局事件 */ |
||||
const KEY = 'REFRESHINDEX' |
||||
|
||||
function on(fn: (arg: any) => void) { |
||||
Taro.eventCenter.on(KEY, fn) |
||||
} |
||||
|
||||
function trigger(data:any){ |
||||
Taro.eventCenter.trigger(KEY, data) |
||||
} |
||||
|
||||
export default { |
||||
on, |
||||
trigger |
||||
} |
||||
|
@ -0,0 +1,3 @@ |
||||
export default definePageConfig({ |
||||
navigationBarTitleText: '注册', |
||||
}) |
@ -0,0 +1,49 @@ |
||||
import {FC} from "react"; |
||||
import {Button, Form, Input, View} from "@tarojs/components"; |
||||
import {getCurrentInstance} from "@tarojs/runtime"; |
||||
import Taro from "@tarojs/taro"; |
||||
|
||||
const BingUser: FC = () => { |
||||
const {company_id, department_id, start_time, end_time} = getCurrentInstance()?.router?.params as unknown as Offline |
||||
|
||||
Taro.useLoad(() => { |
||||
const time = Date.now() |
||||
if (!company_id |
||||
|| !department_id |
||||
|| !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 |
||||
} |
||||
|
||||
}) |
||||
|
||||
|
||||
return ( |
||||
<View className='h-10 bg-white p-2'> |
||||
<Form className='form'> |
||||
|
||||
<View className='item'> |
||||
<View>用户名</View> |
||||
<Input placeholder='请输入用户名' focus/> |
||||
</View> |
||||
|
||||
<View className='item'> |
||||
<View>手机号</View> |
||||
<Input type='number' placeholder='请输入手机号'/> |
||||
</View> |
||||
|
||||
<Button className='button mt-3' formType='submit'>登录</Button> |
||||
</Form> |
||||
</View> |
||||
) |
||||
} |
||||
|
||||
export default BingUser |
@ -0,0 +1,4 @@ |
||||
export default definePageConfig({ |
||||
navigationBarTitleText: '见面会', |
||||
enableShareAppMessage: true |
||||
}) |
@ -0,0 +1,11 @@ |
||||
.page { |
||||
background: #fff; |
||||
min-height: 100vh; |
||||
padding: 20px; |
||||
} |
||||
|
||||
.time { |
||||
border-bottom: 1px solid #ddd; |
||||
padding: 30px 15px; |
||||
border-radius: 10px; |
||||
} |
@ -0,0 +1,168 @@ |
||||
import {FC, useCallback, useState} from "react"; |
||||
import {Button, Image, Picker, View} from "@tarojs/components"; |
||||
import styles from './offline.module.scss' |
||||
import Taro from "@tarojs/taro"; |
||||
import {curriculum} from "@/api"; |
||||
import {formatDate} from "@/utils/time"; |
||||
import {getSetting, authorize} from "@tarojs/taro"; |
||||
import PopPut from "@/components/popPut/popPut"; |
||||
|
||||
|
||||
const Offline: FC = () => { |
||||
const [manages, setManages] = useState<Manage[]>([]) |
||||
const [start, setStart] = useState<string>(formatDate(new Date(), "YY-MM-dd")) |
||||
const [end, setEnd] = useState<string>(formatDate(new Date(), "YY-MM-dd")) |
||||
const [tempFilePath, setTempFilePath] = useState<string | null>(null); |
||||
|
||||
|
||||
Taro.useLoad(() => { |
||||
curriculum.department().then(res => { |
||||
setManages(res.data) |
||||
}) |
||||
}) |
||||
|
||||
async function change(e) { |
||||
const depName = e.detail.value |
||||
if (!depName) { |
||||
Taro.showToast({title: '请选择部门', icon: 'error'}) |
||||
return null |
||||
} |
||||
|
||||
const startTime = new Date(start).getTime() |
||||
const endTime = new Date(end).getTime() |
||||
const depid = manages.find(d => d.name === depName)?.id |
||||
const path = encodeURIComponent("/pages/meeting/index") |
||||
|
||||
const qrcodeUrl = `${process.env.TARO_APP_API}/wechat/link?depid=${depid}&start_time=${startTime}&end_time=${endTime}&path=${path}` |
||||
|
||||
Taro.downloadFile({ |
||||
url: qrcodeUrl, |
||||
success(res) { |
||||
setTempFilePath(res.tempFilePath) |
||||
}, |
||||
fail() { |
||||
Taro.showToast({title: '二维码生产失败', icon: 'error'}) |
||||
} |
||||
} |
||||
) |
||||
} |
||||
|
||||
|
||||
// const paintingCanvas = () => {
|
||||
// Taro.showLoading()
|
||||
// try {
|
||||
// Taro.createSelectorQuery().select('#canvasId').fields({node: true, size: true}).exec((res) => {
|
||||
// const width = res[0].width
|
||||
// const height = res[0].height
|
||||
//
|
||||
// const canvas = res[0].node
|
||||
//
|
||||
// Mycanvas = canvas
|
||||
// const ctx = canvas.getContext('2d')
|
||||
//
|
||||
// const dpr = Taro.getSystemInfoSync().pixelRatio
|
||||
// canvas.width = width * dpr
|
||||
// canvas.height = height * dpr
|
||||
// ctx.scale(dpr, dpr)
|
||||
//
|
||||
// ctx.fillStyle = '#ffffff'
|
||||
// ctx.fillRect(0, 0, width, height)
|
||||
//
|
||||
// ctx.font = '16px Microsoft YaiHei'
|
||||
// ctx.fillStyle = 'black'
|
||||
// ctx.textAlign = 'center';
|
||||
// ctx.fillText(`${start === end ? `有效期${start}` : `开始:${start} 结束:${end}`}`, width / 2, 280)
|
||||
//
|
||||
// Taro.getImageInfo({
|
||||
// src: 'http://81.69.44.74:39200/kynyxd/images/ILBNTCk3PhC3xEV1zCDAsggudZzkiHJi.png',
|
||||
// success(res) {
|
||||
// const img = canvas.createImage()
|
||||
// img.src = res.path
|
||||
// img.onload = () => {
|
||||
// ctx.drawImage(img, (width - 200) / 2, 20, 200, 200)
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// })
|
||||
// } catch (e) {
|
||||
// Taro.showToast({title: '二维码生成失败', icon: 'error'})
|
||||
// }
|
||||
// Taro.hideLoading()
|
||||
// }
|
||||
|
||||
|
||||
const handleWriteFile = useCallback(() => { |
||||
if (tempFilePath) { |
||||
Taro.saveImageToPhotosAlbum({ |
||||
filePath: tempFilePath, |
||||
success() { |
||||
Taro.showModal({title: '下载成功'}) |
||||
}, |
||||
fail() { |
||||
Taro.showToast({title: '下载失败', icon: 'error'}) |
||||
} |
||||
}) |
||||
} else { |
||||
Taro.showToast({title: '下载失败', icon: 'error'}) |
||||
} |
||||
}, [tempFilePath]) |
||||
|
||||
|
||||
// function handleWriteFile() {
|
||||
//
|
||||
// }
|
||||
|
||||
const handleSaveCode = useCallback(() => { |
||||
getSetting({ |
||||
success: function ({authSetting}) { |
||||
//没有权限则申请
|
||||
if (!authSetting["scope.writePhotosAlbum"]) { |
||||
authorize({ |
||||
scope: "scope.writePhotosAlbum", |
||||
success: () => { |
||||
//存储二维码
|
||||
handleWriteFile() |
||||
}, |
||||
}); |
||||
} else { |
||||
handleWriteFile() |
||||
} |
||||
}, |
||||
}); |
||||
}, [tempFilePath]); |
||||
|
||||
|
||||
return ( |
||||
<View className={styles.page}> |
||||
|
||||
<View className={'flex justify-between ' + styles.time}> |
||||
<Picker mode="date" value={start} onChange={(e) => setStart(e.detail.value)} name='start'> |
||||
<View> |
||||
{start} |
||||
</View> |
||||
</Picker> |
||||
|
||||
<View>至</View> |
||||
|
||||
<Picker mode="date" value={start} onChange={(e) => setEnd(e.detail.value)} name='end'> |
||||
<View> |
||||
{end} |
||||
</View> |
||||
</Picker> |
||||
</View> |
||||
|
||||
<View> |
||||
<Picker mode='selector' range={manages} onChange={change} rangeKey='name'> |
||||
<PopPut title='部门'/> |
||||
</Picker> |
||||
</View> |
||||
|
||||
{tempFilePath && <View className='text-center'> |
||||
<Image src={tempFilePath} mode='widthFix'/> |
||||
<Button className='button' onClick={handleSaveCode}>下载</Button> |
||||
</View>} |
||||
</View> |
||||
) |
||||
} |
||||
|
||||
export default Offline |
Loading…
Reference in new issue