|
|
|
@ -1,6 +1,6 @@ |
|
|
|
|
import {FC, useCallback, useEffect, useState} from "react"; |
|
|
|
|
import {Image, Picker, View} from "@tarojs/components"; |
|
|
|
|
import styles from './offline.module.scss' |
|
|
|
|
import styles from './spotMeeting.module.scss' |
|
|
|
|
import Taro from "@tarojs/taro"; |
|
|
|
|
import {curriculum} from "@/api"; |
|
|
|
|
import {formatDate} from "@/utils/time"; |
|
|
|
@ -8,7 +8,7 @@ import {getSetting, authorize} from "@tarojs/taro"; |
|
|
|
|
import PopPut from "@/components/popPut/popPut"; |
|
|
|
|
import MyButton from "@/components/button/MyButton"; |
|
|
|
|
|
|
|
|
|
const Offline: FC = () => { |
|
|
|
|
const SpotMeeting: FC = () => { |
|
|
|
|
const [manages, setManages] = useState<Manage[]>([]) |
|
|
|
|
const [start, setStart] = useState<string>(formatDate(new Date(), "YY-MM-dd 08:00:00")) |
|
|
|
|
const [end, setEnd] = useState<string>(formatDate(new Date(), "YY-MM-dd 18:00:00")) |
|
|
|
@ -17,23 +17,20 @@ const Offline: FC = () => { |
|
|
|
|
const [depid, setDepid] = useState<number | null>(null) |
|
|
|
|
const [isDownloading, setDownloading] = useState(false) |
|
|
|
|
|
|
|
|
|
Taro.useLoad(() => { |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
curriculum.department().then(res => { |
|
|
|
|
setManages(res.data) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (!depid) { |
|
|
|
|
if (!depid || isDownloading) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (isDownloading) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Taro.showLoading() |
|
|
|
|
setDownloading(true) |
|
|
|
|
|
|
|
|
|
const startTime = new Date(start).getTime() |
|
|
|
|
const endTime = new Date(end).getTime() |
|
|
|
|
const path = encodeURIComponent("/pages/meeting/meeting") |
|
|
|
@ -42,6 +39,7 @@ const Offline: FC = () => { |
|
|
|
|
|
|
|
|
|
if (process.env.TARO_ENV === 'h5') { |
|
|
|
|
setTempFilePath(qrcodeUrl) |
|
|
|
|
setDownloading(false) |
|
|
|
|
} else { |
|
|
|
|
Taro.downloadFile({ |
|
|
|
|
url: qrcodeUrl, |
|
|
|
@ -56,6 +54,7 @@ const Offline: FC = () => { |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
Taro.hideLoading() |
|
|
|
|
}, [depid]) |
|
|
|
|
|
|
|
|
|
function change(e) { |
|
|
|
@ -65,7 +64,8 @@ const Offline: FC = () => { |
|
|
|
|
const handleWriteFile = useCallback(() => { |
|
|
|
|
if (tempFilePath == null) { |
|
|
|
|
Taro.showToast({title: '下载失败', icon: 'error'}) |
|
|
|
|
} else if (process.env.TARO_ENV !== 'h5') { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
Taro.saveImageToPhotosAlbum({ |
|
|
|
|
filePath: tempFilePath, |
|
|
|
|
success() { |
|
|
|
@ -75,12 +75,13 @@ const Offline: FC = () => { |
|
|
|
|
Taro.showToast({title: '下载失败', icon: 'error'}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
Taro.showToast({title: '请截屏', icon: 'error'}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}, [tempFilePath]) |
|
|
|
|
|
|
|
|
|
const handleSaveCode = useCallback(() => { |
|
|
|
|
if (process.env.TARO_ENV === 'h5') { |
|
|
|
|
Taro.showToast({title: '请截屏', icon: 'error'}) |
|
|
|
|
} else { |
|
|
|
|
getSetting({ |
|
|
|
|
success: function ({authSetting}) { |
|
|
|
|
//没有权限则申请
|
|
|
|
@ -97,6 +98,7 @@ const Offline: FC = () => { |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, [tempFilePath]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -126,11 +128,14 @@ const Offline: FC = () => { |
|
|
|
|
onError={(e) => setError(e.detail.errMsg)} |
|
|
|
|
style={{width: '80%'}} |
|
|
|
|
/> |
|
|
|
|
{error && <View>{error}</View>}` |
|
|
|
|
<MyButton onClick={handleSaveCode}>下载</MyButton> |
|
|
|
|
{error && <View>{error}</View>} |
|
|
|
|
|
|
|
|
|
{process.env.TARO_ENV !== 'h5' && <MyButton onClick={handleSaveCode}>下载</MyButton>} |
|
|
|
|
{process.env.TARO_ENV === 'h5' && <View>请截图保存</View>} |
|
|
|
|
|
|
|
|
|
</View>} |
|
|
|
|
</View> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export default Offline |
|
|
|
|
export default SpotMeeting |