Переглянути джерело

语音播报/人员签到功能模块完成

fanghuisheng 1 рік тому
батько
коміт
7d11269dec

+ 18 - 0
src/api/business/zhaf/signIn.js

@@ -0,0 +1,18 @@
+import { request } from "@/utils/request";
+
+// 人员签到、签退
+export function add(param) {
+    return request({
+        url: "/service-fire/patrolInspectionAttendance/add",
+        method: "POST",
+        data: param,
+    });
+}
+
+// 人员状态查询
+export function getStatus() {
+    return request({
+        url: "/service-fire/patrolInspectionPersonnel/getStatus",
+        method: "GET",
+    });
+}

+ 91 - 0
src/components/oa-ttsAudio/ttsAudio.js

@@ -0,0 +1,91 @@
+// 这个东西我都没执行yarn add crypto竟然能用,可能另一个项目安装了全局共享了,如报错找不到,执行一下yarn add crypto
+import crypto from 'crypto'
+
+export class AccessToken {
+    static encodeText(text) {
+        let encodedText = encodeURIComponent(text);
+        return encodedText.replace('+', '%20').replace('*', '%2A').replace('~', '%7E');
+    }
+
+    static encodeDict(dict) {
+        let keys = Object.keys(dict).sort();
+        return keys.map(key => `${this.encodeText(key)}=${this.encodeText(dict[key])}`).join('&');
+    }
+
+    static async createToken(accessKeyId, accessKeySecret) {
+        const parameters = {
+            AccessKeyId: accessKeyId,
+            Action: 'CreateToken',
+            Format: 'JSON',
+            RegionId: 'cn-shanghai',
+            SignatureMethod: 'HMAC-SHA1',
+            SignatureNonce: uuidv4(),
+            SignatureVersion: '1.0',
+            Timestamp: new Date().toISOString(),
+            Version: '2019-02-28'
+        };
+
+        const queryString = this.encodeDict(parameters);
+        console.log('Normalized request string:', queryString);
+
+        const stringToSign = `GET&${this.encodeText('/')}&${this.encodeText(queryString)}`;
+        console.log('String to sign:', stringToSign);
+
+        const hmac = crypto.createHmac('sha1', `${accessKeySecret}&`);
+        hmac.update(stringToSign);
+        const signature = hmac.digest('base64');
+        console.log('Signature:', signature);
+
+        const encodedSignature = this.encodeText(signature);
+        console.log('URL-encoded signature:', encodedSignature);
+
+        const fullUrl = `https://nls-meta.cn-shanghai.aliyuncs.com/?Signature=${encodedSignature}&${queryString}`;
+        console.log('URL:', fullUrl);
+
+        let resData =  await new Promise((resolve, reject) => {
+            uni.request({
+                url: fullUrl,
+                method: 'GET',
+                success: res => {
+                    const data = res.data
+                    resolve({
+                        token: data.Token.Id,
+                        expireTime: data.Token.ExpireTime
+                    })
+                },
+                fail: error => {
+                    console.log(error)
+                    reject(error)
+                }
+            })
+        })
+         console.log('res',resData)
+         if(resData){
+            return resData
+         }
+        // Using fetch for HTTP request
+        // const response = await fetch(fullUrl);
+        // if (response.ok) {
+        //     const jsonResponse = await response.json();
+        //     if (jsonResponse.Token) {
+        //         return {
+        //             token: jsonResponse.Token.Id,
+        //             expireTime: jsonResponse.Token.ExpireTime
+        //         };
+        //     }
+        // }
+        // console.error(await response.text());
+        return {
+            token: null,
+            expireTime: null
+        };
+    }
+}
+
+// Sample UUIDv4 function, or you could use a library like `uuid`
+function uuidv4() {
+    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
+        var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
+        return v.toString(16);
+    });
+}

+ 1 - 1
src/config.js

@@ -1,7 +1,7 @@
 // 应用全局配置
 export default {
   //#ifdef APP-PLUS || MP-WEIXIN
-  baseUrl: "http://manager.usky.cn/prod-api",
+  baseUrl: "https://gateway.usky.cn/prod-api",
   //#endif
 
   //#ifdef H5

+ 2 - 2
src/manifest.json

@@ -2,8 +2,8 @@
     "name" : "综合智慧云",
     "appid" : "__UNI__36DE3A0",
     "description" : "综合智慧云app,助力企业数字化转型升级",
-    "versionName" : "2.1.2",
-    "versionCode" : 11,
+    "versionName" : "2.1.3",
+    "versionCode" : 12,
     "transformPx" : false,
     /* 5+App特有相关 */
     "app-plus" : {

+ 10 - 1
src/pages.json

@@ -387,8 +387,17 @@
               }
             }
           }
-        }
+        },
         //巡检模块 结束
+        //人员签到 开始
+        {
+          "path": "signIn/index",
+          "style": {
+            "navigationBarTitleText": "人员签到",
+            "enablePullDownRefresh": false
+          }
+        }
+        //人员签到 签退
       ]
     },
     // 智慧安防

+ 3 - 3
src/pages/business/mhxf/unitInfoCollection/index.vue

@@ -8,7 +8,7 @@
       <view class="centerOne" v-if="pagingBool">
         <view class="title"> 单位基本信息(1/2) </view>
 
-        <u--form :model="form" ref="uForm" :rules="rules" labelWidth="130">
+        <u--form ref="uForm" :model="form" :rules="rules" labelWidth="130">
           <view style="padding: 10px 0">
             <view style="padding: 10px 10px 20px 10px; background: #ffffff">
               <view style="padding-left: 9px">
@@ -1091,8 +1091,8 @@ function selectAction(e) {
     form.value.baseBuildList.forEach((el, index) => {
       rules.value.baseBuildList.push(JSON.parse(JSON.stringify(baseBuildListRules.value)));
 
-      el.baseBuild.fireFacilitySystem = el.baseBuild.fireFacilitySystem ? el.baseBuild.fireFacilitySystem.split(",").map((num) => Number(num)) : [];
-      el.baseBuild.otherSystem = el.baseBuild.otherSystem ? el.baseBuild.otherSystem.split(",").map((num) => Number(num)) : [];
+      el.baseBuild.fireFacilitySystem = el.baseBuild.fireFacilitySystem.length > 0 ? el.baseBuild.fireFacilitySystem.split(",").map((num) => Number(num)) : [];
+      el.baseBuild.otherSystem = el.baseBuild.otherSystem.length > 0 ? el.baseBuild.otherSystem.split(",").map((num) => Number(num)) : [];
 
       //建筑结构
       buildStructureList.value[0].forEach((e) => {

+ 156 - 0
src/pages/business/zhaf/signIn/index.vue

@@ -0,0 +1,156 @@
+<template>
+  <oa-scroll
+    customClass="scroll-height"
+    :refresherLoad="false"
+    :refresherEnabled="false"
+    :refresherDefaultStyle="'none'"
+    :refresherThreshold="44"
+    :refresherBackground="'#f5f6f7'"
+    :data-theme="'theme-' + proxy.$settingStore.themeColor.name"
+  >
+    <template #default>
+      <view class="signIn">
+        <view
+          class="signIn-button round mb30"
+          :class="`bg-${themeColor.name}`"
+          :style="{
+            background: state.signInType === 0 ? themeColor.color : '#999999',
+          }"
+          @click="handleInsert()"
+        >
+          <view class="pt40 font40">{{ state.signInType === 0 ? "签到" : "签退" }}</view>
+          <view class="mt5">{{ state.operateDate.split(" ")[1] }}</view>
+        </view>
+        <view class="signIn-address" v-if="state.address">
+          <view class="iconfont ucicon-address icon mt2" :class="`text-${themeColor.name}`"></view>
+          <view class="ml5">{{ state.address }}</view>
+        </view>
+      </view>
+    </template>
+  </oa-scroll>
+</template>
+
+<script setup>
+import { onLoad, onShow, onHide, onLaunch, onUnload } from "@dcloudio/uni-app";
+import { ref, reactive, computed, onMounted, getCurrentInstance, toRefs, inject } from "vue";
+import { useStores, commonStores } from "@/store/modules/index";
+import { add, getStatus } from "@/api/business/zhaf/signIn.js";
+
+const commonStore = commonStores();
+const { proxy } = getCurrentInstance();
+
+const themeColor = computed(() => {
+  return proxy.$settingStore.themeColor;
+});
+
+const state = reactive({
+  address: "", //准确位置信息
+  deviceCode: uni.getSystemInfoSync().deviceId, //设备编号
+  signInType: 0, //签到类型(0:已签到 1:已签退)
+  operateDate: commonStore.formatterDateTime(new Date()), //操作时间
+  operateCode: 0, //操作类型
+  longitude: "", //经度
+  latitude: "", //纬度
+  remarks: "", //备注
+});
+const inter = reactive({
+  interLocation: null,
+  interOperateDate: null,
+});
+
+function handleInsert() {
+  add({
+    deviceCode: state.deviceCode,
+    signInType: state.signInType === 0 ? 1 : 0,
+    operateCode: state.operateCode,
+    longitude: state.longitude,
+    latitude: state.latitude,
+    remarks: state.remarks,
+  }).then((res) => {
+    if (res.status == "SUCCESS") {
+      proxy.$modal.msgSuccess(state.signInType === 0 ? "签到成功" : "签退成功");
+      getStatusApi(); //调用人员状态查询接口
+    }
+  });
+}
+
+/**
+ * @人员状态查询
+ * @接口查询
+ */
+function getStatusApi() {
+  getStatus().then((res) => {
+    if (res.status == "SUCCESS") {
+      state.signInType = res.data.operateType;
+    }
+  });
+}
+
+function getLocation() {
+  uni.getLocation({
+    type: "gcj02",
+    geocode: true,
+    highAccuracyExpireTime: 5000,
+    success: function (res) {
+      console.log(res);
+      state.longitude = res.longitude;
+      state.latitude = res.latitude;
+      state.address = res.address.city + res.address.district + res.address.street + res.address.streetNum + res.address.poiName;
+    },
+    fail: function (res) {
+      uni.showToast({
+        title: "请打开手机定位或相关应用权限定位!",
+        icon: "none",
+      });
+    },
+  });
+}
+
+onLoad(() => {
+  getStatusApi(); //调用人员状态查询接口
+
+  //#ifdef APP-PLUS
+  getLocation();
+  inter.interLocation = setInterval(() => {
+    getLocation();
+  }, 1000 * 10);
+  //#endif
+  inter.interOperateDate = setInterval(() => {
+    state.operateDate = commonStore.formatterDateTime(new Date());
+  }, 1000);
+});
+
+onUnload(() => {
+  //#ifdef APP-PLUS
+  clearInterval(inter.interLocation); //销毁之前定时器
+  //#endif
+  clearInterval(inter.interOperateDate); //销毁之前定时器
+});
+
+onShow(() => {
+  //调用系统主题颜色
+  proxy.$settingStore.systemThemeColor([1]);
+});
+</script>
+
+<style lang="scss">
+.signIn {
+  padding-top: 45%;
+  //#ifdef MP-WEIXIN
+  padding-top: 45%;
+  //#endif
+
+  &-button {
+    width: 135px;
+    height: 135px;
+    text-align: center;
+    margin: auto;
+  }
+
+  &-address {
+    display: flex;
+    justify-content: center;
+    margin: auto;
+  }
+}
+</style>

+ 1 - 1
src/uni_modules/uview-plus/components/u-form-item/u-form-item.vue

@@ -152,7 +152,7 @@
 			},
 			// 点击组件
 			clickHandler() {
-				//this.$emit('click')
+				this.$emit('click')
 			}
 		},
 	}

+ 1 - 7
vite.config.js

@@ -15,18 +15,12 @@ export default defineConfig(({ mode, command }) => {
           target: "http://172.16.120.165:13200",
           ws: true,
           changeOrigin: true,
-          pathRewrite: {
-            "^/api": "",
-          },
           //rewrite: (p) => p.replace(/^\/dev-api/, '')
         },
         "/prod-api": {
-          target: "http://manager.usky.cn",
+          target: "https://gateway.usky.cn",
           ws: true,
           changeOrigin: true,
-          pathRewrite: {
-            "^/api": "",
-          },
           //rewrite: (p) => p.replace(/^\/dev-api/, '')
         },
       },