chenyao
2025-10-16 8e04df4a9b64199a84bcae5b7c5b3bebf34a5390
Merge remote-tracking branch 'origin/master'
8 files modified
366 ■■■■ changed files
src/components/WebViewPlus.vue 6 ●●●●● patch | view | raw | blame | history
src/pages/inspectionTask/DroneConsole/DroneConsole.vue 11 ●●●● patch | view | raw | blame | history
src/pages/inspectionTask/TaskDetails/TaskDetails.vue 18 ●●●●● patch | view | raw | blame | history
src/pages/inspectionTask/index.vue 2 ●●● patch | view | raw | blame | history
src/pages/login/index.vue 59 ●●●●● patch | view | raw | blame | history
src/pages/map/index.vue 65 ●●●● patch | view | raw | blame | history
src/pages/work/index.vue 179 ●●●●● patch | view | raw | blame | history
src/utils/common/index.js 26 ●●●●● patch | view | raw | blame | history
src/components/WebViewPlus.vue
@@ -9,8 +9,10 @@
function viewMessage(event) {
  messageFun({
    data: {data: {arg: event.detail.data[0]}},
    type: 'WEB_INVOKE_APPSERVICE'
    data: {
      data: {arg: event.detail.data[0]},
      type: 'WEB_INVOKE_APPSERVICE'
    },
  })
}
// WEB_INVOKE_APPSERVICE
src/pages/inspectionTask/DroneConsole/DroneConsole.vue
@@ -2,16 +2,21 @@
  <WebViewPlus :src="`${viewUrl}`" @webMessage="onPostMessage"/>
</template>
<script setup>
import {onHide, onShow} from "@dcloudio/uni-app";
import {onHide, onLoad, onShow} from "@dcloudio/uni-app";
import WebViewPlus from "@/components/WebViewPlus.vue";
import {getWebViewUrl} from "@/utils/index.js";
const viewUrl = getWebViewUrl('/DroneConsole', {wayLineJodInfoId: 6120})
const viewUrl = ref('')
const wayLineJodInfoId = ref(null)
function onPostMessage(event) {
}
onLoad((options) => {
  wayLineJodInfoId.value = options.wayLineJodInfoId
  viewUrl.value = getWebViewUrl('/DroneConsole', {wayLineJodInfoId: wayLineJodInfoId.value})
})
// onShow(() => {
//   // #ifdef APP-PLUS
src/pages/inspectionTask/TaskDetails/TaskDetails.vue
@@ -3,25 +3,29 @@
</template>
<script setup>
import {useUserStore} from "@/store/index.js";
import WebViewPlus from "@/components/WebViewPlus.vue";
import {getWebViewUrl} from "@/utils/index.js";
import {onLoad} from "@dcloudio/uni-app";
const userStore = useUserStore()
const viewUrl = getWebViewUrl('/TaskInProgress', {wayLineJodInfoId: 6120})
const wayLineJodInfoId = ref(null)
const viewUrl = ref('')
function onPostMessage(data) {
  if (data.type === 'back'){
  if (data.type === 'back') {
    uni.switchTab({
      url: '/pages/inspectionTask/index'
    });
  }else if(data.type === 'control'){
  } else if (data.type === 'control') {
    uni.redirectTo({
      url: '/pages/inspectionTask/DroneConsole/DroneConsole'
      url: `/pages/inspectionTask/DroneConsole/DroneConsole?wayLineJodInfoId=${wayLineJodInfoId.value}`
    });
  }
}
onLoad((options) => {
  wayLineJodInfoId.value = options.wayLineJodInfoId
  viewUrl.value = getWebViewUrl('/TaskInProgress', {wayLineJodInfoId: wayLineJodInfoId.value})
})
</script>
<style scoped lang="scss">
src/pages/inspectionTask/index.vue
@@ -13,7 +13,7 @@
  if (data.type === 'taskDetails'){
    if ([1,2].includes(data.rowItem.status)){
      uni.navigateTo({
        url: '/pages/inspectionTask/TaskDetails/TaskDetails'
        url: `/pages/inspectionTask/TaskDetails/TaskDetails?wayLineJodInfoId=${data.rowItem.id}`
      });
    }else{
      uni.navigateTo({
src/pages/login/index.vue
@@ -3,28 +3,35 @@
  <view>
    <view class="login-form-wrap">
      <view class="title"> 掌控智飞</view>
      <input v-model="loginForm.username" class="u-border-bottom" placeholder="请输入用户名"/>
      <input v-model="loginForm.password" class="u-border-bottom" type="password" placeholder="请输入密码"/>
      <input
        v-model="loginForm.username"
        class="u-border-bottom"
        placeholder="请输入用户名"
      />
      <input
        v-model="loginForm.password"
        class="u-border-bottom"
        type="password"
        placeholder="请输入密码"
      />
      <button class="login-btn" :style="[inputStyle]" @tap="submit">
        登录
        <text class="i-mdi-login"/>
        <text class="i-mdi-login" />
      </button>
    </view>
  </view>
</template>
<script setup>
import md5 from 'js-md5'
import {loginByUsername} from '@/api/user/index.js'
import {useUserStore} from "@/store/index.js";
import {
  HOME_PATH, LOGIN_PATH, removeQueryString,
} from "@/router";
import md5 from "js-md5";
import { loginByUsername } from "@/api/user/index.js";
import { useUserStore } from "@/store/index.js";
import { HOME_PATH, LOGIN_PATH, removeQueryString } from "@/router";
const userStore = useUserStore();
const loginForm = ref({
  username: "zhx",
  password: "123456"
})
  username: "shuishen",
  password: "Dashabi....",
});
const inputStyle = computed(() => {
  const style = {};
  if (loginForm.value.username && loginForm.value.password) {
@@ -37,15 +44,15 @@
async function submit() {
  let userInfo = {
    "tenantId": "000000",
    "deptId": "",
    "roleId": "",
    "username": loginForm.value.username,
    "password": loginForm.value.password,
    "type": "account",
    "code": "",
    "key": "",
  }
    tenantId: "000000",
    deptId: "",
    roleId: "",
    username: loginForm.value.username,
    password: loginForm.value.password,
    type: "account",
    code: "",
    key: "",
  };
  loginByUsername(
    userInfo.tenantId,
    userInfo.deptId,
@@ -55,12 +62,12 @@
    userInfo.type,
    userInfo.key,
    userInfo.code
  ).then(res => {
    userStore.setUserInfo(res.data)
  ).then((res) => {
    userStore.setUserInfo(res.data);
    uni.switchTab({
      url: '/pages/user/index'
    })
  })
      url: "/pages/user/index",
    });
  });
}
onLoad((options) => {
src/pages/map/index.vue
@@ -1,66 +1,31 @@
<!--
 * @Author       : yuan
 * @Date         : 2025-10-14 17:40:58
 * @LastEditors  : yuan
 * @LastEditTime : 2025-10-15 15:54:25
 * @FilePath     : \src\pages\map\index.vue
 * @Description  :
 * Copyright 2025 OBKoro1, All Rights Reserved.
 * 2025-10-14 17:40:58
-->
<template>
  <view class="page-wrap">
    <web-view
      ref="sWebViewRef"
      :src="`${viewUrl}`"
      @message="onPostMessage"
      @onPostMessage="onPostMessage"
    />
    <WebViewPlus :src="`${viewUrl}`" @webMessage="onPostMessage" />
  </view>
</template>
<script setup>
import { useUserStore } from "@/store/index.js";
import WebViewPlus from "@/components/WebViewPlus.vue";
const sWebViewRef = ref(null);
const userStore = useUserStore();
const viewUrl = `https://192.168.1.194:5174/drone-app-web-view/#/webViewWrapper/defaultMap?params=${JSON.stringify(
const viewUrl = `http://192.168.1.194:5174/drone-app-web-view/#/webViewWrapper/defaultMap?params=${JSON.stringify(
  userStore?.userInfo
)}`;
const onPostMessage = (event) => {
  // #ifdef APP-PLUS
  if (event.detail.data[0].type === "scanCode") {
    scanCode();
  }
  // #endif
};
const onPostMessage = (event) => {};
const scanCode = () => {
  // 只允许通过相机扫码
  uni.scanCode({
    onlyFromCamera: true,
    success: function (res) {
      console.log("条码类型:" + res.scanType);
      console.log("条码内容:" + res.result);
      // 获取扫码结果
      let url = res.result;
      // 跳转到B页面,并传递URL参数
      uni.navigateTo({
        url: "/subPackages/browser/index?url=" + encodeURIComponent(url),
      });
    },
    fail: function (err) {
      console.log("扫码失败:", err);
      uni.showToast({
        title: "扫码失败",
        icon: "none",
      });
    },
  });
};
onLoad(() => {
  // #ifdef H5
  window.addEventListener("message", function (e) {
    if (e.data.data.type === "scanCode") {
      scanCode();
    }
  });
  // #endif
});
onLoad(() => {});
</script>
<style scoped lang="scss">
src/pages/work/index.vue
@@ -30,189 +30,12 @@
<script setup>
    import {getWebViewUrl} from "@/utils/index.js";
import { useUserStore } from '@/store/index.js'
import {getList,getstatusCount} from '/src/api/work/index.js'
    import dayjs from 'dayjs';
    const userStore = useUserStore()
    const userInfo = userStore.userInfo
const sWebViewRef = ref(null);
const viewUrl = getWebViewUrl('/work', {})
// const viewUrl = `http://192.168.1.157:5173/drone-app-web-view/#/webViewWrapper/work?params=${JSON.stringify(userStore?.userInfo)}`;
    const dataList = ref([])
    const keyword = ref('')
    const currentTab=ref('myTickets')
    const tabList = ref([{
            name: '我的工单',
            key: 'myTickets',
            badge: {
                value: 1
            }
        },
        {
            name: '全部状态',
            key: 'all',
            badge: {
                value: 2
            },
            status: null
        },
        {
            name: '待审核',
            key: 'pending',
            badge: {
                value: 3
            },
            status: '2'
        },
        {
            name: '待处理',
            key: 'processing',
            badge: {
                value: 4
            },
            status: '0'
        },
        {
            name: '处理中',
            key: 'inProgress',
            badge: {
                value: 5
            },
            status: '3'
        },
        {
            name: '已完成',
            key: 'completed',
            badge: {
                value: 6
            },
            status: '4'
        }
    ])
    const formatDate = (dateString) => {
        return dayjs(dateString).format('MM/DD HH:mm');
    };
    const listParams = ref({
        status: null,
        current: 1,
        size: 9999,
        source: 1,
        department:'',
        keyword:''
    })
    const getDataList = () => {
        const params = {
            current: 1,
            size: 9999,
            source: 1,
            status:listParams.value.status,
            event_name:listParams.value.keyword,
            user_id:currentTab.value=== 'myTickets' ?userInfo.user_id : undefined
        }
        getList(params).then(res => {
            const response = res.data.data.records
            dataList.value = response
        })
    }
        const getstatusCountData=()=>{
            getstatusCount().then(res=>{
                const response = res.data.data
                 const { statusCount, totalCount, userCount } = response
                tabList.value.forEach(tab=>{
                    if(tab.key === 'all'){
                        tab.badge.value = totalCount || 0
                    }else if(tab.key === 'myTickets'){
                        tab.badge.value = userCount || 0
                    }else{
                        tab.badge.value=statusCount[String(tab.status)] || 0
                    }
                })
            })
        }
    const handleClick = (item) => {
        currentTab.value = item.key
    listParams.value.status = item.status
        getDataList()
    }
    const detailHandle = (val) => {
        uni.navigateTo({
            url: `/subPackages/workDetail/index?eventNum=${val.event_num}`,
        })
    }
    onShow(() => {
        getDataList()
        getstatusCountData()
    })
</script>
<style scoped lang="scss">
    .eventTickets {
        padding: 0 10px;
        .searchTop {
            display: flex;
            align-items: center;
            margin-top: 10px;
        }
        :deep(.u-badge) {
            background-color: #1d6fe9 !important;
        }
        .eventBox {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            padding: 10px 0;
            background-color: #ebeff2;
            .eventItem {
                width: calc(50% - 5px);
                background-color: #fff;
                border-radius: 5px;
                overflow: hidden;
                img {
                    width: 100%;
                    height: 100px;
                    border-radius: 5px;
                    overflow: hidden;
                }
                .itemTitle {
                    padding: 0 5px;
                     white-space: nowrap;
                    overflow: hidden;
                    text-overflow: ellipsis;
                }
                .itemContent {
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                    padding: 5px;
                    .itemStatus {
                        display: flex;
                        align-items: center;
                        span {
                            display: inline-block;
                            width: 10px;
                            height: 10px;
                            border-radius: 50%;
                            margin-right: 5px;
                        }
                    }
                }
            }
        }
    }
</style>
src/utils/common/index.js
@@ -29,18 +29,22 @@
  })
}
export function getWebViewUrl(targetUrl,otherParams){
  const userStore = useUserStore()
  const url = import.meta.env.VITE_APP_WEBVIEW_URL
  console.log(url,686)
  // 构建查询参数
  const params = new URLSearchParams()
  params.append('params', JSON.stringify(userStore?.userInfo))
  // 处理 otherParams 对象
export function getWebViewUrl(targetUrl, otherParams) {
  const userStore = useUserStore();
  const url = import.meta.env.VITE_APP_WEBVIEW_URL;
  // 1. 处理用户参数
  const userParams = userStore?.userInfo ? JSON.stringify(userStore.userInfo) : '{}';
  // 2. 构建查询参数字符串
  let queryString = `params=${encodeURIComponent(userParams)}`;
  // 3. 处理 otherParams 对象
  if (otherParams && typeof otherParams === 'object') {
    Object.keys(otherParams).forEach(key => {
      params.append(key, otherParams[key])
    })
      const value = otherParams[key];
      if (value !== undefined && value !== null) {
        queryString += `&${key}=${encodeURIComponent(value)}`;
      }
    });
  }
  return `${url}${targetUrl}?${params.toString()}`
  // 4. 拼接完整 URL
  return `${url}${targetUrl}?${queryString}`;
}