Commit ee0ed2ee7057b064b8cb22835473943c11280114

Authored by tianwu
1 parent 660378cc

positionsUploadInit 方法报错处理,暂未解决报错 等我空了修复

project-wl-kuaidiyuan-uniapp-vue3/pages/index/components/orderInfo.vue
... ... @@ -27,6 +27,9 @@ const props = defineProps({
27 27 default: () => ({}),
28 28 },
29 29 });
  30 +
  31 +
  32 +
30 33 // ------定义方法------
31 34 // 进入 待取件列表页
32 35 const handlePicup = () => {
... ...
project-wl-kuaidiyuan-uniapp-vue3/pages/index/index.vue
... ... @@ -62,9 +62,10 @@ const noPickupTaskList = reactive([]); //取件列表数据
62 62 const noDispatchTaskList = reactive([]); //派件列表数据
63 63 const locationData = ref({});
64 64 let baseData = ref({});
  65 +console.log(users.loacation)
65 66 let page = reactive({
66   - latitude: users.loacation.latitude !== undefined ? users.loacation.latitude : 40.062595,
67   - longitude: users.loacation.longitude !== undefined ? users.loacation.longitude : 116.372809,
  67 + latitude: users.loacation.latitude ? users.loacation.latitude : 40.062595,
  68 + longitude: users.loacation.longitude ? users.loacation.longitude : 116.372809,
68 69 page: 1,
69 70 pageSize: 10,
70 71 dateTime: getTimeDate(new Date()).veryDayDate,
... ... @@ -105,8 +106,8 @@ const getList = async () => {
105 106 // 获取相关任务、取件、派件、今日已取、已签
106 107 const getHomeBase = async () => {
107 108 const locition = {
108   - longitude: 116.344015,
109   - latitude: 40.060607
  109 + longitude: page.longitude,
  110 + latitude: page.latitude
110 111 };
111 112 await getHomeData(locition).then(res => {
112 113 if (res.code === 200) {
... ...
project-wl-kuaidiyuan-uniapp-vue3/utils/index.js
... ... @@ -181,30 +181,34 @@ let getAuth = null
181 181  
182 182 // 初始上报位置
183 183 export const positionsUploadInit = () => {
184   - // 获取用户的定位配置
185   - let appAuthorizeSetting = uni.getAppAuthorizeSetting().locationAuthorized
186   - // 清除 定位检查的定时器
187   - getAuth != null ? clearInterval(getAuth) : null
188   - // 如果用户拒绝使用定位 提示无法上报位置
189   - if (appAuthorizeSetting == 'denied'){
190   - uni.showToast({
191   - title: '您拒绝提供定位服务,系统将无法使用位置上报功能',
192   - duration: 3000,
193   - icon: 'none'
194   - });
195   - return false
196   - }
197   - //如果没有开启定位 持续检查 直到开启定位
198   - if(appAuthorizeSetting != 'authorized' && appAuthorizeSetting != 'denied'){
199   - getAuth = setInterval(() => {
200   - positionsUploadInit()
201   - }, 30000)
202   - return false
203   - }
204   - const posit = uni.getStorageSync('positions')
205   - // 位置上报
206   - if (!posit){
207   - positionUploadHandle()
  184 + try {
  185 + // 获取用户的定位配置
  186 + let appAuthorizeSetting = uni.getAppAuthorizeSetting().locationAuthorized
  187 + // 清除 定位检查的定时器
  188 + getAuth != null ? clearInterval(getAuth) : null
  189 + // 如果用户拒绝使用定位 提示无法上报位置
  190 + if (appAuthorizeSetting == 'denied'){
  191 + uni.showToast({
  192 + title: '您拒绝提供定位服务,系统将无法使用位置上报功能',
  193 + duration: 3000,
  194 + icon: 'none'
  195 + });
  196 + return false
  197 + }
  198 + //如果没有开启定位 持续检查 直到开启定位
  199 + if(appAuthorizeSetting != 'authorized' && appAuthorizeSetting != 'denied'){
  200 + getAuth = setInterval(() => {
  201 + positionsUploadInit()
  202 + }, 30000)
  203 + return false
  204 + }
  205 + const posit = uni.getStorageSync('positions')
  206 + // 位置上报
  207 + if (!posit){
  208 + positionUploadHandle()
  209 + }
  210 + } catch(e) {
  211 + console.error(e)
208 212 }
209 213 }
210 214 /**
... ...