addLicensePlates.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <ax-body title="车牌管理">
  3. <view class="body">
  4. <!-- 车牌列表 -->
  5. <view class="plate-list">
  6. <view class="plate-card" v-for="(item, index) in vehicleList" :key="index">
  7. <image class="plate-bg"
  8. src="https://national-motion.oss-cn-beijing.aliyuncs.com/20260318/f0babdfe99ca49c69cf26454f9084107.png"
  9. mode="aspectFill"></image>
  10. <view class="plate-content">
  11. <view class="plate-number">{{ item.licensePlate }}</view>
  12. <view class="plate-actions">
  13. <view class="default-tag" v-if="item.isDefault">默认</view>
  14. <view class="set-default" v-else @click="setDefault(item)">设为默认</view>
  15. <view class="delete-btn" @click="deleteVehicle(item)">
  16. <text class="delete-icon">🗑</text>
  17. <text>删除</text>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <!-- 空状态 -->
  24. <view class="empty-state" v-if="vehicleList.length === 0">
  25. <text>暂无绑定车辆</text>
  26. </view>
  27. <view class="rules-tips">
  28. <view class="tips-title">
  29. 规则说明
  30. </view>
  31. <view class="tips-texts">
  32. <view class="">1.绑定车牌后,将按订单充电时长+30分钟离场时间进行减免停车费;(例如:充电时长60分钟,系统自动延长30分钟离场时间,即离场时减免90分钟停车费)</view>
  33. <view class="">2.绑定多个车牌时,请在充电开始前,确认充电车辆已设为当前默认充电车辆后,再开始充电,否则无法进行减免停车费。</view>
  34. <view class="">3.车牌绑定错误或默认车牌未对应现场充电车辆导致无法减免停车费,因此产生的一切损失与本平台无关。</view>
  35. </view>
  36. <view style="height: 30rpx;"></view>
  37. </view>
  38. </view>
  39. <!-- 底部添加按钮 -->
  40. <view class="bottom-btn-wrap">
  41. <view class="add-btn" @click="openAddPopup">添加车辆</view>
  42. </view>
  43. <!-- 添加车辆弹窗 -->
  44. <ax-popup ref="addPopup" position="bottom" maskType="black" maskClose @closed="onPopupClosed">
  45. <view class="popup-content">
  46. <view class="popup-header">
  47. <view class="popup-title">添加车辆</view>
  48. <view class="popup-close" @click="closeAddPopup">×</view>
  49. </view>
  50. <view class="popup-body">
  51. <view class="form-tip">请点击下方输入框输入车牌号</view>
  52. <best-plate-keyboard v-model="newPlateNumber" placeholder="点击输入车牌号" @complete="onPlateComplete" />
  53. </view>
  54. </view>
  55. </ax-popup>
  56. </ax-body>
  57. </template>
  58. <script>
  59. import BestPlateKeyboard from '../components/best-plate-keyboard/index.vue'
  60. export default {
  61. components: {
  62. BestPlateKeyboard
  63. },
  64. data() {
  65. return {
  66. vehicleList: [],
  67. newPlateNumber: ''
  68. }
  69. },
  70. onShow() {
  71. this.getVehicleList();
  72. },
  73. methods: {
  74. // 获取车辆列表
  75. getVehicleList() {
  76. this.$api.base('get', '/applet/v1/vehicle/list', {}, {
  77. error: false
  78. }).then(res => {
  79. if (res && res.data) {
  80. this.vehicleList = Array.isArray(res.data) ? res.data : [];
  81. }
  82. }).catch(() => {
  83. this.vehicleList = [];
  84. });
  85. },
  86. // 设为默认
  87. setDefault(item) {
  88. this.$app.popup.confirm('是否确认操作?','提示').then(confirm=>{
  89. if(confirm){
  90. this.$api.base('put', `/applet/v1/vehicle/default/${item.id}`, {}).then(res => {
  91. if (res.code === '00000') {
  92. setTimeout(()=>{
  93. uni.showToast({
  94. title: '设置成功',
  95. icon: 'success'
  96. });
  97. },500)
  98. this.getVehicleList();
  99. }
  100. });
  101. }
  102. })
  103. },
  104. // 删除车辆
  105. deleteVehicle(item) {
  106. this.$app.popup.confirm('确认删除该车辆?', '提示').then(confirm => {
  107. if (confirm) {
  108. this.$api.base('delete', `/applet/v1/vehicle/${item.id}`, {}).then(res => {
  109. if (res.code === '00000') {
  110. setTimeout(()=>{
  111. uni.showToast({
  112. title: '删除成功',
  113. icon: 'success'
  114. });
  115. },500)
  116. this.getVehicleList();
  117. }
  118. });
  119. }
  120. });
  121. },
  122. // 打开添加弹窗
  123. openAddPopup() {
  124. this.$app.url.goto('/subPackages/other/platePage/index');
  125. // this.newPlateNumber = ''
  126. // this.$refs.addPopup.open()
  127. },
  128. // 关闭添加弹窗
  129. closeAddPopup() {
  130. this.$refs.addPopup.close()
  131. },
  132. // 弹窗关闭后
  133. onPopupClosed() {
  134. this.newPlateNumber = ''
  135. },
  136. // 车牌输入完成
  137. onPlateComplete(plateNumber) {
  138. if (!plateNumber) {
  139. return
  140. }
  141. const userInfo = this.$app.storage.get('USER_INFO') || {}
  142. // 如果没有车辆,新添加的默认设为默认车辆
  143. const isDefault = this.vehicleList.length === 0 ? 1 : 0
  144. this.$api.base('post', '/applet/v1/vehicle', {
  145. userId: userInfo.appletUserId || '',
  146. licensePlate: plateNumber,
  147. isDefault: isDefault // 是否默认车辆(0-否 1-是)
  148. }).then(res => {
  149. if (res.code === '00000') {
  150. setTimeout(()=>{
  151. uni.showToast({ title: '添加成功', icon: 'success' })
  152. },100)
  153. this.closeAddPopup()
  154. this.getVehicleList()
  155. setTimeout(()=>{
  156. uni.navigateBack()
  157. },500)
  158. }
  159. })
  160. },
  161. }
  162. }
  163. </script>
  164. <style scoped>
  165. page {
  166. background-color: #F5F7FB;
  167. }
  168. .body {
  169. padding: 20rpx;
  170. padding-bottom: 140rpx;
  171. }
  172. /* 车牌列表 */
  173. .plate-list {
  174. display: flex;
  175. flex-direction: column;
  176. gap: 20rpx;
  177. }
  178. .plate-card {
  179. position: relative;
  180. width: 100%;
  181. height: 180rpx;
  182. border-radius: 16rpx;
  183. overflow: hidden;
  184. }
  185. .plate-bg {
  186. position: absolute;
  187. top: 0;
  188. left: 0;
  189. width: 100%;
  190. height: 100%;
  191. }
  192. .plate-content {
  193. position: relative;
  194. z-index: 1;
  195. display: flex;
  196. align-items: center;
  197. justify-content: space-between;
  198. height: 100%;
  199. padding: 0 30rpx;
  200. }
  201. .plate-number {
  202. font-size: 40rpx;
  203. font-weight: bold;
  204. color: #2b303a;
  205. letter-spacing: 4rpx;
  206. }
  207. .plate-actions {
  208. display: flex;
  209. flex-direction: column;
  210. align-items: flex-end;
  211. gap: 16rpx;
  212. }
  213. .default-tag {
  214. position: absolute;
  215. right: 0;
  216. top: 0;
  217. border-radius: 0rpx 16rpx 0rpx 16rpx;
  218. padding: 8rpx 24rpx;
  219. background: linear-gradient(135deg, #47aeff 0%, #3eb6f8 100%);
  220. font-size: 24rpx;
  221. color: #fff;
  222. }
  223. .set-default {
  224. font-size: 26rpx;
  225. color: #666;
  226. }
  227. .delete-btn {
  228. display: flex;
  229. align-items: center;
  230. gap: 8rpx;
  231. font-size: 26rpx;
  232. color: #666;
  233. }
  234. .delete-icon {
  235. font-size: 28rpx;
  236. }
  237. /* 空状态 */
  238. .empty-state {
  239. display: flex;
  240. align-items: center;
  241. justify-content: center;
  242. padding: 200rpx 0;
  243. font-size: 28rpx;
  244. color: #999;
  245. border-radius: 16rpx;
  246. background: linear-gradient( 180deg, #C7FFFD 0%, #F2FFFF 100%);
  247. }
  248. .rules-tips{
  249. margin-top: 20rpx;
  250. }
  251. .tips-title{
  252. font-size: 28rpx;
  253. font-weight: bold;
  254. }
  255. .tips-texts{
  256. font-size: 26rpx;
  257. color: #333;
  258. }
  259. /* 弹窗样式 */
  260. .popup-content {
  261. width: 100vw;
  262. background: #fff;
  263. border-radius: 32rpx 32rpx 0 0;
  264. overflow: hidden;
  265. }
  266. .popup-header {
  267. display: flex;
  268. align-items: center;
  269. justify-content: space-between;
  270. padding: 30rpx;
  271. border-bottom: 1rpx solid #f0f0f0;
  272. }
  273. .popup-title {
  274. font-size: 32rpx;
  275. font-weight: 600;
  276. color: #333;
  277. }
  278. .popup-close {
  279. width: 48rpx;
  280. height: 48rpx;
  281. display: flex;
  282. align-items: center;
  283. justify-content: center;
  284. font-size: 40rpx;
  285. color: #999;
  286. }
  287. .popup-body {
  288. padding: 30rpx;
  289. padding-bottom: calc(30rpx + env(safe-area-inset-bottom));
  290. }
  291. .form-tip {
  292. font-size: 26rpx;
  293. color: #999;
  294. margin-bottom: 20rpx;
  295. }
  296. /* 底部按钮 */
  297. .bottom-btn-wrap {
  298. position: fixed;
  299. left: 0;
  300. right: 0;
  301. bottom: 0;
  302. padding: 20rpx 30rpx;
  303. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  304. background: #fff;
  305. box-shadow: 0 -2rpx 20rpx rgba(0, 0, 0, 0.05);
  306. }
  307. .add-btn {
  308. display: flex;
  309. align-items: center;
  310. justify-content: center;
  311. height: 96rpx;
  312. background: linear-gradient(to right, #8ff8fb, #47aeff);
  313. border-radius: 48rpx;
  314. font-size: 32rpx;
  315. color: #2b303a;
  316. font-weight: 500;
  317. }
  318. </style>