index.vue 5.8 KB

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