|
@@ -19,6 +19,7 @@ if (process.env.TARO_ENV == 'rn') {
|
|
|
export default function DayNightSwiperPopup(props: { authInfo: any }) {
|
|
export default function DayNightSwiperPopup(props: { authInfo: any }) {
|
|
|
const [showDetailModal, setShowDetailModal] = useState(false)
|
|
const [showDetailModal, setShowDetailModal] = useState(false)
|
|
|
const [showDetailPopup, setShowDetailPopup] = useState(false)
|
|
const [showDetailPopup, setShowDetailPopup] = useState(false)
|
|
|
|
|
+ const [isLoading, setIsLoading] = useState(false)
|
|
|
const [authInfo, setAuthInfo] = useState<any>(props.authInfo)
|
|
const [authInfo, setAuthInfo] = useState<any>(props.authInfo)
|
|
|
const [dayDate, setDayDate] = useState<any>('')
|
|
const [dayDate, setDayDate] = useState<any>('')
|
|
|
const [nightDate, setNightDate] = useState<any>('')
|
|
const [nightDate, setNightDate] = useState<any>('')
|
|
@@ -28,6 +29,12 @@ export default function DayNightSwiperPopup(props: { authInfo: any }) {
|
|
|
setAuthInfo(props.authInfo)
|
|
setAuthInfo(props.authInfo)
|
|
|
}, [props.authInfo])
|
|
}, [props.authInfo])
|
|
|
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ if (global.updateLocationLoading) {
|
|
|
|
|
+ global.updateLocationLoading(isLoading)
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [isLoading])
|
|
|
|
|
+
|
|
|
const { t } = useTranslation()
|
|
const { t } = useTranslation()
|
|
|
|
|
|
|
|
function modalContent() {
|
|
function modalContent() {
|
|
@@ -35,6 +42,11 @@ export default function DayNightSwiperPopup(props: { authInfo: any }) {
|
|
|
testInfo={null}
|
|
testInfo={null}
|
|
|
dismiss={() => {
|
|
dismiss={() => {
|
|
|
setShowDetailPopup(false)
|
|
setShowDetailPopup(false)
|
|
|
|
|
+ setIsLoading(false)
|
|
|
|
|
+ if (process.env.TARO_ENV == 'rn' && kIsAndroid) {
|
|
|
|
|
+ var Jto = require('react-native').NativeModules.NativeBridge;
|
|
|
|
|
+ Jto.stopLocation()
|
|
|
|
|
+ }
|
|
|
}}
|
|
}}
|
|
|
confirm={() => { }}>
|
|
confirm={() => { }}>
|
|
|
<DayNightDetailPopup
|
|
<DayNightDetailPopup
|
|
@@ -43,7 +55,14 @@ export default function DayNightSwiperPopup(props: { authInfo: any }) {
|
|
|
nightDate={nightDate}
|
|
nightDate={nightDate}
|
|
|
dayDate={dayDate}
|
|
dayDate={dayDate}
|
|
|
updateLocation={auth}
|
|
updateLocation={auth}
|
|
|
- onClose={() => { setShowDetailPopup(false) }}
|
|
|
|
|
|
|
+ onClose={() => {
|
|
|
|
|
+ setShowDetailPopup(false)
|
|
|
|
|
+ setIsLoading(false)
|
|
|
|
|
+ if (process.env.TARO_ENV == 'rn' && kIsAndroid) {
|
|
|
|
|
+ var Jto = require('react-native').NativeModules.NativeBridge;
|
|
|
|
|
+ Jto.stopLocation()
|
|
|
|
|
+ }
|
|
|
|
|
+ }}
|
|
|
/>
|
|
/>
|
|
|
</Modal>
|
|
</Modal>
|
|
|
}
|
|
}
|
|
@@ -191,13 +210,20 @@ export default function DayNightSwiperPopup(props: { authInfo: any }) {
|
|
|
var status = statuses[PERMISSIONS.ANDROID.ACCESS_COARSE_LOCATION];
|
|
var status = statuses[PERMISSIONS.ANDROID.ACCESS_COARSE_LOCATION];
|
|
|
if (status == 'granted') {
|
|
if (status == 'granted') {
|
|
|
var Jto = require('react-native').NativeModules.NativeBridge;
|
|
var Jto = require('react-native').NativeModules.NativeBridge;
|
|
|
|
|
+ setIsLoading(true)
|
|
|
Jto.getLocation().then(result => {
|
|
Jto.getLocation().then(result => {
|
|
|
uploadLocation(JSON.parse(result));
|
|
uploadLocation(JSON.parse(result));
|
|
|
-
|
|
|
|
|
|
|
+ setIsLoading(false)
|
|
|
}).catch(e => {
|
|
}).catch(e => {
|
|
|
console.log('rn location error', e)
|
|
console.log('rn location error', e)
|
|
|
- var ToastAndroid = require('react-native').ToastAndroid;
|
|
|
|
|
- ToastAndroid.show(t('feature.day_night.location_failed'), ToastAndroid.LONG);
|
|
|
|
|
|
|
+ showAlert({
|
|
|
|
|
+ title: 'Failure',
|
|
|
|
|
+ content: t('feature.day_night.location_failed'),
|
|
|
|
|
+ showCancel: false
|
|
|
|
|
+ })
|
|
|
|
|
+ setIsLoading(false)
|
|
|
|
|
+ // var ToastAndroid = require('react-native').ToastAndroid;
|
|
|
|
|
+ // ToastAndroid.show(t('feature.day_night.location_failed'), ToastAndroid.LONG);
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
@@ -208,10 +234,10 @@ export default function DayNightSwiperPopup(props: { authInfo: any }) {
|
|
|
else {
|
|
else {
|
|
|
showAlert({
|
|
showAlert({
|
|
|
title: t('feature.auth_sys.location_title'),
|
|
title: t('feature.auth_sys.location_title'),
|
|
|
- content: t('feature.auth_sys.location_desc'),
|
|
|
|
|
|
|
+ content: t('feature.auth_sys.device_location_desc'),
|
|
|
showCancel: true,
|
|
showCancel: true,
|
|
|
cancelText: t('feature.auth_sys.location_cancel'),
|
|
cancelText: t('feature.auth_sys.location_cancel'),
|
|
|
- confirmText: t('feature.auth_sys.location_confirm'),
|
|
|
|
|
|
|
+ confirmText: t('feature.auth_sys.device_confirm'),
|
|
|
confirm: () => {
|
|
confirm: () => {
|
|
|
Jto.openSystemLocationSettings()
|
|
Jto.openSystemLocationSettings()
|
|
|
}
|
|
}
|
|
@@ -225,19 +251,22 @@ export default function DayNightSwiperPopup(props: { authInfo: any }) {
|
|
|
|
|
|
|
|
function authLocation() {
|
|
function authLocation() {
|
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
if (process.env.TARO_ENV == 'rn') {
|
|
|
|
|
+ setIsLoading(true)
|
|
|
Taro.getLocation({
|
|
Taro.getLocation({
|
|
|
success(res) {
|
|
success(res) {
|
|
|
uploadLocation(res);
|
|
uploadLocation(res);
|
|
|
|
|
+ setIsLoading(false)
|
|
|
},
|
|
},
|
|
|
fail(res) {
|
|
fail(res) {
|
|
|
console.log('location update failed reason', res)
|
|
console.log('location update failed reason', res)
|
|
|
if (res.errMsg == 'Permissions denied!') {
|
|
if (res.errMsg == 'Permissions denied!') {
|
|
|
|
|
+ setIsLoading(false)
|
|
|
showAlert({
|
|
showAlert({
|
|
|
title: t('feature.auth_sys.location_title'),
|
|
title: t('feature.auth_sys.location_title'),
|
|
|
- content: t('feature.auth_sys.location_desc'),
|
|
|
|
|
|
|
+ content: kIsIOS ? t('feature.auth_sys.location_desc') : t('feature.auth_sys.location_android_service_desc'),
|
|
|
showCancel: true,
|
|
showCancel: true,
|
|
|
cancelText: t('feature.auth_sys.location_cancel'),
|
|
cancelText: t('feature.auth_sys.location_cancel'),
|
|
|
- confirmText: t('feature.auth_sys.location_confirm'),
|
|
|
|
|
|
|
+ confirmText: kIsIOS ? t('feature.auth_sys.location_confirm') : t('feature.auth_sys.service_confirm'),
|
|
|
confirm: () => {
|
|
confirm: () => {
|
|
|
if (kIsIOS) {
|
|
if (kIsIOS) {
|
|
|
Linking.openURL('app-settings:')
|
|
Linking.openURL('app-settings:')
|
|
@@ -257,16 +286,24 @@ export default function DayNightSwiperPopup(props: { authInfo: any }) {
|
|
|
var Jto = require('react-native').NativeModules.NativeBridge;
|
|
var Jto = require('react-native').NativeModules.NativeBridge;
|
|
|
Jto.getLocation().then(result => {
|
|
Jto.getLocation().then(result => {
|
|
|
uploadLocation(JSON.parse(result));
|
|
uploadLocation(JSON.parse(result));
|
|
|
|
|
+ setIsLoading(false)
|
|
|
|
|
|
|
|
}).catch(e => {
|
|
}).catch(e => {
|
|
|
- console.log('rn location error', e)
|
|
|
|
|
- var ToastAndroid = require('react-native').ToastAndroid;
|
|
|
|
|
- ToastAndroid.show(t('feature.day_night.location_failed'), ToastAndroid.LONG);
|
|
|
|
|
|
|
+ showAlert({
|
|
|
|
|
+ title: 'Failure',
|
|
|
|
|
+ content: t('feature.day_night.location_failed'),
|
|
|
|
|
+ showCancel: false
|
|
|
|
|
+ })
|
|
|
|
|
+ setIsLoading(false)
|
|
|
|
|
+ // console.log('rn location error', e)
|
|
|
|
|
+ // var ToastAndroid = require('react-native').ToastAndroid;
|
|
|
|
|
+ // ToastAndroid.show(t('feature.day_night.location_failed'), ToastAndroid.LONG);
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
|
|
+ setIsLoading(false)
|
|
|
showAlert({
|
|
showAlert({
|
|
|
- title: 'Error',
|
|
|
|
|
|
|
+ title: 'Failure',
|
|
|
content: t('feature.day_night.location_failed'),
|
|
content: t('feature.day_night.location_failed'),
|
|
|
showCancel: false
|
|
showCancel: false
|
|
|
})
|
|
})
|