twoRoundExtension.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <view class="container">
  3. <!-- 搜索栏 -->
  4. <view class="search-bar">
  5. <input class="search-input" type="text" placeholder="请输入承包方姓名/身份证号" />
  6. <button class="search-btn">搜索</button>
  7. </view>
  8. <!-- 数据卡片区域 - 增加数据存在性判断 -->
  9. <view class="card" v-if="groupInfo && groupInfo.fbfmc">
  10. <view class="card-title">{{ groupInfo.fbfmc }}</view>
  11. <view class="tag-group">
  12. <view class="tag orange" @click="toCollective()">集体地</view>
  13. <view class="tag gray">未开始</view>
  14. </view>
  15. <view class="stats-row">
  16. <view class="stat-item" @click="InformationDetails()">
  17. <view class="stat-num">0</view>
  18. <view class="stat-label">总户数</view>
  19. </view>
  20. <view class="stat-item" @click="InformationDetails()">
  21. <view class="stat-num">0</view>
  22. <view class="stat-label">已上报</view>
  23. </view>
  24. <view class="stat-item" @click="InformationDetails()">
  25. <view class="stat-num red">0</view>
  26. <view class="stat-label">未上报</view>
  27. </view>
  28. </view>
  29. <view class="stats-row">
  30. <view class="stat-item pink" @click="InformationDetails()">
  31. <view class="stat-num">0</view>
  32. <view class="stat-label">待审核</view>
  33. </view>
  34. <view class="stat-item red" @click="InformationDetails()">
  35. <view class="stat-num">0</view>
  36. <view class="stat-label">未通过</view>
  37. </view>
  38. <view class="stat-item orange" @click="InformationDetails()">
  39. <view class="stat-num">0</view>
  40. <view class="stat-label">待公示</view>
  41. </view>
  42. <view class="stat-item green" @click="InformationDetails()">
  43. <view class="stat-num">0</view>
  44. <view class="stat-label">已公示</view>
  45. </view>
  46. </view>
  47. </view>
  48. <!-- 现场调查任务 -->
  49. <!-- <view class="task-item" @click="goToTask()">
  50. <view class="task-text">现场调查任务</view>
  51. <view class="task-arrow">></view>
  52. </view> -->
  53. <!-- 空数据提示 - 优化显示逻辑 -->
  54. <view class="empty-area">
  55. <view class="empty-text">暂无承包方数据</view>
  56. </view>
  57. <!-- 新增按钮 -->
  58. <button class="add-btn" @click="handleAdd">新增</button>
  59. </view>
  60. </template>
  61. <script setup>
  62. import { ref, onMounted } from 'vue';
  63. import { onLoad } from '@dcloudio/uni-app';
  64. // 初始化数据,避免undefined
  65. const groupInfo = ref({
  66. fbfmc: '' // 承包方名称默认值
  67. });
  68. // 封装参数解析逻辑,增加异常处理
  69. const parseOptions = (options) => {
  70. try {
  71. // 1. 校验参数是否存在
  72. if (!options || !options.groupInfo) {
  73. console.warn('未传入groupInfo参数');
  74. return {};
  75. }
  76. // 2. 解码并解析JSON,增加异常捕获
  77. const decodedData = decodeURIComponent(options.groupInfo);
  78. const parsedData = JSON.parse(decodedData);
  79. // 3. 校验解析后的数据结构
  80. if (!parsedData.fbfmc) {
  81. console.warn('groupInfo中缺少fbfmc字段', parsedData);
  82. return {};
  83. }
  84. return parsedData;
  85. } catch (error) {
  86. console.error('解析groupInfo失败:', error);
  87. return {};
  88. }
  89. };
  90. // 页面加载时解析参数
  91. onLoad((options) => {
  92. const data = parseOptions(options);
  93. groupInfo.value = { ...groupInfo.value, ...data };
  94. console.log('解析后的承包方数据:', groupInfo.value);
  95. });
  96. // 兼容不同平台的生命周期
  97. onMounted(() => {
  98. if (!groupInfo.value.fbfmc) {
  99. console.log('groupInfo数据未正确加载');
  100. }
  101. });
  102. // 处理导航栏操作(未使用的方法保留但注释说明)
  103. const handleMenu = () => {
  104. // 菜单逻辑暂未实现
  105. };
  106. const handleMinimize = () => {
  107. // 最小化逻辑暂未实现
  108. };
  109. const handleClose = () => {
  110. // 关闭逻辑暂未实现
  111. };
  112. // 信息详情跳转(增加提示友好性)
  113. const InformationDetails = () => {
  114. uni.showToast({
  115. title: '暂无相关数据',
  116. icon: 'none',
  117. duration: 1500
  118. });
  119. };
  120. // 跳转现场调查任务(增加页面存在性校验)
  121. const goToTask = () => {
  122. uni.navigateTo({
  123. url: '/pages/task/index',
  124. fail: (err) => {
  125. console.error('跳转现场调查任务失败:', err);
  126. uni.showToast({
  127. title: '页面不存在',
  128. icon: 'none'
  129. });
  130. }
  131. });
  132. };
  133. // 跳转集体地页面
  134. const toCollective = () => {
  135. uni.navigateTo({
  136. url: '/pages/map/collectively/index',
  137. fail: (err) => {
  138. console.error('跳转集体地页面失败:', err);
  139. uni.showToast({
  140. title: '页面不存在',
  141. icon: 'none'
  142. });
  143. }
  144. });
  145. };
  146. // 打开新增选项弹窗(优化用户体验)
  147. const handleAdd = () => {
  148. console.log(groupInfo.value)
  149. uni.showActionSheet({
  150. itemList: ['后台录入', '手动录入'],
  151. itemColor: '#007bff', // 统一主题色
  152. success: (res) => {
  153. const urlMap = [
  154. `/pages/EntryPage/backstageAdd?groupInfo=${encodeURIComponent(JSON.stringify(groupInfo))}`,
  155. '/pages/EntryPage/manualAdd'
  156. ];
  157. uni.navigateTo({
  158. url: urlMap[res.tapIndex],
  159. fail: (err) => {
  160. console.error('跳转新增页面失败:', err);
  161. uni.showToast({
  162. title: '页面不存在',
  163. icon: 'none'
  164. });
  165. }
  166. });
  167. },
  168. fail: (err) => {
  169. console.log('取消选择', err);
  170. }
  171. });
  172. };
  173. </script>
  174. <style scoped>
  175. .container {
  176. padding: 16rpx;
  177. background-color: #f8f9fa;
  178. min-height: 100vh;
  179. box-sizing: border-box;
  180. }
  181. .search-bar {
  182. display: flex;
  183. align-items: center;
  184. background-color: #fff;
  185. border-radius: 8rpx;
  186. padding: 12rpx 16rpx;
  187. margin-bottom: 20rpx;
  188. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  189. }
  190. .search-input {
  191. flex: 1;
  192. height: 60rpx;
  193. font-size: 28rpx;
  194. padding: 0 10rpx;
  195. }
  196. .search-btn {
  197. width: 120rpx;
  198. height: 60rpx;
  199. line-height: 60rpx;
  200. background-color: #007bff;
  201. color: #fff;
  202. border-radius: 8rpx;
  203. font-size: 28rpx;
  204. border: none;
  205. }
  206. .card {
  207. background-color: #fff;
  208. border-radius: 12rpx;
  209. padding: 20rpx;
  210. margin-bottom: 20rpx;
  211. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
  212. }
  213. .card-title {
  214. font-size: 30rpx;
  215. font-weight: 600;
  216. margin-bottom: 16rpx;
  217. color: #333;
  218. }
  219. .tag-group {
  220. display: flex;
  221. gap: 12rpx;
  222. margin-bottom: 24rpx;
  223. }
  224. .tag {
  225. padding: 4rpx 12rpx;
  226. border-radius: 6rpx;
  227. font-size: 24rpx;
  228. }
  229. .tag.orange {
  230. background-color: #ff9933;
  231. color: #fff;
  232. }
  233. .tag.gray {
  234. background-color: #cccccc;
  235. color: #fff;
  236. }
  237. .stats-row {
  238. display: flex;
  239. justify-content: space-between;
  240. margin-bottom: 16rpx;
  241. }
  242. .stat-item {
  243. text-align: center;
  244. flex: 1;
  245. margin: 0 10rpx;
  246. }
  247. .stat-num {
  248. font-size: 36rpx;
  249. font-weight: bold;
  250. margin-bottom: 4rpx;
  251. }
  252. .stat-num.red {
  253. color: #ff3333;
  254. }
  255. .stat-label {
  256. font-size: 24rpx;
  257. color: #666;
  258. }
  259. .stat-item.pink {
  260. background-color: #ffcccc;
  261. border-radius: 8rpx;
  262. padding: 8rpx 0;
  263. }
  264. .stat-item.red {
  265. background-color: #ff9999;
  266. border-radius: 8rpx;
  267. padding: 8rpx 0;
  268. }
  269. .stat-item.orange {
  270. background-color: #ffcc99;
  271. border-radius: 8rpx;
  272. padding: 8rpx 0;
  273. }
  274. .stat-item.green {
  275. background-color: #ccffcc;
  276. border-radius: 8rpx;
  277. padding: 8rpx 0;
  278. }
  279. .task-item {
  280. display: flex;
  281. justify-content: space-between;
  282. align-items: center;
  283. background-color: #fff;
  284. border-radius: 8rpx;
  285. padding: 20rpx;
  286. margin-bottom: 20rpx;
  287. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
  288. }
  289. .task-text {
  290. font-size: 28rpx;
  291. color: #007bff;
  292. }
  293. .task-arrow {
  294. font-size: 32rpx;
  295. color: #999;
  296. }
  297. .empty-area {
  298. display: flex;
  299. flex-direction: column;
  300. align-items: center;
  301. justify-content: center;
  302. margin-top: 100rpx;
  303. }
  304. .empty-icon {
  305. width: 200rpx;
  306. height: 200rpx;
  307. margin-bottom: 20rpx;
  308. }
  309. .empty-text {
  310. font-size: 28rpx;
  311. color: #999;
  312. }
  313. .add-btn {
  314. position: fixed;
  315. bottom: 40rpx;
  316. right: 40rpx;
  317. width: 100rpx;
  318. height: 100rpx;
  319. border-radius: 50%;
  320. background-color: #007bff;
  321. color: #fff;
  322. display: flex;
  323. align-items: center;
  324. justify-content: center;
  325. font-size: 32rpx;
  326. white-space: nowrap;
  327. border: none;
  328. box-shadow: 0 4rpx 12rpx rgba(0, 123, 255, 0.3);
  329. }
  330. </style>