index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <u-navbar leftIconColor="#fff" :autoBack="false" :placeholder="true" :safeAreaInsetTop="true" :bgColor="proxy.$settingStore.themeColor.color" @leftClick="handleToBack()">
  3. <template #center>
  4. <view class="u-navbar__content__center__item"> 点位采集 </view>
  5. </template>
  6. <template #right>
  7. <view class="u-navbar__content__right__item font12">
  8. <span @click="handleIconClick('采集记录')">采集记录</span>
  9. </view>
  10. </template>
  11. </u-navbar>
  12. <oa-scroll
  13. customClass="scroll-height"
  14. :total="xunJianStore.collectDataList.length"
  15. :isSticky="false"
  16. :refresherEnabled="true"
  17. :refresherEnabledTitle="true"
  18. :refresherDefaultStyle="'none'"
  19. :refresherThreshold="44"
  20. :refresherBackground="'#f5f6f7'"
  21. :data-theme="'theme-' + proxy.$settingStore.themeColor.name"
  22. >
  23. <template #default>
  24. <!-- 按组使用 -->
  25. <uni-swipe-action>
  26. <uni-swipe-action-item
  27. v-for="(cu, index) in xunJianStore.collectDataList"
  28. :key="index"
  29. :right-options="options"
  30. @click="bindClick($event, index)"
  31. @change="swipeChange($event, index)"
  32. style="margin-bottom: 15px"
  33. >
  34. <view class="collect-area bg-white">
  35. <view class="collect-area_left">
  36. <u-image style="margin: auto" width="40" height="40" src="@/static/images/xunjian/scan.png" v-if="cu.siteType == 1" shape="circle"></u-image>
  37. <u-image style="margin: auto" width="40" height="40" src="@/static/images/xunjian/NFC.png" v-if="cu.siteType == 2" shape="circle"></u-image>
  38. </view>
  39. <view class="collect-area_center">
  40. <view class="collect-area_center_title">
  41. {{ cu.siteName }}
  42. </view>
  43. <view class="collect-area_center_time">
  44. {{ cu.siteTime }}
  45. </view>
  46. </view>
  47. <view style="margin: auto"></view>
  48. <view class="collect-area_right">
  49. <view v-if="cu.swipeBool == false" class="collect-area_right_item" @click="handleInsert(cu)"> 提交 </view>
  50. </view>
  51. </view>
  52. </uni-swipe-action-item>
  53. </uni-swipe-action>
  54. <oaMovable :themesColor="proxy.$settingStore.themeColor.color">
  55. <template #content>
  56. <view class="iconfont oaIcon-nfc menu-item-icon" @click="nfcClick()"></view>
  57. <view class="iconfont oaIcon-saoyisao menu-item-icon" @click="scanClick()"></view>
  58. </template>
  59. </oaMovable>
  60. <!-- 提示信息弹窗 -->
  61. <uni-popup ref="message" type="message">
  62. <uni-popup-message
  63. :style="{
  64. color: messageList.color,
  65. }"
  66. :type="messageList.type"
  67. :message="messageList.message"
  68. :duration="messageList.duration"
  69. ></uni-popup-message>
  70. </uni-popup>
  71. </template>
  72. </oa-scroll>
  73. </template>
  74. <script setup>
  75. /*----------------------------------依赖引入-----------------------------------*/
  76. import { onReady, onLoad, onShow, onUnload, onNavigationBarButtonTap } from "@dcloudio/uni-app";
  77. import { ref, onMounted, reactive, computed, getCurrentInstance, toRefs, inject, shallowRef, watch } from "vue";
  78. /*----------------------------------接口引入-----------------------------------*/
  79. import { addSite } from "@/api/business/zhaf/xunJian/collect.js";
  80. /*----------------------------------组件引入-----------------------------------*/
  81. import oaMovable from "@/components/oa-movable/index.vue"; // 引入组件
  82. /*----------------------------------store引入-----------------------------------*/
  83. import { xunJianStores } from "@/store/modules/index";
  84. /*----------------------------------公共方法引入-----------------------------------*/
  85. /*----------------------------------公共变量-----------------------------------*/
  86. const { proxy } = getCurrentInstance();
  87. const xunJianStore = xunJianStores(); //全局变量值Store
  88. /*----------------------------------变量声明-----------------------------------*/
  89. /**
  90. * @NFC
  91. */
  92. function nfcClick() {
  93. proxy.$nfc.initNFC();
  94. }
  95. /**
  96. * @扫一扫
  97. * @点击事件
  98. */
  99. const scanArray = ref([]);
  100. const scanBool = ref(false);
  101. function scanClick() {
  102. uni.scanCode({
  103. autoZoom: false,
  104. success: (e) => {
  105. proxy.$modal.msg("扫码成功");
  106. proxy.$tab.navigateTo(`/pages/business/zhaf/xunJian/collect/components/collectDetail?siteNubmber=${e.result}&siteType=${1}`);
  107. },
  108. fail: (err) => {
  109. proxy.$modal.msg("扫码失败");
  110. },
  111. complete: () => {
  112. console.log("扫码结束");
  113. },
  114. });
  115. }
  116. /**
  117. * @api请求
  118. * @提交按钮点击事件
  119. */
  120. const message = ref(null);
  121. const messageList = reactive({
  122. type: "",
  123. message: "",
  124. duration: 0,
  125. color: "",
  126. });
  127. function handleInsert(e) {
  128. if (!proxy.$common.isNetwork()) {
  129. return false;
  130. }
  131. uni.getLocation({
  132. type: "gcj02",
  133. geocode: true,
  134. highAccuracyExpireTime: 5000,
  135. success: function (res) {
  136. api(res.longitude, res.latitude);
  137. },
  138. fail: function (res) {
  139. proxy.$modal.msg("请打开手机定位或相关应用权限定位!");
  140. },
  141. });
  142. function api(longitude, latitude) {
  143. addSite({
  144. siteName: e.siteName, //地点名称
  145. siteNubmber: e.siteNubmber, //地点号码
  146. siteDescribe: e.siteDescribe, //地点描述
  147. siteType: e.siteType, //地点类型(1二维码,2NFC)
  148. longitude: longitude, //经度
  149. latitude: latitude, //纬度
  150. pictureUrl: "", //图片地址
  151. distanceRange: 10, //误差范围
  152. // areaId: 0, //区域id
  153. // companyId: 0, //单位ID
  154. collectTime: e.siteTime ? e.siteTime.replace(" ", "T") : e.siteTime,
  155. })
  156. .then((res) => {
  157. if (res.status == "SUCCESS") {
  158. messageList.type = "SUCCESS";
  159. messageList.message = "提交成功";
  160. messageList.duration = 2000;
  161. messageList.color = "#09bb07";
  162. message.value.open();
  163. xunJianStore.collectDataList.splice(xunJianStore.collectDataList.indexOf(e), 1);
  164. } else {
  165. }
  166. })
  167. .catch((err) => {
  168. proxy.$modal.msg(err);
  169. });
  170. }
  171. }
  172. const options = ref([
  173. {
  174. text: "删除",
  175. style: {
  176. backgroundColor: "#dd524d",
  177. },
  178. },
  179. ]);
  180. /**
  181. * @左滑删除点击事件
  182. */
  183. function bindClick(e, index) {
  184. xunJianStore.collectDataList.splice(index, 1);
  185. }
  186. /**
  187. * @左滑删除change事件
  188. */
  189. function swipeChange(e, index) {
  190. if (e == "right") {
  191. xunJianStore.collectDataList[index].swipeBool = true;
  192. } else {
  193. xunJianStore.collectDataList[index].swipeBool = false;
  194. }
  195. }
  196. //右侧按钮点击事件
  197. function handleIconClick(type) {
  198. if (type === "采集记录") {
  199. proxy.$tab.navigateTo("/pages/business/zhaf/xunJian/collect/components/collectRecord");
  200. }
  201. }
  202. //返回
  203. function handleToBack() {
  204. proxy.$tab.navigateBack(1); //返回到需要执行方法的页面
  205. }
  206. onLoad((options) => {});
  207. onShow(() => {
  208. //调用系统主题颜色
  209. proxy.$settingStore.systemThemeColor([1]);
  210. uni.$on("NFC_readID", function (value) {
  211. setTimeout(() => {
  212. proxy.$tab.navigateTo(`/pages/business/zhaf/xunJian/collect/components/collectDetail?siteNubmber=${value}&siteType=${2}`);
  213. uni.$off("NFC_readID"); //将值删除监听器
  214. }, 0);
  215. });
  216. });
  217. onUnload(() => {
  218. uni.$off("NFC_readID"); //将值删除监听器
  219. });
  220. onReady(() => {});
  221. </script>
  222. <style lang="scss" scoped>
  223. .collect-area {
  224. display: flex;
  225. padding: 15px;
  226. &_left {
  227. display: flex;
  228. margin-right: 15px;
  229. }
  230. &_center {
  231. &_title {
  232. display: flex;
  233. font-size: 15px;
  234. margin-bottom: 5px;
  235. height: 20px;
  236. line-height: 20px;
  237. }
  238. &_time {
  239. font-size: 13px;
  240. color: #a1a1a1;
  241. }
  242. }
  243. &_right {
  244. display: flex;
  245. padding: 0 15px;
  246. &_item {
  247. margin: auto;
  248. padding: 0;
  249. font-size: 14px;
  250. color: #409eff;
  251. }
  252. }
  253. }
  254. </style>