Home Article Practice firstpage_index1

firstpage_index1

2024-07-07 11:34  views:370  source:许某    

import {
ZText,
ZView,
ZStore,
ZImage,
ZMarquee,
ZLinearGradient,
ZNotify,
ZTouchableOpacity,
} from "@zto/brick";
import React, { useEffect, useState } from "react";
import { QRCode } from "@static";
import {noticeIcon,receivedOrderIcon,
dispatchedPartsIcon,backgroundImg,searchIcon,
extensionImg,mronIcon,studyIocn,
studyTextIcon,extenImg }
from '@static/firstpage'
import { setH, setW } from "@utils/adaptive";
import {printAuthority} from '../../apis/beginOrderApi'
import {
AppRegistry,
StyleSheet,
View,
TouchableOpacity,
ImageBackground,
ScrollView,
RefreshControl,
NativeModules,
Platform,
Modal,
ActivityIndicator
} from "react-native";
import { homeMetrics,queryOrderCount,
countDispatchCenter,appUpgrade,AuthCheck,
operateEwbInfoApi } from '@apis/firstpageApi'
import { checkOrderNoRegular, dealwithScanResult }
from '@filters/common'
import { setCustomText } from '@components/CustomText'
import { diffDate,dateTime }
from '@filters/date.filter'
import { getTokens } from '@utils/user.token'
import RnSwiper from '@components/RnSwiper'
//扫描
const { startScan, specialToast } =
NativeModules.RNScanMain
import ZRN from '@zto/zrn-js'
const { BackgroundTimer } = ZRN.Modules
const { getSiteInfo } =
NativeModules.RNSelectSiteManager
// RNUpgrade 类名
// getVersion 获取原生的 版本号 返回”1.0.0“
// getNewVersion 获取最新的版本更新内容
const { getVersion, getNewVersion }
= NativeModules.RNUpgrade
const { getUUID,sendLog,clearLogin,reloadRNView }
= NativeModules.AuthToken
import {iconAll} from './allIcon'
import {authentication} from '@static/firstpage'
const { pushAuthenticationVC } =
NativeModules.RNUserAuthenticationManager
import {userTrackEvnet,openPage}
from '@utils/evnetTractUtil'
const {
openPageEnvent
} = NativeModules.ZTOBuryingModules
import {RNUpgradeApp} from '@utils/request'
import {clickDebounce} from '@utils/debounce'
import { CToast } from "../../filters/common";
setCustomText()
let waybillModel = {}
let currentAcctIndex = null
let cid = 'bd652627f3bafe1e'
let notifyId = null
let l3 = null
// let l1 = null
const Firstpage = (props) => {
//首页指标对象
const [targetList, settargetList] = useState({});
// 派件中心对象
const [dispatch, setDispatch] = useState({})
//订单中心对象
const [order, setOrder] = useState({})
// 运单跳转
const [isContainAcct, setisContainAcct]
= useState(null)
const [userAcct, setuserAcct] = useState(null)
//操作区域数组
const [sloganList, setSloganList] = useState([
{ label: '1', value: '降低社会物流成本、推进国家能力建设' },
{ label: '2', value: '以质量求生存,以信誉促发展' },
{ label: '3', value: '追求客户满意,是你我的责任' },
])
// 常用应用数组
const [applicationList, setapplicationList]
= useState([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])
const [dispatchDataLoading, setDispatchDataLoading]
= useState(false)
const [orderLoading, setOrderDataLoading]
= useState(false)
let keysService = false;
let dataService = false;
let targetListService = false;
let dispatchDataService = false;
let versionService = 0;
let authCheckService = 0;
useEffect(() => {
getAllApiData();
openPageEnvent({
param: '',
pageId:'P102',
pageUrl: globalThis.homeUrl || '',
pageTag:'P102',
moduleName:'Firstpage',
rn_version: RNUpgradeApp
})
notifyId = ZNotify.add('portletConfigNotice',
(data) => { if (data.isFlag) {
if (data?.loadKeys) {
getKeys() //从内存拉取图标顺序
} else {
getAllApiData()
props.Fun()
}
}})
// l3 = ZNotify.add('ZNotifyRemove',
(data)=>{if (data.isRemove) { allRemove() }})
//获取到网点信息
getSiteInfo((data) => {
var str = data.userAcct.length != 0
? data.userAcct : ''
setuserAcct(str)
ZStore.get("WayBillData", (data) => {
var pData = typeof data == 'object' ?
data : JSON.parse(data)
if (pData) {
var acct = userAcct
var arr = [];
pData.map((item, index) => {
var itemUserAcct =
item.userAcct == undefined ?
JSON.parse(item).userAcct : item.userAcct
if (itemUserAcct == acct) {
setisContainAcct(true)
currentAcctIndex = index
var pitem = typeof item == 'object' ?
item : JSON.parse(item)
var order = typeof
pitem.orderlistData == 'object' ?
pitem.orderlistData : JSON.parse(pitem.orderlistData)
if (order) {
order.map((item2) => {
var item1 = typeof
item2 == 'object' ?
item2 : JSON.parse(item2)
arr.unshift(item1)
})
}
}
});
}
});
})
return () => {
allRemove()
}
}, [])
//排查问题 开始时间 结束时间 路径 入参 返回值
const getWenti = (stateTime,endTime,
url,params,messge) =>{
getUUID(async(uuid) =>{
if (Platform.OS === "android"&&uuid === cid) {
let token = await getTokens()
let headers =`headers={'Content-Type':
'application/x-www-form-urlencoded;charset=utf-8',
"Authorization": bearer ${token},
"x-data-tunnel": 2,"x-forward": "operate"}`
let rnLog = `开始时间=${stateTime}-uuid=${cid}-接口路径
=${url}-${headers}-入参=${params}-结束时间
=${endTime}-出参=${messge}`
sendLog({rnLog})
}
})
}
//图标排序查询
const getKeys = ()=>{
ZStore.get("portletConfiglist",(data)=>{
if (data?.list) {
let res = JSON.parse(data.list)
setapplicationList(res)
}
})
}
//获取首页指标数据
const getTargetList = () => {
homeMetrics().then((res) => {
if (res.success) {
settargetList(res.result)
} else {
CToast(res.message.replace(/\r\n/g, ""))
}
});
}
//获取派件中心统计数据
const getDispatchData = async () =>{
let stateTime = dateTime();
let endTime = null;let res = null
let params = {beginDate:diffDate(2)+' 00:00:00',
endDate:diffDate(0)+' 23:59:59', recentlyDay: 3}
setTimeout(() => {
if (!res||!(res.success)) {
getWenti(stateTime,endTime,
'/api/scan/countDispatchCenter',
JSON.stringify(params),JSON.stringify(res))
}
}, 10000);
setDispatchDataLoading(true)
countDispatchCenter(params).then((res) => {
setDispatchDataLoading(false)
endTime = dateTime()
if (res.success) {
setDispatch(res.result)
} else {
CToast(res.message.replace(/\r\n/g, ""))
}
})
}
//获取订单中心统计数据
const getData = async () =>{
let stateTime = dateTime();
let endTime = null;let res = null
let params = {bgnDate:diffDate(2),
endDate:diffDate(0), status: 1}
setTimeout(() => {
if (!res||!(res.success)) {
getWenti(stateTime,endTime,
'/api/order/count',JSON.stringify(params),
JSON.stringify(res))
}
}, 5000);
setOrderDataLoading(true)
queryOrderCount(params).then((res) => {
setOrderDataLoading(false)
endTime = dateTime()
if (res.success) {
setOrder(res.result)
} else {
CToast(res.message.replace(/\r\n/g, ""))
}
})
}
const resetServiceState = () => {
keysService = false;
dataService = false;
targetListService = false;
dispatchDataService = false;
versionService = 0;
authCheckService = 0;
}
const serviceSuccess = () => {
if (!keysService || !dataService ||
!targetListService || !dispatchDataService
|| versionService === 0 ||
authCheckService === 0) {
return
}
toast.hide()
if (versionService === 1) {
if (authCheckService === 1) {
setisShowModal(false)
} else {
setisShowModal(true)
}
}
}
//获取首页所有数据
const getAllApiData = async (isShow) =>{
getKeys() //从内存拉取图标顺序
if (!isShow) {
getData()
getTargetList()
getDispatchData()
}
}
// 清除通知
const allRemove = () =>{
// l1&&l1.remove()
l3&&l3.remove()
notifyId&&notifyId.remove()
}
//判断版本更新是否弹窗
const getyVersion = () =>{
getVersion(async(args) => {
let params = {
versionValue:args,
appId:Platform.OS ===
'ios'?'com.zto56.sitethrough':'com.zto56.siteflow'
}
let res = await appUpgrade(params)
versionService = 3;
if (res.success) {
if (res.result?.forceUpgrade == 1) {
versionService = 2;
getNewVersion({show:0})//判断版本提示强更
}else{
versionService = 1;
getRnToUpdate() //判断RN是否需要更新
}
}
serviceSuccess()
})
}
// rn检查版本更新
getRnToUpdate = async() =>{
let res = await appUpgrade({appId:"ztokyoperate",
versionValue:RNUpgradeApp})
if (res.success) {
if (res.result?.forceUpgrade == 1) {
userTrackEvnet('need_update_rn',
{rn_version:RNUpgradeApp})
reloadRNView()
}
}
}



Disclaimer: The above articles are added by users themselves and are only for typing and communication purposes. They do not represent the views of this website, and this website does not assume any legal responsibility. This statement is hereby made! If there is any infringement of your rights, please contact us promptly to delete it.

字符:    改为:
去打字就可以设置个性皮肤啦!(O ^ ~ ^ O)