index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <web-view
  3. v-show="!controlStore.modal.show"
  4. ref="faceView"
  5. id="faceView"
  6. class="faceView"
  7. src="/static/face/meeting.html"
  8. bindmessage="receiveMessage"
  9. :webview-styles="webviewStyles"
  10. @message="onMessage"
  11. >
  12. </web-view>
  13. <u-modal
  14. :show="controlStore.modal.show"
  15. title="配置服务器"
  16. :cancelText="'退出应用'"
  17. :zoom="false"
  18. :showConfirmButton="true"
  19. :showCancelButton="true"
  20. :closeOnClickOverlay="true"
  21. @confirm="controlStore.modalConfirm(), getMeetingRoomReservationList()"
  22. @cancel="controlStore.modalCancel()"
  23. @close="controlStore.modalClose()"
  24. >
  25. <view class="slot-content">
  26. <u-subsection class="mb20" :list="controlStore.subsection.list" :current="controlStore.subsection.value" @change="controlStore.sectionChange"></u-subsection>
  27. <view v-if="controlStore.subsection.value == 0">
  28. <view class="mb10 required">服务器地址</view>
  29. <view class="mb20">
  30. <u-input v-model="controlStore.form.linkUrl" placeholder="服务器地址(必填)" border="bottom" style="padding: 6px 0px" />
  31. </view>
  32. <view class="mb10">服务器端口</view>
  33. <view class="mb20">
  34. <u-input v-model="controlStore.form.port" placeholder="服务器端口(非必填)" border="bottom" style="padding: 6px 0px" />
  35. </view>
  36. </view>
  37. <view v-if="controlStore.subsection.value == 1">
  38. <view class="mb10 required">绑定会议室</view>
  39. <view class="mb20">
  40. <u-input
  41. v-model="controlStore.form.meetingName"
  42. placeholder="会议室(必选)"
  43. suffixIcon="arrow-right"
  44. suffixIconStyle="color: #909399"
  45. border="bottom"
  46. style="padding: 6px 0px"
  47. disabledColor="transparent"
  48. disabled
  49. @click="controlStore.handlePicker('绑定会议室')"
  50. />
  51. </view>
  52. <view class="mb10 required">绑定门禁</view>
  53. <view>
  54. <u-input
  55. v-model="controlStore.form.doorName"
  56. placeholder="门禁(必选)"
  57. suffixIcon="arrow-right"
  58. suffixIconStyle="color: #909399"
  59. border="none"
  60. disabledColor="transparent"
  61. disabled
  62. @click="controlStore.handlePicker('绑定门禁')"
  63. />
  64. </view>
  65. <view class="mb10 required" @click="handleButton()">开启灯光</view>
  66. </view>
  67. </view>
  68. </u-modal>
  69. <u-picker
  70. :show="controlStore.picker.show"
  71. :columns="controlStore.picker.list"
  72. :title="'请选择' + controlStore.picker.title"
  73. keyName="name"
  74. visibleItemCount="6"
  75. :defaultIndex="[controlStore.picker.defaultIndex]"
  76. :closeOnClickOverlay="true"
  77. @close="controlStore.picker.show = false"
  78. @cancel="controlStore.picker.show = false"
  79. @confirm="controlStore.pickerConfirm"
  80. ></u-picker>
  81. </template>
  82. <script setup>
  83. /*----------------------------------依赖引入-----------------------------------*/
  84. import config from "@/config";
  85. import { onLoad, onShow, onReady, onHide, onLaunch, onUnload, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
  86. import { ref, reactive, computed, getCurrentInstance, toRefs, inject, nextTick, watch } from "vue";
  87. /*----------------------------------接口引入-----------------------------------*/
  88. import { meetingApi, signOnOut } from "@/api/business/meeting.js";
  89. /*----------------------------------组件引入-----------------------------------*/
  90. /*----------------------------------store引入-----------------------------------*/
  91. import { controlStores } from "@/store/modules/index";
  92. /*----------------------------------公共方法引入-----------------------------------*/
  93. const { proxy } = getCurrentInstance();
  94. const controlStore = controlStores();
  95. /*----------------------------------公共变量-----------------------------------*/
  96. const state = reactive({
  97. webviewStyles: {
  98. width: "100%",
  99. height: "100%",
  100. },
  101. inter: {
  102. interMeeting: null,
  103. },
  104. });
  105. const { webviewStyles, meetingRoomList, modal, picker, form, inter } = toRefs(state);
  106. // 初始化
  107. function init() {
  108. controlStore.pageFunction = ["门禁", "会议"];
  109. controlStore.initCamera();
  110. controlStore.initNfc();
  111. controlStore.initData();
  112. // if (!inter.interMeeting) {
  113. // getMeetingRoomReservationList();
  114. // inter.interMeeting = setInterval(() => {
  115. // getMeetingRoomReservationList();
  116. // }, 1000 * 5);
  117. // }
  118. }
  119. /**
  120. * @会议室详情列表
  121. */
  122. function getMeetingRoomReservationList() {
  123. controlStore.meetingTimeList = [];
  124. controlStore.meetingReservaList.thisVenueData = [];
  125. controlStore.meetingReservaList.thisVenueTime = {};
  126. controlStore.meetingReservaList.nextSceneData = [];
  127. controlStore.meetingReservaList.nextSceneTime = {};
  128. for (let i = 0; i <= 23.5; i += 0.5) {
  129. var time = "";
  130. if (i % 1 === 0.5) {
  131. if (i < 10) {
  132. time = "0" + (i - 0.5) + ":30";
  133. } else {
  134. time = i - 0.5 + ":30";
  135. }
  136. } else {
  137. if (i < 10) {
  138. time = "0" + i + ":00";
  139. } else {
  140. time = i + ":00";
  141. }
  142. }
  143. controlStore.meetingTimeList.push({
  144. startTime: time,
  145. endTime: time,
  146. isEnd: 0,
  147. isHave: 0,
  148. isReservation: 0,
  149. });
  150. }
  151. meetingApi()
  152. .GetMeetingRoomReservationList({
  153. domain: controlStore.form.domain,
  154. meetingRoomId: controlStore.form.meetingId,
  155. date: proxy.$dayjs().format("YYYY-MM-DD") + " 00:00:00",
  156. })
  157. .then((requset) => {
  158. if (requset.data.length > 0) {
  159. controlStore.meetingReservaList.dataAll = requset.data[0];
  160. controlStore.meetingReservaList.dataAll.dmMeetingList.forEach((e, index) => {
  161. //判断开始时间和结束时间是否包含当前时间
  162. if (proxy.$dayjs().isBetween(e.startDate, e.endDate, null, "[]")) {
  163. controlStore.meetingReservaList.thisVenueData.push(e);
  164. controlStore.meetingReservaList.thisVenueTime = proxy.$time.timeRestructuring(controlStore.meetingReservaList.dataAll.meetingRoomUsage[index]);
  165. }
  166. //判断当前时间是否相同或在其之前
  167. if (proxy.$dayjs().isSameOrBefore(e.startDate) && controlStore.meetingReservaList.nextSceneData.length < 1) {
  168. controlStore.meetingReservaList.nextSceneData.push(e);
  169. controlStore.meetingReservaList.nextSceneTime = proxy.$time.timeRestructuring(controlStore.meetingReservaList.dataAll.meetingRoomUsage[index]);
  170. }
  171. });
  172. controlStore.meetingReservaList.timeList = showTimeSegments(controlStore.meetingTimeList);
  173. controlStore.handleChildren({
  174. funcName: "初始化数据",
  175. data: JSON.stringify(controlStore.meetingReservaList),
  176. });
  177. } else {
  178. controlStore.meetingReservaList.timeList = controlStore.meetingTimeList;
  179. controlStore.handleChildren({
  180. funcName: "初始化数据",
  181. data: JSON.stringify(controlStore.meetingReservaList),
  182. });
  183. }
  184. })
  185. .catch((err) => {});
  186. }
  187. // 显示时间段的函数
  188. function showTimeSegments(times) {
  189. const timesXleList = JSON.parse(JSON.stringify(times));
  190. for (var i = 0; i < timesXleList.length; i++) {
  191. const timeValue = new Date(`${proxy.$dayjs().format("YYYY-MM-DD")}T${timesXleList[i].startTime}`);
  192. controlStore.meetingReservaList.dataAll.meetingRoomUsage.forEach((item) => {
  193. const timeList = proxy.$time.timeRestructuring(item);
  194. const startValue = new Date(`${proxy.$dayjs().format("YYYY-MM-DD")}T${timeList.startTime}`);
  195. const endValue = new Date(`${proxy.$dayjs().format("YYYY-MM-DD")}T${timeList.endTime}`);
  196. if (timeValue.getTime() >= startValue.getTime() && timeValue.getTime() < endValue.getTime()) {
  197. timesXleList.splice(i--, 1);
  198. }
  199. });
  200. }
  201. controlStore.meetingReservaList.dataAll.meetingRoomUsage.forEach((item) => {
  202. const timeList = proxy.$time.timeRestructuring(item);
  203. const startValue = new Date(`${proxy.$dayjs().format("YYYY-MM-DD")}T${timeList.startTime}`);
  204. const endValue = new Date(`${proxy.$dayjs().format("YYYY-MM-DD")}T${timeList.endTime}`);
  205. if (proxy.$dayjs().isBetween(startValue, endValue, null, "[]")) {
  206. timesXleList.push({
  207. ...timeList,
  208. isEnd: 0,
  209. isHave: 1,
  210. isReservation: 0,
  211. });
  212. } else {
  213. if (proxy.$dayjs().isSameOrAfter(startValue)) {
  214. timesXleList.push({
  215. ...timeList,
  216. isEnd: 1,
  217. isHave: 0,
  218. isReservation: 0,
  219. });
  220. }
  221. if (proxy.$dayjs().isSameOrBefore(startValue)) {
  222. timesXleList.push({
  223. ...timeList,
  224. isEnd: 0,
  225. isHave: 0,
  226. isReservation: 1,
  227. });
  228. }
  229. }
  230. });
  231. var newTimesXleList = proxy.$common
  232. .uniq(timesXleList, "startTime")
  233. .sort((a, b) => new Date(`${proxy.$dayjs().format("YYYY-MM-DD")}T${a.startTime}`) - new Date(`${proxy.$dayjs().format("YYYY-MM-DD")}T${b.startTime}`));
  234. return newTimesXleList;
  235. }
  236. /**
  237. * @接收子页面传过来的值
  238. */
  239. function onMessage(e) {
  240. controlStore.analysisData(e.detail.data[0]);
  241. }
  242. // #ifdef H5
  243. window.onmessage = function (event) {
  244. controlStore.analysisData(event.data);
  245. };
  246. // #endif
  247. function testAsyncFunc(imgUrl, index) {
  248. // 调用异步方法
  249. testModule.testAsyncFunc(
  250. {
  251. imgUrl: imgUrl,
  252. },
  253. (ret) => {
  254. console.log(ret);
  255. }
  256. );
  257. }
  258. const device = uni.requireNativePlugin("device");
  259. function handleButton(){
  260. device.setLed("绿色");
  261. }
  262. onLoad((options) => {
  263. setTimeout(() => {
  264. init();
  265. }, 500);
  266. // const plugin = uni.requireNativePlugin("temp_plugin");
  267. // console.log(plugin);
  268. // console.log("设备名称:", plugin.getDeviceName());
  269. // plugin.showToast("我是原生插件Toast");
  270. console.log(device);
  271. console.log("IP地址:", device.getIpAddress());
  272. // device.invoke1();
  273. // console.log("序列号:", device.getSerialno());
  274. // console.log("分区信息:", device.getDeviceCustom(16));
  275. // device.setLed("蓝色");
  276. // 假设你已经配置好了uniapp的Android插件
  277. const main = plus.android.runtimeMainActivity();
  278. const Intent = plus.android.importClass("android.content.Intent");
  279. const MyActivity = plus.android.importClass("com.example.device.test"); // 替换为你的包名和Activity名
  280. // 创建一个Intent来启动你的Activity
  281. const intent = new Intent(main, MyActivity);
  282. // 添加需要的额外数据到intent
  283. intent.putExtra("com.example.device.test.setLed", "绿色");
  284. // 启动Activity
  285. main.sendBroadcast(intent);
  286. // var testModule = uni.requireNativePlugin("opencv_plugin");
  287. // console.log(testModule);
  288. // testModule.testAsyncFunc(
  289. // {
  290. // imgUrl: "https://img0.baidu.com/it/u=3389607,2584865022&fm=253&fmt=auto&app=138&f=PNG?w=449&h=645",
  291. // },
  292. // (ret) => {
  293. // console.log(ret);
  294. // }
  295. // );
  296. });
  297. onShow(() => {});
  298. onUnload(() => {
  299. clearInterval(inter.interMeeting); //销毁之前定时器
  300. });
  301. </script>
  302. <style>
  303. .faceView {
  304. width: 100% !important;
  305. height: 100% !important;
  306. }
  307. iframe {
  308. width: 100% !important;
  309. height: 100% !important;
  310. border-width: 0;
  311. }
  312. </style>
  313. <style lang="scss" scoped>
  314. :deep() {
  315. .u-modal {
  316. width: 30rem !important;
  317. &__title {
  318. font-size: 18px !important;
  319. }
  320. .slot-content {
  321. font-size: 16px;
  322. width: 100%;
  323. }
  324. }
  325. }
  326. </style>