You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

car-manage.vue 8.8KB

2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <template>
  2. <view class="main" :style="{height: height+'px'}">
  3. <view class="createbox">
  4. <view class="createBtn" @click="toPage">
  5. 添加
  6. </view>
  7. </view>
  8. <view class="listbox">
  9. <view class="item-row" v-for="(item,i) in state.listArr" :key="i">
  10. <view class="item-left">
  11. <image :src="`${$imgUrl}/che.png`" mode=""></image>
  12. <view class="content">
  13. <view class="title">车牌号</view>
  14. <view class="desc">{{item.vehiclePlate}}</view>
  15. </view>
  16. </view>
  17. <view class="item-right">
  18. <view class="flag"><text>{{item.status}}</text> </view>
  19. <!-- <view class="title">
  20. 车牌号:{{item.vehiclePlate}}
  21. </view> -->
  22. <view class="btns" v-if="item.status=='未使用'">
  23. <view class="edit" @click="edit(item)">编辑</view>
  24. <view class="del" @click="del(item.vehicleId)">删除</view>
  25. </view>
  26. </view>
  27. </view>
  28. <!-- 暂无数据 -->
  29. <view class="tips">
  30. ~暂无数据了,请添加!~
  31. </view>
  32. </view>
  33. <!-- <view class="item-row">
  34. <view class="item-left">
  35. <view class="title">ETC卡号</view>
  36. <view class="desc">520111111111111111</view>
  37. <view class="title">OBU序列号</view>
  38. <view class="desc">520111111111111111</view>
  39. </view>
  40. <view class="item-right">
  41. <view class="flag"><text>未使用</text> </view>
  42. <view class="title">
  43. 车牌号:贵Z111111
  44. </view>
  45. <view class="btns">
  46. <view class="edit">编辑</view>
  47. <view class="del">删除</view>
  48. </view>
  49. </view>
  50. </view> -->
  51. <!-- <view class="item-row">
  52. <view class="item-left">
  53. <view class="title">行驶证副面</view>
  54. <view class="desc">补传行驶证副面</view>
  55. <view class="flag"><text>拍摄示例</text> </view>
  56. </view>
  57. <view class="item-right">
  58. <view class="empty-node"></view>
  59. <image :src="state.installImg ?? defInstallImg"></image>
  60. </view>
  61. </view> -->
  62. <!-- <view class="btn">
  63. <submit-button @submit="saveHandle" title="保存"></submit-button>
  64. </view> -->
  65. </view>
  66. </template>
  67. <script lang="ts" setup>
  68. import {
  69. reactive
  70. } from "vue";
  71. import {
  72. msg,
  73. navTo
  74. } from '@/utils/utils';
  75. import {
  76. fileURL
  77. } from "@/datas/fileURL.js";
  78. import {
  79. pathToBase64
  80. } from "@/utils/util/imageTool.js";
  81. import {
  82. getItem
  83. } from "@/utils/storage.ts"
  84. import {
  85. selectCarInfo,
  86. delCarInfo
  87. } from "@/utils/network/api.js";
  88. import {
  89. request
  90. } from "@/utils/network/request.js";
  91. import {
  92. stringToJson
  93. } from "@/utils/network/encryption";
  94. import {
  95. onLoad,
  96. onShow
  97. } from "@dcloudio/uni-app";
  98. const height = uni.getSystemInfoSync().windowHeight
  99. const defHeadstockImg = `${fileURL}image/applyCard/car-zhu.png`;
  100. const defInstallImg = `${fileURL}image/applyCard/car-fu.png`;
  101. const toPage = () => {
  102. navTo('/personal-center/setting/car-information/car-create')
  103. }
  104. const data = reactive({
  105. openId: getItem('openId'),
  106. vehicleId: ''
  107. })
  108. const state = reactive({
  109. listArr: []
  110. })
  111. // 获取列表数据
  112. const getDataList = () => {
  113. const options = {
  114. type: 2,
  115. data: data,
  116. method: "POST",
  117. showLoading: true,
  118. };
  119. request(selectCarInfo, options).then((res) => {
  120. const data = stringToJson(res.bizContent);
  121. console.log(data)
  122. state.listArr = data.vehicleManages
  123. });
  124. }
  125. // 删除
  126. const del = (id) => {
  127. wx.showModal({
  128. title: '提示',
  129. content: '是否删除该条车辆信息',
  130. success: function(res) {
  131. if (res.confirm) {
  132. console.log('用户点击确定');
  133. let data = {
  134. vehicleId: id,
  135. openId: getItem('openId')
  136. }
  137. const options = {
  138. type: 2,
  139. data: data,
  140. method: "POST",
  141. showLoading: true,
  142. };
  143. request(delCarInfo, options).then((res) => {
  144. const data = stringToJson(res.bizContent);
  145. console.log(data)
  146. state.listArr = data.vehicleManages
  147. if (data.info == '成功.') {
  148. uni.showToast({
  149. title: "删除成功",
  150. icon: "none"
  151. })
  152. getDataList()
  153. }
  154. });
  155. } else if (res.cancel) {
  156. console.log('用户点击取消');
  157. }
  158. }
  159. });
  160. }
  161. // 编辑
  162. const edit = (item) => {
  163. let data = JSON.stringify(item)
  164. navTo(`/personal-center/setting/car-information/car-change?data=${data}`)
  165. }
  166. onShow(() => {
  167. getDataList()
  168. })
  169. // //选择图片
  170. // const chooseImage = (type: number) => {
  171. // uni.chooseImage({
  172. // count: 1,
  173. // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  174. // //sourceType: ['album','camera'],
  175. // success: function(res) {
  176. // console.log(res.tempFilePaths);
  177. // if (type === 1) {
  178. // state.headstockImg = res.tempFilePaths[0];
  179. // } else {
  180. // state.installImg = res.tempFilePaths[0];
  181. // }
  182. // }
  183. // });
  184. // }
  185. // //下一步
  186. // const saveHandle = () => {
  187. // if (!state.headstockImg || !state.installImg) {
  188. // msg('请按照要求上传图片!');
  189. // return;
  190. // }
  191. // msg('保存成功')
  192. // }
  193. </script>
  194. <style>
  195. page {
  196. background: #F3F3F3;
  197. }
  198. </style>
  199. <style lang="scss" scoped>
  200. .main {
  201. overflow: hidden;
  202. .createbox {
  203. justify-content: flex-end;
  204. display: flex;
  205. padding: 0rpx 30rpx;
  206. margin-top: 20rpx;
  207. .createBtn {
  208. padding: 6rpx 27rpx;
  209. border: 1rpx solid #0A8F8A;
  210. border-radius: 10rpx;
  211. font-size: 30rpx;
  212. background: #D9F8F1;
  213. }
  214. }
  215. .listbox {
  216. overflow: auto;
  217. height: calc(100vh - 90rpx);
  218. .tips {
  219. text-align: center;
  220. font-size: 28rpx;
  221. margin-top: 30rpx;
  222. }
  223. .item-row {
  224. display: flex;
  225. justify-content: space-between;
  226. margin-top: 30rpx;
  227. background: white;
  228. padding: 30rpx;
  229. border-radius: 20rpx;
  230. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  231. margin: 30rpx;
  232. .item-left {
  233. display: flex;
  234. // flex-direction: column;
  235. justify-content: center;
  236. image{
  237. width: 190rpx;
  238. height: 110rpx;
  239. }
  240. .content {
  241. display: flex;
  242. flex-direction: column;
  243. margin-left: 30rpx;
  244. .title {
  245. font-size: 34rpx;
  246. color: #333;
  247. font-weight: bold;
  248. }
  249. .desc {
  250. font-size: 24rpx;
  251. color: #999;
  252. margin: 10rpx 0;
  253. }
  254. }
  255. .flag {
  256. width: 110rpx;
  257. height: 45rpx;
  258. line-height: 42rpx;
  259. color: #0A8F8A;
  260. margin-top: 16rpx;
  261. border-radius: 6rpx;
  262. text-align: center;
  263. font-size: 20rpx;
  264. background: #D9F8F1;
  265. }
  266. }
  267. .item-right {
  268. width: 295rpx;
  269. // height: 188rpx;
  270. position: relative;
  271. image {
  272. position: relative;
  273. z-index: 10;
  274. width: 100%;
  275. height: 188rpx;
  276. }
  277. // &::before {
  278. // content: '';
  279. // position: absolute;
  280. // width: 22rpx;
  281. // height: 22rpx;
  282. // border: 4rpx solid #21BEB1;
  283. // border-bottom: none;
  284. // border-right: none;
  285. // z-index: 0;
  286. // left: -4rpx;
  287. // top: -4rpx;
  288. // }
  289. // &::after {
  290. // content: '';
  291. // position: absolute;
  292. // width: 22rpx;
  293. // height: 22rpx;
  294. // border: 4rpx solid #21BEB1;
  295. // border-top: none;
  296. // border-right: none;
  297. // z-index: 0;
  298. // left: -4rpx;
  299. // bottom: -4rpx;
  300. // }
  301. .flag {
  302. width: 110rpx;
  303. height: 45rpx;
  304. line-height: 42rpx;
  305. color: #0A8F8A;
  306. margin-top: 16rpx;
  307. border-radius: 6rpx;
  308. text-align: center;
  309. font-size: 20rpx;
  310. background: #D9F8F1;
  311. position: relative;
  312. right: -180rpx;
  313. }
  314. .title {
  315. text-align: right;
  316. margin: 20rpx 0;
  317. font-size: 28rpx;
  318. }
  319. .btns {
  320. display: flex;
  321. justify-content: space-around;
  322. align-items: center;
  323. margin-top: 20rpx;
  324. .edit {
  325. padding: 6rpx 27rpx;
  326. border: 1rpx solid #0A8F8A;
  327. border-radius: 30rpx;
  328. font-size: 30rpx;
  329. color: #0A8F8A;
  330. }
  331. .del {
  332. padding: 6rpx 27rpx;
  333. border: 1rpx solid red;
  334. border-radius: 30rpx;
  335. font-size: 30rpx;
  336. color: red;
  337. }
  338. }
  339. }
  340. .empty-node {
  341. position: absolute;
  342. z-index: 0;
  343. width: 100%;
  344. height: 100%;
  345. &::before {
  346. content: '';
  347. position: absolute;
  348. width: 22rpx;
  349. height: 22rpx;
  350. border: 4rpx solid #21BEB1;
  351. border-left: none;
  352. border-bottom: none;
  353. z-index: 0;
  354. right: -4rpx;
  355. top: -4rpx;
  356. }
  357. &::after {
  358. content: '';
  359. position: absolute;
  360. width: 22rpx;
  361. height: 22rpx;
  362. border: 4rpx solid #21BEB1;
  363. border-top: none;
  364. border-left: none;
  365. z-index: 0;
  366. right: -4rpx;
  367. bottom: -4rpx;
  368. }
  369. }
  370. }
  371. }
  372. .hint {
  373. display: flex;
  374. flex-direction: row;
  375. justify-content: center;
  376. font-size: 26rpx;
  377. color: #666666;
  378. padding: 0px 30rpx;
  379. margin-top: 60rpx;
  380. .icon {
  381. width: 36rpx;
  382. height: 36rpx;
  383. margin-right: 10rpx;
  384. }
  385. view {
  386. width: calc(100% - 36rpx);
  387. }
  388. }
  389. .btn {
  390. margin: 470rpx 40rpx 30rpx;
  391. }
  392. }
  393. </style>