index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <scroll-view class="scroll-height" :scroll-y="true" :data-theme="'theme-' + proxy.$settingStore.themeColor.name">
  3. <!-- 按组使用 -->
  4. <uni-swipe-action>
  5. <uni-swipe-action-item
  6. class="mb15"
  7. v-for="(cu, index) in xunJianStore.collectDataList"
  8. :key="index"
  9. :right-options="options"
  10. @click="bindClick($event, index)"
  11. @change="swipeChange($event, index)"
  12. >
  13. <view class="flex bg-white p15 pt0">
  14. <view class="flex mr15">
  15. <u-image style="margin: auto" width="40" height="40" src="@/static/images/xunjian/scan.png" v-if="cu.siteType == 1" shape="circle"></u-image>
  16. <u-image style="margin: auto" width="40" height="40" src="@/static/images/xunjian/NFC.png" v-if="cu.siteType == 2" shape="circle"></u-image>
  17. </view>
  18. <view class="reportCenter">
  19. <view class="centerSiteName">
  20. {{ cu.siteName }}
  21. </view>
  22. <view style="font-size: 13px; color: #a1a1a1">
  23. {{ cu.siteTime == "" || cu.siteTime == null ? "无" : cu.siteTime }}
  24. </view>
  25. </view>
  26. <view style="margin: auto"></view>
  27. <view class="reportRight">
  28. <view style="margin: auto" v-if="cu.swipeBool == false">
  29. <view style="padding: 0; font-size: 14px; color: #409eff" @click="handleInsert(cu)"> 提交 </view>
  30. </view>
  31. </view>
  32. </view>
  33. </uni-swipe-action-item>
  34. </uni-swipe-action>
  35. <oaMovable :themesColor="proxy.$settingStore.themeColor.color">
  36. <template #content>
  37. <view class="iconfont ucicon-nfc menu-item-icon" @click="nfcClick()"></view>
  38. <view class="iconfont ucicon-saoyisao menu-item-icon" @click="scanClick()"></view>
  39. </template>
  40. </oaMovable>
  41. <!-- 提示信息弹窗 -->
  42. <uni-popup ref="message" type="message">
  43. <uni-popup-message
  44. :style="{
  45. color: messageList.color,
  46. }"
  47. :type="messageList.type"
  48. :message="messageList.message"
  49. :duration="messageList.duration"
  50. ></uni-popup-message>
  51. </uni-popup>
  52. <u-empty marginTop="20%" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" v-if="xunJianStore.collectDataList.length <= 0"> </u-empty>
  53. </scroll-view>
  54. </template>
  55. <script setup>
  56. import { onReady, onLoad, onShow, onUnload, onNavigationBarButtonTap } from "@dcloudio/uni-app";
  57. import { ref, onMounted, reactive, computed, getCurrentInstance, toRefs, inject, shallowRef, watch } from "vue";
  58. import { xunJianStores } from "@/store/modules/index";
  59. import { addSite } from "@/api/business/mhxf/xunJian/collect.js";
  60. import oaMovable from "@/components/oa-movable/index.vue"; // 引入组件
  61. const { proxy } = getCurrentInstance();
  62. const xunJianStore = xunJianStores(); //全局变量值Store
  63. /**
  64. * @NFC
  65. */
  66. function nfcClick() {
  67. proxy.$nfc.initNFC();
  68. }
  69. /**
  70. * @扫一扫
  71. * @点击事件
  72. */
  73. const scanArray = ref([]);
  74. const scanBool = ref(false);
  75. function scanClick() {
  76. uni.scanCode({
  77. autoZoom: false,
  78. success: (e) => {
  79. uni.showToast({
  80. title: "扫码成功",
  81. icon: "none",
  82. });
  83. uni.navigateTo({
  84. url: `/pages/business/mhxf/xunJian/collect/components/collectDetail?siteNubmber=${e.result}&siteType=${1}`,
  85. });
  86. },
  87. fail: (err) => {
  88. uni.showToast({
  89. title: "扫码失败",
  90. icon: "none",
  91. });
  92. console.log("扫码失败", err);
  93. },
  94. complete: () => {
  95. console.log("扫码结束");
  96. },
  97. });
  98. }
  99. /**
  100. * @api请求
  101. * @提交按钮点击事件
  102. */
  103. const message = ref(null);
  104. const messageList = reactive({
  105. type: "",
  106. message: "",
  107. duration: 0,
  108. color: "",
  109. });
  110. function handleInsert(e) {
  111. uni.getLocation({
  112. type: "wgs84",
  113. success: function (res) {
  114. console.log("当前位置的经度:" + res.longitude);
  115. console.log("当前位置的纬度:" + res.latitude);
  116. api(res.longitude, res.latitude);
  117. },
  118. fail: function (res) {
  119. uni.showToast({
  120. title: "请打开手机定位或相关应用权限定位!",
  121. icon: "none",
  122. });
  123. },
  124. });
  125. function api(longitude, latitude) {
  126. addSite({
  127. siteName: e.siteName, //地点名称
  128. siteNubmber: e.siteNubmber, //地点号码
  129. siteDescribe: e.siteDescribe, //地点描述
  130. siteType: e.siteType, //地点类型(1二维码,2NFC)
  131. longitude: longitude, //经度
  132. latitude: latitude, //纬度
  133. pictureUrl: "", //图片地址
  134. distanceRange: 10, //误差范围
  135. // areaId: 0, //区域id
  136. // companyId: 0, //单位ID
  137. }).then((res) => {
  138. if (res.status == "SUCCESS") {
  139. messageList.type = "SUCCESS";
  140. messageList.message = "提交成功";
  141. messageList.duration = 2000;
  142. messageList.color = "#09bb07";
  143. message.value.open();
  144. xunJianStore.collectDataList.splice(xunJianStore.collectDataList.indexOf(e), 1);
  145. } else {
  146. }
  147. });
  148. }
  149. }
  150. const options = ref([
  151. {
  152. text: "删除",
  153. style: {
  154. backgroundColor: "#dd524d",
  155. },
  156. },
  157. ]);
  158. /**
  159. * @左滑删除点击事件
  160. */
  161. function bindClick(e, index) {
  162. xunJianStore.collectDataList.splice(index, 1);
  163. }
  164. /**
  165. * @左滑删除change事件
  166. */
  167. function swipeChange(e, index) {
  168. if (e == "right") {
  169. xunJianStore.collectDataList[index].swipeBool = true;
  170. } else {
  171. xunJianStore.collectDataList[index].swipeBool = false;
  172. }
  173. }
  174. // 自定义导航事件
  175. onNavigationBarButtonTap((e) => {
  176. if (e.float == "right") {
  177. uni.navigateTo({
  178. url: "/pages/business/mhxf/xunJian/collect/components/collectRecord",
  179. });
  180. } else {
  181. }
  182. });
  183. onLoad((options) => {});
  184. onShow(() => {
  185. //调用系统主题颜色
  186. proxy.$settingStore.systemThemeColor([1]);
  187. uni.$on("tagid", function (value) {
  188. setTimeout(() => {
  189. uni.navigateTo({
  190. url: `/pages/business/mhxf/xunJian/collect/components/collectDetail?siteNubmber=${value}&siteType=${2}`,
  191. });
  192. uni.$off("tagid"); //将值删除监听器
  193. }, 0);
  194. });
  195. });
  196. onUnload(() => {
  197. uni.$off("tagid"); //将值删除监听器
  198. });
  199. onReady(() => {});
  200. onMounted(() => {});
  201. </script>
  202. <style lang="scss">
  203. .is-selected {
  204. color: #1989fa;
  205. }
  206. </style>
  207. <style scoped>
  208. .reportCenter .centerSiteName {
  209. font-size: 15px;
  210. margin-bottom: 5px;
  211. height: 20px;
  212. line-height: 20px;
  213. display: flex;
  214. }
  215. .reportRight {
  216. display: flex;
  217. padding: 0 15px;
  218. }
  219. </style>