浏览代码

NFC巡检模块完成1.0

fanghuisheng 1 年之前
父节点
当前提交
bea995b7a2

+ 149 - 0
src/components/oa-movable/index.vue

@@ -0,0 +1,149 @@
+<template>
+  <movable-area class="fixed-box">
+    <movable-view class="fixed-button" direction="all" :inertia="true" y="100px">
+      <view class="menuBox">
+        <view class="mainMenu iconfont ucicon-jiahao menu-icon" :style="{ background: themesColor }" @click="declick"></view>
+        <view class="posi" :animation="animationData">
+          <slot name="content"> </slot>
+        </view>
+      </view>
+    </movable-view>
+  </movable-area>
+</template>
+<script setup>
+import { onReady, onLoad, onShow, onNavigationBarButtonTap, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
+import { ref, onMounted, inject, shallowRef, reactive, getCurrentInstance, watchEffect, toRefs, toRef, watch } from "vue";
+
+const emit = defineEmits(["load", "refresh"]);
+const props = defineProps({
+  //主题颜色
+  themesColor: {
+    type: String,
+    default: "#3f99ff",
+  },
+});
+
+const defaultArray = reactive({
+  off: true,
+  animation: null,
+  animationData: {},
+});
+
+const { themesColor } = toRefs(props);
+const { off, animation, animationData } = toRefs(defaultArray);
+
+// 悬浮按钮
+function declick() {
+  if (off.value) {
+    //使用动画
+    rotateAndScale();
+  } else {
+    norotateAndScale();
+  }
+  off.value = !off.value;
+}
+
+//定义动画内容
+function rotateAndScale() {
+  animation.value.rotate(0).translateY(-1).step();
+  //导出动画数据传递给data层
+  animationData.value = animation.value.export();
+}
+
+//当!off的时候动画回到原始位置
+function norotateAndScale() {
+  animation.value.rotate(0).translateY(150).step();
+  animationData.value = animation.value.export();
+}
+
+onLoad((option) => {
+  animation.value = uni.createAnimation();
+});
+
+onShow(() => {
+  var animation1 = uni.createAnimation({
+    duration: 500,
+    trmingFunction: "ease",
+  });
+  animation.value = animation1;
+});
+</script>
+
+<style lang="scss" scoped>
+.fixed-box {
+  pointer-events: none;
+  width: 100vw;
+  height: 100vh;
+  position: fixed;
+  left: 0;
+  bottom: 0;
+  z-index: 100000;
+}
+
+.fixed-button {
+  right: 0;
+  top: 60vh;
+  left: auto;
+  width: 50px;
+  height: 150px;
+  display: flex;
+  padding: 5px 5px;
+  justify-content: center;
+  align-items: center;
+  pointer-events: auto;
+}
+
+.menuBox {
+  width: 100%;
+  height: 100%;
+  position: relative;
+  z-index: 1;
+  overflow: hidden;
+  border-radius: 25px;
+}
+
+.mainMenu {
+  width: 50px;
+  height: 50px;
+  position: absolute;
+  right: 0;
+  bottom: 0;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  border-radius: 100%;
+}
+
+:deep(.iconfont) {
+  color: #fff;
+  font-size: 28px;
+}
+
+.posi {
+  width: 50px;
+  position: relative;
+  z-index: -1;
+  transform: rotate(0deg) translateY(150px);
+  background-color: #fff;
+  border-radius: 50rpx;
+  padding-bottom: 50px;
+
+  :deep(.iconfont) {
+    width: 50px;
+    height: 50px;
+    font-size: 18px;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    color: #333333 !important;
+  }
+}
+
+/* 适配iphonex 有底部横条的 */
+@supports (bottom: constant(safe-area-inset-bottom)) or (bottom: env(safe-area-inset-bottom)) {
+  .fixed-box {
+    bottom: constant(safe-area-inset-bottom);
+    bottom: env(safe-area-inset-bottom);
+  }
+}
+</style>

+ 7 - 0
src/pages.json

@@ -184,6 +184,13 @@
             "navigationBarTitleText": "服务评价",
             "enablePullDownRefresh": false
           }
+        },
+        {
+          "path": "nfc/index",
+          "style": {
+            "navigationBarTitleText": "NFC读取",
+            "enablePullDownRefresh": false
+          }
         }
       ]
     },

+ 1 - 4
src/pages/business/mhxf/xunJian/collect/components/collectDetail.vue

@@ -68,10 +68,6 @@ function handleInsert() {
       model.siteTime = commonStore.formatterDate(endTime, "yyyy-MM-dd hh:mm:ss");
 
       xunJianStore.collectDataList.push(model);
-
-      //   uni.navigateTo({
-      //     url: "/pages/business/mhxf/xunJian/collect/index",
-      //   });
       uni.navigateBack({
         delta: 1, //返回到需要执行方法的页面
       });
@@ -82,6 +78,7 @@ function handleInsert() {
 }
 
 onLoad((options) => {
+  model.siteType = options.siteType;
   model.siteNubmber = options.siteNubmber;
 });
 

+ 33 - 8
src/pages/business/mhxf/xunJian/collect/index.vue

@@ -35,9 +35,12 @@
       </uni-swipe-action-item>
     </uni-swipe-action>
 
-    <view class="app-scan-fixed">
-      <u-image width="67" height="67" src="@/static/images/add.png" shape="circle" @click="scanClick()"></u-image>
-    </view>
+    <oaMovable :themesColor="proxy.$settingStore.themeColor.color">
+      <template #content>
+        <view class="iconfont ucicon-nfc menu-icon" @click="nfcClick()"></view>
+        <view class="iconfont ucicon-saoyisao menu-icon" @click="scanClick()"></view>
+      </template>
+    </oaMovable>
 
     <!-- 提示信息弹窗 -->
     <uni-popup ref="message" type="message">
@@ -56,14 +59,23 @@
 </template>
 
 <script setup>
-import { onReady, onLoad, onShow, onNavigationBarButtonTap } from "@dcloudio/uni-app";
-import { ref, onMounted, reactive, computed, getCurrentInstance, toRefs, inject, shallowRef } from "vue";
+import { onReady, onLoad, onShow, onUnload, onNavigationBarButtonTap } from "@dcloudio/uni-app";
+import { ref, onMounted, reactive, computed, getCurrentInstance, toRefs, inject, shallowRef, watch } from "vue";
 import { xunJianStores } from "@/store/modules/index";
-
 import { addSite } from "@/api/business/mhxf/xunJian/collect.js";
+import oaMovable from "@/components/oa-movable/index.vue"; // 引入组件
 
-const xunJianStore = xunJianStores(); //全局变量值Store
 const { proxy } = getCurrentInstance();
+const xunJianStore = xunJianStores(); //全局变量值Store
+
+/**
+ * @NFC
+ */
+function nfcClick() {
+  uni.navigateTo({
+    url: "/pages/common/nfc/index",
+  });
+}
 
 /**
  * @扫一扫
@@ -80,7 +92,7 @@ function scanClick() {
         icon: "none",
       });
       uni.navigateTo({
-        url: "/pages/business/mhxf/xunJian/collect/components/collectDetail?siteNubmber=" + e.result,
+        url: `/pages/business/mhxf/xunJian/collect/components/collectDetail?siteNubmber=${e.result}&siteType=${1}`,
       });
     },
     fail: (err) => {
@@ -192,6 +204,19 @@ onLoad((options) => {});
 onShow(() => {
   //调用系统主题颜色
   proxy.$settingStore.systemThemeColor([1]);
+
+  uni.$on("tagid", function (value) {
+    setTimeout(() => {
+      uni.navigateTo({
+        url: `/pages/business/mhxf/xunJian/collect/components/collectDetail?siteNubmber=${value}&siteType=${2}`,
+      });
+      uni.$off("tagid"); //将值删除监听器
+    }, 0);
+  });
+});
+
+onUnload(() => {
+  uni.$off("tagid"); //将值删除监听器
 });
 
 onReady(() => {});

+ 5 - 3
src/pages/business/mhxf/xunJian/plan/components/content.vue

@@ -61,10 +61,12 @@
         </view>
       </view>
     </view>
-    <view class="app-button-fixed">
-      <u-button class="app-buttom" v-if="xunJianStore.contentArray.siteList.inspectionStatus == 1" type="primary" shape="circle" @click="buttonClick(1)"> 上一步 </u-button>
+    <view class="app-button-fixed" v-if="xunJianStore.contentArray.siteList.inspectionStatus == 1">
+      <view class="app-flex">
+        <u-button class="app-buttom" style="margin-right: 15px" shape="circle" @click="buttonClick(1)"> 上一步 </u-button>
 
-      <u-button class="app-buttom" v-if="xunJianStore.contentArray.siteList.inspectionStatus == 1" type="primary" shape="circle" @click="buttonClick(2)"> 提交 </u-button>
+        <u-button class="app-buttom" type="primary" shape="circle" @click="buttonClick(2)"> 提交 </u-button>
+      </view>
     </view>
 
     <u-modal ref="uModal" :show="show" :title="title" :content="content" @confirm="confirm"></u-modal>

+ 1 - 1
src/pages/business/mhxf/xunJian/plan/components/drawer.vue

@@ -1,5 +1,5 @@
 <template>
-  <u-popup :show="scanBool" @close="close" @open="open" mode="bottom" :data-theme="'theme-' + proxy.$settingStore.themeColor.name">
+  <u-popup :show="scanBool" @close="close" @open="open" mode="bottom">
     <template #default>
       <view class="mb15 mt15">
         <h4 style="font-size: 16px; color: #149eff; text-align: center; margin-bottom: 10px">请选择计划</h4>

+ 59 - 30
src/pages/business/mhxf/xunJian/plan/components/report.vue

@@ -52,22 +52,25 @@
         </view>
       </view>
     </view>
-    <view class="app-scan-fixed">
-      <u-image width="67" height="67" src="@/static/images/add.png" shape="circle" @click="scanClick()"></u-image>
-    </view>
+
+    <oaMovable :themesColor="proxy.$settingStore.themeColor.color">
+      <template #content>
+        <view class="iconfont ucicon-nfc menu-icon" @click="nfcClick()"></view>
+        <view class="iconfont ucicon-saoyisao menu-icon" @click="scanClick()"></view>
+      </template>
+    </oaMovable>
   </scroll-view>
 </template>
 
 <script setup>
-import { onLoad, onShow } from "@dcloudio/uni-app";
+import { onLoad, onShow, onUnload } from "@dcloudio/uni-app";
 import { ref, onMounted, reactive, computed, getCurrentInstance, toRefs, inject, shallowRef } from "vue";
 import { useStores, commonStores, xunJianStores } from "@/store/modules/index";
-
 import { recordList, recordOption, siteDetails, planSonSiteDetails } from "@/api/business/mhxf/xunJian/plan.js";
-
-const xunJianStore = xunJianStores(); //全局变量值Store
+import oaMovable from "@/components/oa-movable/index.vue"; // 引入组件
 
 const { proxy } = getCurrentInstance();
+const xunJianStore = xunJianStores(); //全局变量值Store
 
 function pulicClick(obj) {
   if (obj.inspectionStatus == 2) {
@@ -106,12 +109,23 @@ function pulicClick(obj) {
     xunJianStore.siteId = obj.id;
     xunJianStore.siteNubmber = "";
 
-    uni.navigateTo({
-      url: "/pages/business/mhxf/xunJian/plan/components/siteDetails",
-    });
+    if (obj.siteType == 1) {
+      scanClick();
+    } else if (obj.siteType == 2) {
+      nfcClick();
+    }
   }
 }
 
+/**
+ * @NFC
+ */
+function nfcClick() {
+  uni.navigateTo({
+    url: "/pages/common/nfc/index",
+  });
+}
+
 /**
  * @扫一扫
  * @点击事件
@@ -127,26 +141,7 @@ async function scanClick() {
         icon: "none",
       });
 
-      xunJianStore.contentArray = {};
-      xunJianStore.siteId = "";
-      xunJianStore.siteNubmber = e.result;
-
-      siteDetails({
-        siteId: xunJianStore.siteId,
-        siteNubmber: xunJianStore.siteNubmber,
-        planSonId: xunJianStore.planSonId,
-      }).then((res) => {
-        if (res.status == "SUCCESS") {
-          currentDateList.value.forEach((e) => {
-            if (e.id == res.data.siteList[0].id) {
-              uni.navigateTo({
-                url: "/pages/business/mhxf/xunJian/plan/components/siteDetails",
-              });
-            }
-          });
-        } else {
-        }
-      });
+      siteDetailsApi(e.result);
     },
     fail: (err) => {
       uni.showToast({
@@ -161,6 +156,33 @@ async function scanClick() {
   });
 }
 
+/**
+ * @点位详情查询
+ * @接口请求
+ */
+function siteDetailsApi(value) {
+  xunJianStore.contentArray = {};
+  xunJianStore.siteId = "";
+  xunJianStore.siteNubmber = value;
+
+  siteDetails({
+    siteId: xunJianStore.siteId,
+    siteNubmber: xunJianStore.siteNubmber,
+    planSonId: xunJianStore.planSonId,
+  }).then((res) => {
+    if (res.status == "SUCCESS") {
+      currentDateList.value.forEach((res1) => {
+        if (res1.id == res.data.siteList[0].id) {
+          uni.navigateTo({
+            url: "/pages/business/mhxf/xunJian/plan/components/siteDetails",
+          });
+        }
+      });
+    } else {
+    }
+  });
+}
+
 /**
  * @地点列表
  * @api接口请求
@@ -190,6 +212,13 @@ onLoad((options) => {
 onShow(() => {
   //调用系统主题颜色
   proxy.$settingStore.systemThemeColor([1]);
+  uni.$on("tagid", function (value) {
+    siteDetailsApi(value);
+  });
+});
+
+onUnload(() => {
+  uni.$off("tagid"); //将值删除监听器
 });
 
 onMounted(() => {});

+ 54 - 30
src/pages/business/mhxf/xunJian/plan/index.vue

@@ -93,22 +93,24 @@
       <view id="planTimeline" style="text-align: center; color: #bdbdbd; font-size: 14px" v-else> 暂无数据 </view>
     </view>
 
-    <view class="app-scan-fixed">
-      <u-image width="67" height="67" src="@/static/images/add.png" shape="circle" @click="scanClick()"></u-image>
-    </view>
+    <oaMovable :themesColor="proxy.$settingStore.themeColor.color">
+      <template #content>
+        <view class="iconfont ucicon-nfc menu-icon" @click="nfcClick()"></view>
+        <view class="iconfont ucicon-saoyisao menu-icon" @click="scanClick()"></view>
+      </template>
+    </oaMovable>
 
     <drawer v-if="scanArray.length > 0" :scanArray="scanArray" :scanBool="scanBool" @scanClose="scanClose"></drawer>
   </scroll-view>
 </template>
 
 <script setup>
-import drawer from "./components/drawer.vue";
-
-import { onLoad, onShow, onLaunch } from "@dcloudio/uni-app";
-import { ref, onMounted, reactive, computed, getCurrentInstance, toRefs, inject, shallowRef } from "vue";
+import { onLoad, onShow, onLaunch, onUnload } from "@dcloudio/uni-app";
+import { ref, onMounted, reactive, computed, getCurrentInstance, toRefs, inject, shallowRef, defineAsyncComponent } from "vue";
 import { useStores, commonStores, xunJianStores } from "@/store/modules/index";
-
 import { recordList, recordOption, planList, patrolInspectionPlan, appPlanStatistics } from "@/api/business/mhxf/xunJian/plan.js";
+import drawer from "./components/drawer.vue"; // 引入组件
+import oaMovable from "@/components/oa-movable/index.vue"; // 引入组件
 
 const commonStore = commonStores(); //全局公共Store
 const xunJianStore = xunJianStores(); //全局变量值Store
@@ -181,6 +183,15 @@ function reportClick(obj) {
   }
 }
 
+/**
+ * @NFC
+ */
+function nfcClick() {
+  uni.navigateTo({
+    url: "/pages/common/nfc/index",
+  });
+}
+
 /**
  * @扫一扫
  * @点击事件
@@ -195,24 +206,7 @@ function scanClick() {
         title: "扫码成功",
         icon: "none",
       });
-      xunJianStore.inspectionStatus = 1;
-
-      planList({
-        siteNubmber: e.result,
-      }).then((res) => {
-        if (res.status == "SUCCESS") {
-          if (res.data.length > 0) {
-            scanArray.value = res.data;
-            scanBool.value = true;
-          } else {
-            uni.showToast({
-              title: "此点位下暂无数据,请切换点位重试!",
-              icon: "none",
-            });
-          }
-        } else {
-        }
-      });
+      planListApi(e.result);
     },
     fail: (err) => {
       uni.showToast({
@@ -222,15 +216,37 @@ function scanClick() {
       console.log("扫码失败", err);
     },
     complete: () => {
-      // uni.showToast({
-      //   title: "扫码结束",
-      //   icon: "none",
-      // });
       console.log("扫码结束");
     },
   });
 }
 
+/**
+ * @点位查询
+ * @接口查询
+ */
+function planListApi(value) {
+  console.log(value);
+  xunJianStore.inspectionStatus = 1;
+
+  planList({
+    siteNubmber: value,
+  }).then((res) => {
+    if (res.status == "SUCCESS") {
+      if (res.data.length > 0) {
+        scanArray.value = res.data;
+        scanBool.value = true;
+      } else {
+        uni.showToast({
+          title: "此点位下暂无数据,请切换点位重试!",
+          icon: "none",
+        });
+      }
+    } else {
+    }
+  });
+}
+
 /**
  * @抽屉emit
  * @关闭事件
@@ -342,6 +358,14 @@ onLoad((options) => {
 onShow(() => {
   //调用系统主题颜色
   proxy.$settingStore.systemThemeColor([1]);
+
+  uni.$on("tagid", function (value) {
+    planListApi(value);
+  });
+});
+
+onUnload(() => {
+  uni.$off("tagid"); //将值删除监听器
 });
 
 onMounted(() => {});

+ 313 - 0
src/pages/common/nfc/index.vue

@@ -0,0 +1,313 @@
+<template></template>
+
+<script setup>
+import config from "@/config";
+import storage from "@/utils/storage";
+import { onLoad, onShow, onReady, onHide, onLaunch, onUnload, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
+import { ref, reactive, computed, getCurrentInstance, toRefs, inject, watch } from "vue";
+import { useStores, commonStores, xunJianStores } from "@/store/modules/index";
+
+const { proxy } = getCurrentInstance();
+const xunJianStore = xunJianStores();
+
+const data = reactive({});
+const {} = toRefs(data);
+
+var NfcAdapter;
+var NdefRecord;
+var NdefMessage;
+var waiting;
+var readyWriteData = false; //开启写
+var readyRead = false; //开启读
+var techListsArray = [
+  ["android.nfc.tech.IsoDep"],
+  ["android.nfc.tech.NfcA"],
+  ["android.nfc.tech.NfcB"],
+  ["android.nfc.tech.NfcF"],
+  ["android.nfc.tech.Nfcf"],
+  ["android.nfc.tech.NfcV"],
+  ["android.nfc.tech.NdefFormatable"],
+  ["android.nfc.tech.MifareClassic"],
+  ["android.nfc.tech.MifareUltralight"],
+];
+
+function initNFC() {
+  if (uni.getSystemInfoSync().platform == "android") {
+    listenNFCStatus();
+  }
+}
+function readNFC(callback) {
+  if (uni.getSystemInfoSync().platform == "android") {
+    readData(callback);
+  }
+}
+function closeNFC() {
+  if (uni.getSystemInfoSync().platform == "android") {
+    closeReadAndWrite();
+  }
+}
+
+function listenNFCStatus() {
+  try {
+    var main = plus.android.runtimeMainActivity();
+    var Intent = plus.android.importClass("android.content.Intent");
+    var Activity = plus.android.importClass("android.app.Activity");
+    var PendingIntent = plus.android.importClass("android.app.PendingIntent");
+    var IntentFilter = plus.android.importClass("android.content.IntentFilter");
+    NfcAdapter = plus.android.importClass("android.nfc.NfcAdapter");
+    var nfcAdapter = NfcAdapter.getDefaultAdapter(main);
+
+    if (nfcAdapter == null) {
+      uni.showToast({
+        title: "设备不支持NFC!",
+        icon: "none",
+      });
+      return;
+    }
+
+    if (!nfcAdapter.isEnabled()) {
+      uni.showToast({
+        title: "请在系统设置中先启用NFC功能!",
+        icon: "none",
+      });
+      return;
+    }
+
+    var intent = new Intent(main, main.getClass());
+    intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
+    var pendingIntent = PendingIntent.getActivity(main, 0, intent, 0);
+    var ndef = new IntentFilter("android.nfc.action.TECH_DISCOVERED");
+    ndef.addDataType("*/*");
+    var intentFiltersArray = [ndef];
+
+    plus.globalEvent.addEventListener(
+      "newintent",
+      function () {
+        // 轮询调用 NFC
+        setTimeout(handle_nfc_data1, 1000);
+      },
+      false
+    );
+    plus.globalEvent.addEventListener(
+      "pause",
+      function (e) {
+        if (nfcAdapter) {
+          //关闭前台调度系统
+          //恢复默认状态
+          nfcAdapter.disableForegroundDispatch(main);
+        }
+      },
+      false
+    );
+    plus.globalEvent.addEventListener(
+      "resume",
+      function (e) {
+        if (nfcAdapter) {
+          //开启前台调度系统
+          // 优于所有其他NFC
+          nfcAdapter.enableForegroundDispatch(main, pendingIntent, intentFiltersArray, techListsArray);
+        }
+      },
+      false
+    );
+    nfcAdapter.enableForegroundDispatch(main, pendingIntent, intentFiltersArray, techListsArray);
+  } catch (e) {
+    console.error(e);
+  }
+}
+
+function handle_nfc_data1() {
+  NdefRecord = plus.android.importClass("android.nfc.NdefRecord");
+  NdefMessage = plus.android.importClass("android.nfc.NdefMessage");
+  var main = plus.android.runtimeMainActivity();
+  var intent = main.getIntent();
+  //console.log("action type:" + intent.getAction());
+  if ("android.nfc.action.TECH_DISCOVERED" == intent.getAction()) {
+    if (readyWriteData) {
+      //__write(intent);
+      readyWriteData = false;
+    } else if (readyRead) {
+      __read(intent);
+      readyRead = false;
+    }
+  }
+}
+
+function showToast(msg) {
+  plus.nativeUI.toast(msg);
+}
+
+/**
+ * @NFC写入
+ * @param {*} intent
+ * @returns
+ */
+function __write(intent) {
+  try {
+    waiting.setTitle("请勿移开标签\n正在写入...");
+    var text = document.getElementById("text").value;
+    console.log("text=" + text);
+
+    var textBytes = plus.android.invoke(text, "getBytes");
+    var textRecord = new NdefRecord(NdefRecord.TNF_MIME_MEDIA, plus.android.invoke("text/plain", "getBytes"), plus.android.invoke("", "getBytes"), textBytes);
+    var message = new NdefMessage([textRecord]);
+    var Ndef = plus.android.importClass("android.nfc.tech.Ndef");
+    var NdefFormatable = plus.android.importClass("android.nfc.tech.NdefFormatable");
+    var tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
+    var ndef = Ndef.get(tag);
+    if (ndef != null) {
+      var size = message.toByteArray().length;
+      console.log("size=" + size);
+      ndef.connect();
+      if (!ndef.isWritable()) {
+        showToast("tag不允许写入");
+        waiting.close();
+        return;
+      }
+      if (ndef.getMaxSize() < size) {
+        showToast("文件大小超出容量");
+        waiting.close();
+        return;
+      }
+
+      ndef.writeNdefMessage(message);
+      waiting.close();
+      showToast("写入数据成功.");
+      return;
+    } else {
+      var format = NdefFormatable.get(tag);
+      if (format != null) {
+        try {
+          format.connect();
+          format.format(message);
+          showToast("格式化tag并且写入message");
+          waiting.close();
+          return;
+        } catch (e) {
+          showToast("格式化tag失败.");
+          waiting.close();
+          return;
+        }
+      } else {
+        showToast("Tag不支持NDEF");
+        waiting.close();
+        return;
+      }
+    }
+  } catch (e) {
+    console.log("error=" + e);
+    waiting.close();
+    alert("写入失败");
+  }
+}
+
+/**
+ * @NFC读取
+ * @param {*} intent
+ * @returns
+ */
+function __read(intent) {
+  try {
+    var content = "";
+    waiting.setTitle("请勿移开标签\n正在读取数据...");
+    var tag = plus.android.importClass("android.nfc.Tag");
+    tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
+    var bytesId = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID);
+    waiting.close();
+    var tagid = bytesToHexString(tag.getId());
+
+    uni.$emit("tagid", tagid); //将值存储监听器
+    proxy.$tab.navigateBack(1); //返回上一级页面
+    closeNFC();
+  } catch (e) {
+    uni.showToast({
+      title: e,
+      icon: "none",
+    });
+  }
+}
+
+function bytesToHexString(inarray) {
+  var i, j, x;
+  var hex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"];
+  var out = "";
+  for (j = 0; j < inarray.length; ++j) {
+    x = parseInt(inarray[j]) & 0xff;
+    i = (x >> 4) & 0x0f;
+    out += hex[i];
+    i = x & 0x0f;
+    out += hex[i];
+  }
+  return out;
+}
+
+function reverseTwo(str) {
+  var str1 = "";
+  for (var i = 1; i <= str.length; i++) {
+    str1 += str[i - 1];
+    if (i % 2 == 0) {
+      if (i == str.length) {
+        break;
+      }
+      str1 += ":";
+    }
+  }
+  var str2 = "";
+  for (var i = str1.split(":").length - 1; i >= 0; i--) {
+    str2 += str1.split(":")[i];
+  }
+  return str2;
+}
+
+if (uni.getSystemInfoSync().platform == "android") {
+  //plus.globalEvent.addEventListener('plusready', listenNFCStatus, false);
+}
+
+function writeData() {
+  var textEle = plus.globalEvent.getElementById("text");
+  if (!textEle.value) {
+    uni.showToast({
+      title: "请输入要写入的内容!",
+      icon: "none",
+    });
+    return;
+  }
+  readyWriteData = true;
+  waiting = plus.nativeUI.showWaiting("请将NFC标签靠近!");
+}
+
+function readData() {
+  readyRead = true;
+  waiting = plus.nativeUI.showWaiting("请将NFC标签靠近!", {
+    modal: false,
+  });
+}
+
+function closeReadAndWrite() {
+  readyWriteData = false;
+  readyRead = false;
+
+  if (waiting) {
+    waiting.close();
+  }
+}
+
+onLoad((options) => {
+  // 开启nfc监听
+  initNFC();
+  readNFC();
+});
+
+onUnload(() => {
+  closeNFC();
+});
+
+onReady(() => {});
+
+onShow(() => {
+  //调用系统主题颜色
+  proxy.$settingStore.systemThemeColor([1]);
+});
+</script>
+
+<style lang="scss" scoped></style>

+ 39 - 3
src/static/iconfont/iconfont.css

@@ -1,8 +1,8 @@
 @font-face {
   font-family: "iconfont"; /* Project id 3620854 */
-  src: url("https://at.alicdn.com/t/c/font_3620854_k0vl6lrxxy.woff2?t=1693536081618") format("woff2"),
-       url("https://at.alicdn.com/t/c/font_3620854_k0vl6lrxxy.woff?t=1693536081618") format("woff"),
-       url("https://at.alicdn.com/t/c/font_3620854_k0vl6lrxxy.ttf?t=1693536081618") format("truetype");
+  src: url('https://at.alicdn.com/t/c/font_3620854_o6ushwiz9vl.woff2?t=1701161701250') format('woff2'),
+       url('https://at.alicdn.com/t/c/font_3620854_o6ushwiz9vl.woff?t=1701161701250') format('woff'),
+       url('https://at.alicdn.com/t/c/font_3620854_o6ushwiz9vl.ttf?t=1701161701250') format('truetype');
 }
 
 .iconfont {
@@ -13,6 +13,42 @@
   -moz-osx-font-smoothing: grayscale;
 }
 
+.ucicon-nfc:before {
+  content: "\e61a";
+}
+
+.ucicon-jiahao:before {
+  content: "\e727";
+}
+
+.ucicon-skin:before {
+  content: "\e636";
+}
+
+.ucicon-ziti:before {
+  content: "\e7b1";
+}
+
+.ucicon-fullscreen:before {
+  content: "\e625";
+}
+
+.ucicon-zaosheng:before {
+  content: "\e61c";
+}
+
+.ucicon-diannao:before {
+  content: "\e623";
+}
+
+.ucicon-siweidaotu:before {
+  content: "\e619";
+}
+
+.ucicon-yanzhengshoujihao:before {
+  content: "\e633";
+}
+
 .ucicon-zhiwen:before {
   content: "\e74f";
 }

二进制
src/static/iconfont/iconfont.ttf


+ 1 - 1
src/store/modules/index.js

@@ -7,5 +7,5 @@ export {
     useStores,
     commonStores,
     settingStores,
-    xunJianStores
+    xunJianStores,
 };

+ 24 - 22
src/store/modules/setting.js

@@ -34,30 +34,32 @@ const settingStore = defineStore("setting", {
          * @系统主题颜色
          */
         systemThemeColor(type) {
-            if (type.includes(2)) {
-                uni.setTabBarStyle({
-                    selectedColor: this.themeColor.color,
-                    borderStyle: "white",
-                });
-
-                this.themeColor.tabList.forEach((selectedIconPath, index) => {
-                    uni.setTabBarItem({
-                        index,
-                        selectedIconPath,
+            setTimeout(() => {
+                if (type.includes(2)) {
+                    uni.setTabBarStyle({
+                        selectedColor: this.themeColor.color,
+                        borderStyle: "white",
                     });
-                });
-            }
 
-            if (type.includes(1)) {
-                uni.setNavigationBarColor({
-                    frontColor: "#ffffff",
-                    backgroundColor: this.themeColor.color,
-                    animation: {
-                        duration: 400,
-                        timingFunc: "easeIn",
-                    },
-                });
-            }
+                    this.themeColor.tabList.forEach((selectedIconPath, index) => {
+                        uni.setTabBarItem({
+                            index,
+                            selectedIconPath,
+                        });
+                    });
+                }
+
+                if (type.includes(1)) {
+                    uni.setNavigationBarColor({
+                        frontColor: "#ffffff",
+                        backgroundColor: this.themeColor.color,
+                        animation: {
+                            duration: 400,
+                            timingFunc: "easeIn",
+                        },
+                    });
+                }
+            }, 0);
         },
 
         /**