index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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. <baPing />
  74. </template>
  75. <script setup>
  76. /*----------------------------------依赖引入-----------------------------------*/
  77. import { onReady, onLoad, onShow, onUnload, onNavigationBarButtonTap } from "@dcloudio/uni-app";
  78. import { ref, onMounted, reactive, computed, getCurrentInstance, toRefs, inject, shallowRef, watch } from "vue";
  79. /*----------------------------------接口引入-----------------------------------*/
  80. import { addSite } from "@/api/business/zhaf/xunJian/collect.js";
  81. /*----------------------------------组件引入-----------------------------------*/
  82. import oaMovable from "@/components/oa-movable/index.vue"; // 引入组件
  83. /*----------------------------------store引入-----------------------------------*/
  84. import { xunJianStores } from "@/store/modules/index";
  85. /*----------------------------------公共方法引入-----------------------------------*/
  86. /*----------------------------------公共变量-----------------------------------*/
  87. const { proxy } = getCurrentInstance();
  88. const xunJianStore = xunJianStores(); //全局变量值Store
  89. /*----------------------------------变量声明-----------------------------------*/
  90. /**
  91. * @NFC
  92. */
  93. function nfcClick() {
  94. proxy.$nfc.initNFC();
  95. }
  96. /**
  97. * @扫一扫
  98. * @点击事件
  99. */
  100. const scanArray = ref([]);
  101. const scanBool = ref(false);
  102. function scanClick() {
  103. uni.scanCode({
  104. autoZoom: false,
  105. success: (e) => {
  106. proxy.$modal.msg("扫码成功");
  107. proxy.$tab.navigateTo(`/pages/business/zhaf/xunJian/collect/components/collectDetail?siteNubmber=${e.result}&siteType=${1}`);
  108. },
  109. fail: (err) => {
  110. proxy.$modal.msg("扫码失败");
  111. },
  112. complete: () => {
  113. console.log("扫码结束");
  114. },
  115. });
  116. }
  117. /**
  118. * @api请求
  119. * @提交按钮点击事件
  120. */
  121. const message = ref(null);
  122. const messageList = reactive({
  123. type: "",
  124. message: "",
  125. duration: 0,
  126. color: "",
  127. });
  128. function handleInsert(e) {
  129. if (!proxy.$common.isNetwork()) {
  130. return false;
  131. }
  132. uni.getLocation({
  133. type: "gcj02",
  134. geocode: true,
  135. highAccuracyExpireTime: 5000,
  136. success: function (res) {
  137. api(res.longitude, res.latitude);
  138. },
  139. fail: function (res) {
  140. proxy.$modal.msg("请打开手机定位或相关应用权限定位!");
  141. },
  142. });
  143. function api(longitude, latitude) {
  144. addSite({
  145. siteName: e.siteName, //地点名称
  146. siteNubmber: e.siteNubmber, //地点号码
  147. siteDescribe: e.siteDescribe, //地点描述
  148. siteType: e.siteType, //地点类型(1二维码,2NFC)
  149. longitude: longitude, //经度
  150. latitude: latitude, //纬度
  151. pictureUrl: "", //图片地址
  152. distanceRange: 10, //误差范围
  153. // areaId: 0, //区域id
  154. // companyId: 0, //单位ID
  155. collectTime: e.siteTime ? e.siteTime.replace(" ", "T") : e.siteTime,
  156. })
  157. .then((res) => {
  158. if (res.status == "SUCCESS") {
  159. messageList.type = "SUCCESS";
  160. messageList.message = "提交成功";
  161. messageList.duration = 2000;
  162. messageList.color = "#09bb07";
  163. message.value.open();
  164. xunJianStore.collectDataList.splice(xunJianStore.collectDataList.indexOf(e), 1);
  165. } else {
  166. }
  167. })
  168. .catch((err) => {
  169. proxy.$modal.msg(err);
  170. });
  171. }
  172. }
  173. const options = ref([
  174. {
  175. text: "删除",
  176. style: {
  177. backgroundColor: "#dd524d",
  178. },
  179. },
  180. ]);
  181. /**
  182. * @左滑删除点击事件
  183. */
  184. function bindClick(e, index) {
  185. xunJianStore.collectDataList.splice(index, 1);
  186. }
  187. /**
  188. * @左滑删除change事件
  189. */
  190. function swipeChange(e, index) {
  191. if (e == "right") {
  192. xunJianStore.collectDataList[index].swipeBool = true;
  193. } else {
  194. xunJianStore.collectDataList[index].swipeBool = false;
  195. }
  196. }
  197. //右侧按钮点击事件
  198. function handleIconClick(type) {
  199. if (type === "采集记录") {
  200. proxy.$tab.navigateTo("/pages/business/zhaf/xunJian/collect/components/collectRecord");
  201. }
  202. }
  203. //返回
  204. function handleToBack() {
  205. proxy.$tab.navigateBack(1); //返回到需要执行方法的页面
  206. }
  207. onLoad((options) => {});
  208. onShow(() => {
  209. //调用系统主题颜色
  210. proxy.$settingStore.systemThemeColor([1]);
  211. uni.$on("NFC_readID", function (value) {
  212. setTimeout(() => {
  213. proxy.$tab.navigateTo(`/pages/business/zhaf/xunJian/collect/components/collectDetail?siteNubmber=${value}&siteType=${2}`);
  214. uni.$off("NFC_readID"); //将值删除监听器
  215. }, 0);
  216. });
  217. });
  218. onUnload(() => {
  219. uni.$off("NFC_readID"); //将值删除监听器
  220. });
  221. onReady(() => {});
  222. </script>
  223. <style lang="scss" scoped>
  224. .collect-area {
  225. display: flex;
  226. padding: 15px;
  227. &_left {
  228. display: flex;
  229. margin-right: 15px;
  230. }
  231. &_center {
  232. &_title {
  233. display: flex;
  234. font-size: 15px;
  235. margin-bottom: 5px;
  236. height: 20px;
  237. line-height: 20px;
  238. }
  239. &_time {
  240. font-size: 13px;
  241. color: #a1a1a1;
  242. }
  243. }
  244. &_right {
  245. display: flex;
  246. padding: 0 15px;
  247. &_item {
  248. margin: auto;
  249. padding: 0;
  250. font-size: 14px;
  251. color: #409eff;
  252. }
  253. }
  254. }
  255. </style>