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