anomaly.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <template>
  2. <view class="anomaly-container">
  3. <!-- 内容区域 -->
  4. <scroll-view scroll-y class="anomaly-scroll">
  5. <!-- 异常类型 -->
  6. <view class="ano-card">
  7. <view class="ano-section-title">
  8. <view class="ano-title-bar"></view>
  9. <text class="ano-title-text">异常类型</text>
  10. </view>
  11. <view class="ano-type-row" @click="openTypeSheet">
  12. <text class="ano-type-val" :class="{ 'placeholder': !selectedType }">
  13. {{ selectedType || '其他异常' }}
  14. </text>
  15. <image class="ano-right-arrow" src="/static/icons/right_arrow_orange.svg"></image>
  16. </view>
  17. </view>
  18. <!-- 异常描述 -->
  19. <view class="ano-card">
  20. <view class="ano-section-title">
  21. <view class="ano-title-bar"></view>
  22. <text class="ano-title-text">异常描述</text>
  23. </view>
  24. <textarea
  25. class="ano-textarea"
  26. v-model="anomalyDesc"
  27. placeholder="请详细描述现场异常情况..."
  28. placeholder-style="color:#ccc; font-size:28rpx;"
  29. maxlength="500"
  30. ></textarea>
  31. </view>
  32. <!-- 现场照片 -->
  33. <view class="ano-card">
  34. <view class="ano-section-title">
  35. <view class="ano-title-bar"></view>
  36. <text class="ano-title-text">现场照片 (必填,最多5张)</text>
  37. </view>
  38. <view class="ano-photo-grid">
  39. <!-- 已上传图片 -->
  40. <view class="ano-photo-item" v-for="(img, idx) in photoList" :key="idx">
  41. <image class="ano-photo-preview" :src="img" mode="aspectFill"></image>
  42. <view class="ano-photo-del" @click="removePhoto(idx)">×</view>
  43. </view>
  44. <!-- 添加按钮 -->
  45. <view class="ano-photo-add" @click="choosePhoto" v-if="photoList.length < 5">
  46. <image class="ano-add-icon" src="/static/icons/camera_grey.svg"></image>
  47. <text class="ano-add-text">上传</text>
  48. </view>
  49. </view>
  50. </view>
  51. <!-- 底部留空供按钮 -->
  52. <view style="height: 160rpx;"></view>
  53. </scroll-view>
  54. <!-- 底部提交按钮 -->
  55. <view class="ano-footer">
  56. <button class="ano-submit-btn" @click="submitAnomaly">提交上报</button>
  57. </view>
  58. <!-- 异常类型选择器 -->
  59. <view class="ano-sheet-mask" v-if="showTypeSheet" @click="closeTypeSheet">
  60. <view class="ano-sheet" @click.stop>
  61. <text class="ano-sheet-title">选择异常类型</text>
  62. <scroll-view scroll-y class="ano-sheet-list">
  63. <view
  64. class="ano-sheet-item"
  65. v-for="(type, idx) in anomalyTypes"
  66. :key="idx"
  67. @click="selectType(type)"
  68. >
  69. <text :class="['ano-sheet-item-text', { 'selected': selectedType === type }]">{{ type }}</text>
  70. <image
  71. v-if="selectedType === type"
  72. class="ano-check-icon"
  73. src="/static/icons/right_arrow_orange.svg"
  74. ></image>
  75. </view>
  76. </scroll-view>
  77. <view class="ano-sheet-cancel" @click="closeTypeSheet">取消</view>
  78. </view>
  79. </view>
  80. </view>
  81. </template>
  82. <script>
  83. export default {
  84. data() {
  85. return {
  86. // 已选异常类型
  87. selectedType: '其他异常',
  88. // 异常描述
  89. anomalyDesc: '',
  90. // 照片列表
  91. photoList: [],
  92. // 是否显示类型选择器
  93. showTypeSheet: false,
  94. // 异常类型列表
  95. anomalyTypes: [
  96. '无法联系用户',
  97. '地址错误',
  98. '宠物身体异常',
  99. '设施损坏',
  100. '用户拒收',
  101. '其他异常'
  102. ]
  103. };
  104. },
  105. methods: {
  106. // 打开类型选择器
  107. openTypeSheet() {
  108. this.showTypeSheet = true;
  109. },
  110. // 关闭类型选择器
  111. closeTypeSheet() {
  112. this.showTypeSheet = false;
  113. },
  114. // 选择异常类型
  115. selectType(type) {
  116. this.selectedType = type;
  117. this.closeTypeSheet();
  118. },
  119. // 选择照片
  120. choosePhoto() {
  121. uni.chooseImage({
  122. count: 5 - this.photoList.length,
  123. sizeType: ['compressed'],
  124. sourceType: ['album', 'camera'],
  125. success: (res) => {
  126. this.photoList = [...this.photoList, ...res.tempFilePaths].slice(0, 5);
  127. }
  128. });
  129. },
  130. // 删除照片
  131. removePhoto(idx) {
  132. this.photoList.splice(idx, 1);
  133. },
  134. // 提交上报
  135. submitAnomaly() {
  136. if (!this.selectedType) {
  137. uni.showToast({ title: '请选择异常类型', icon: 'none' });
  138. return;
  139. }
  140. if (this.photoList.length === 0) {
  141. uni.showToast({ title: '请上传现场照片', icon: 'none' });
  142. return;
  143. }
  144. // 模拟提交
  145. uni.showLoading({ title: '提交中...' });
  146. setTimeout(() => {
  147. uni.hideLoading();
  148. uni.showToast({ title: '上报成功', icon: 'success' });
  149. setTimeout(() => {
  150. uni.navigateBack();
  151. }, 1500);
  152. }, 1000);
  153. }
  154. }
  155. };
  156. </script>
  157. <style>
  158. /* 页面背景 */
  159. .anomaly-container {
  160. min-height: 100vh;
  161. background-color: #F7F8FA;
  162. display: flex;
  163. flex-direction: column;
  164. }
  165. .anomaly-scroll {
  166. flex: 1;
  167. padding: 20rpx 30rpx 0;
  168. box-sizing: border-box;
  169. }
  170. /* 内容卡片 */
  171. .ano-card {
  172. background-color: #fff;
  173. border-radius: 16rpx;
  174. padding: 30rpx;
  175. margin-bottom: 20rpx;
  176. }
  177. /* 节标题 */
  178. .ano-section-title {
  179. display: flex;
  180. align-items: center;
  181. margin-bottom: 20rpx;
  182. }
  183. .ano-title-bar {
  184. width: 6rpx;
  185. height: 30rpx;
  186. background-color: #FF9800;
  187. border-radius: 3rpx;
  188. margin-right: 12rpx;
  189. }
  190. .ano-title-text {
  191. font-size: 30rpx;
  192. font-weight: bold;
  193. color: #333;
  194. }
  195. /* 异常类型行 */
  196. .ano-type-row {
  197. display: flex;
  198. align-items: center;
  199. justify-content: space-between;
  200. padding: 10rpx 0;
  201. }
  202. .ano-type-val {
  203. font-size: 28rpx;
  204. color: #333;
  205. flex: 1;
  206. }
  207. .ano-type-val.placeholder {
  208. color: #ccc;
  209. }
  210. .ano-right-arrow {
  211. width: 20rpx;
  212. height: 20rpx;
  213. }
  214. /* 描述文本框 */
  215. .ano-textarea {
  216. width: 100%;
  217. min-height: 200rpx;
  218. font-size: 28rpx;
  219. color: #333;
  220. line-height: 1.6;
  221. background-color: #FAFAFA;
  222. border-radius: 10rpx;
  223. padding: 20rpx;
  224. box-sizing: border-box;
  225. }
  226. /* 照片网格 */
  227. .ano-photo-grid {
  228. display: flex;
  229. flex-wrap: wrap;
  230. gap: 16rpx;
  231. }
  232. .ano-photo-item {
  233. width: 150rpx;
  234. height: 150rpx;
  235. border-radius: 12rpx;
  236. position: relative;
  237. overflow: hidden;
  238. }
  239. .ano-photo-preview {
  240. width: 100%;
  241. height: 100%;
  242. }
  243. .ano-photo-del {
  244. position: absolute;
  245. top: 4rpx;
  246. right: 4rpx;
  247. width: 36rpx;
  248. height: 36rpx;
  249. line-height: 32rpx;
  250. text-align: center;
  251. background-color: rgba(0, 0, 0, 0.5);
  252. color: #fff;
  253. border-radius: 50%;
  254. font-size: 28rpx;
  255. }
  256. .ano-photo-add {
  257. width: 150rpx;
  258. height: 150rpx;
  259. border: 2rpx dashed #E0E0E0;
  260. border-radius: 12rpx;
  261. background-color: #FAFAFA;
  262. display: flex;
  263. flex-direction: column;
  264. justify-content: center;
  265. align-items: center;
  266. }
  267. .ano-add-icon {
  268. width: 50rpx;
  269. height: 50rpx;
  270. margin-bottom: 10rpx;
  271. opacity: 0.5;
  272. }
  273. .ano-add-text {
  274. font-size: 24rpx;
  275. color: #999;
  276. }
  277. /* 底部提交 */
  278. .ano-footer {
  279. position: fixed;
  280. bottom: 0;
  281. left: 0;
  282. width: 100%;
  283. background-color: #FF9800;
  284. padding: 20rpx 40rpx;
  285. padding-bottom: constant(safe-area-inset-bottom);
  286. padding-bottom: env(safe-area-inset-bottom);
  287. box-sizing: border-box;
  288. }
  289. .ano-submit-btn {
  290. width: 100%;
  291. height: 90rpx;
  292. line-height: 90rpx;
  293. background: linear-gradient(90deg, #FF9800 0%, #FF5722 100%);
  294. color: #fff;
  295. font-size: 32rpx;
  296. font-weight: bold;
  297. border-radius: 45rpx;
  298. border: none;
  299. }
  300. .ano-submit-btn::after {
  301. border: none;
  302. }
  303. /* 异常类型选择器 */
  304. .ano-sheet-mask {
  305. position: fixed;
  306. top: 0;
  307. left: 0;
  308. width: 100%;
  309. height: 100%;
  310. background-color: rgba(0, 0, 0, 0.5);
  311. z-index: 999;
  312. display: flex;
  313. align-items: flex-end;
  314. }
  315. .ano-sheet {
  316. width: 100%;
  317. background-color: #fff;
  318. border-radius: 24rpx 24rpx 0 0;
  319. padding-bottom: constant(safe-area-inset-bottom);
  320. padding-bottom: env(safe-area-inset-bottom);
  321. }
  322. .ano-sheet-title {
  323. display: block;
  324. text-align: center;
  325. font-size: 28rpx;
  326. color: #999;
  327. padding: 30rpx 0 20rpx;
  328. border-bottom: 1px solid #f5f5f5;
  329. }
  330. .ano-sheet-list {
  331. max-height: 60vh;
  332. }
  333. .ano-sheet-item {
  334. display: flex;
  335. align-items: center;
  336. justify-content: space-between;
  337. padding: 30rpx 40rpx;
  338. border-bottom: 1px solid #f9f9f9;
  339. }
  340. .ano-sheet-item-text {
  341. font-size: 32rpx;
  342. color: #333;
  343. }
  344. .ano-sheet-item-text.selected {
  345. color: #FF9800;
  346. font-weight: bold;
  347. }
  348. .ano-check-icon {
  349. width: 20rpx;
  350. height: 20rpx;
  351. }
  352. .ano-sheet-cancel {
  353. text-align: center;
  354. font-size: 32rpx;
  355. color: #999;
  356. padding: 30rpx 0;
  357. border-top: 16rpx solid #F7F8FA;
  358. }
  359. </style>