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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. <template>
  2. <view class="container">
  3. <!-- 主要内容 -->
  4. <view class="content">
  5. <!-- 基本信息 -->
  6. <view class="info-section">
  7. <view class="section-title">基本信息</view>
  8. <!-- 激活类型选择 -->
  9. <view class="activation-type">
  10. <view
  11. :class="['type-item', { active: activationType === 'self' }]"
  12. @click="activationType = 'self'"
  13. >
  14. 本人激活
  15. </view>
  16. <view
  17. :class="['type-item', { active: activationType === 'other' }]"
  18. @click="activationType = 'other'"
  19. >
  20. 非本人激活
  21. </view>
  22. </view>
  23. <!-- 表单字段 -->
  24. <view v-if="activationType === 'other'" class="form-item car-number-row">
  25. <view class="form-label">车牌号</view>
  26. <car-number-input
  27. v-model="formData.carNumber"
  28. @numberInputResult="carNumberInputResult"
  29. inputColor="#ECF1F4"
  30. style="width: 100%;"
  31. />
  32. </view>
  33. <view v-else class="form-item">
  34. <view class="form-label">车牌号</view>
  35. <view class="form-input" @click="selectCarNumber">
  36. <text :class="['input-text', { placeholder: !formData.carNumber }]">
  37. {{ formData.carNumber || '请选择车牌号' }}
  38. </text>
  39. <view class="arrow-down">▼</view>
  40. </view>
  41. </view>
  42. <view class="form-item">
  43. <view class="form-label">车牌颜色</view>
  44. <view class="form-input" @click="selectCarColor">
  45. <text :class="['input-text', { placeholder: !formData.carColor }]">
  46. {{ formData.carColor || '请选择车牌颜色' }}
  47. </text>
  48. <view class="arrow-down">▼</view>
  49. </view>
  50. </view>
  51. <view class="form-item">
  52. <view class="form-label">申请手机号</view>
  53. <input
  54. class="form-input-text"
  55. placeholder="请输入手机号码"
  56. v-model="formData.phoneNumber"
  57. type="number"
  58. maxlength="11"
  59. />
  60. </view>
  61. <!-- 非本人激活时显示验证码 -->
  62. <view v-if="activationType === 'other'" class="form-item">
  63. <view class="form-label">短信验证码</view>
  64. <view class="form-input" style="display:flex;align-items:center;">
  65. <input
  66. class="form-input-text"
  67. placeholder="请输入验证码"
  68. v-model="formData.smsCode"
  69. maxlength="6"
  70. style="flex:1;"
  71. />
  72. <button class="send-code-btn" @click="sendCode" :disabled="waitTime>0">
  73. {{ waitTime > 0 ? waitTime + 's后重试' : '发送验证码' }}
  74. </button>
  75. </view>
  76. </view>
  77. </view>
  78. <!-- 上传照片 -->
  79. <view class="upload-section">
  80. <view class="section-title">上传照片</view>
  81. <!-- 车辆45度照 -->
  82. <view class="picture-wrapper" @click="uploadImage('vehicle')">
  83. <view class="bg1">
  84. <view class="">
  85. <view class="name">上传激活车辆45度照</view>
  86. <view class="value">上传车辆45度角照片</view>
  87. <view class="tip">
  88. <view class="tip-value" @click.stop="showSpec('vehicle')">拍摄规范</view>
  89. </view>
  90. </view>
  91. <image v-if="!formData.vehicleImage" class="icon" :src="`${$imgUrl}issuance/chetou45.png`"
  92. :style="{'--bgimg':`url(${$imgUrl}issuance/bg-border.png)`}">
  93. </image>
  94. <image v-else class="icon" :src="formData.vehicleImage"
  95. :style="{'--bgimg':`url(${$imgUrl}issuance/bg-border.png)`}"></image>
  96. </view>
  97. </view>
  98. <!-- ETC设备安装照 -->
  99. <view class="picture-wrapper" @click="uploadImage('device')">
  100. <view class="bg1">
  101. <view class="">
  102. <view class="name">上传ETC设备安装照</view>
  103. <view class="value">上传ETC设备安装位置照片</view>
  104. <view class="tip">
  105. <view class="tip-value" @click.stop="showSpec('device')">拍摄规范</view>
  106. </view>
  107. </view>
  108. <image v-if="!formData.deviceImage" class="icon" :src="`${$imgUrl}issuance/device.png`"
  109. :style="{'--bgimg':`url(${$imgUrl}issuance/bg-border.png)`}">
  110. </image>
  111. <image v-else class="icon" :src="formData.deviceImage"
  112. :style="{'--bgimg':`url(${$imgUrl}issuance/bg-border.png)`}"></image>
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. <!-- 底部按钮 -->
  118. <view class="bottom-button" @click="nextStep">
  119. 下一步
  120. </view>
  121. </view>
  122. </template>
  123. <script setup lang="ts">
  124. import { ref, reactive, onMounted, onUnmounted } from 'vue'
  125. import { onLoad } from '@dcloudio/uni-app'
  126. import carNumberInput from './components/car-number-input.vue'
  127. // 响应式数据
  128. const statusBarHeight = ref(0)
  129. const barHeight = ref(0)
  130. const activationType = ref('self') // 'self' 本人激活, 'other' 非本人激活
  131. const waitTime = ref(0)
  132. let timer: any = null
  133. const formData = reactive({
  134. carNumber: '',
  135. carColor: '',
  136. phoneNumber: '',
  137. vehicleImage: '',
  138. deviceImage: '',
  139. smsCode: ''
  140. })
  141. // 页面加载
  142. onLoad(() => {
  143. getSystemInfo()
  144. })
  145. // 获取系统信息
  146. const getSystemInfo = () => {
  147. const systemInfo = uni.getSystemInfoSync()
  148. statusBarHeight.value = systemInfo.statusBarHeight || 0
  149. const { top, height } = uni.getMenuButtonBoundingClientRect()
  150. barHeight.value = height ? height + (top - statusBarHeight.value) * 2 : 38
  151. }
  152. // 返回上一页
  153. const goBack = () => {
  154. uni.navigateBack()
  155. }
  156. // 选择车牌号
  157. const selectCarNumber = () => {
  158. // 这里可以调用车牌号选择组件
  159. uni.showToast({
  160. title: '车牌号选择功能',
  161. icon: 'none'
  162. })
  163. }
  164. // 选择车牌颜色
  165. const selectCarColor = () => {
  166. uni.showActionSheet({
  167. itemList: ['蓝色', '绿色', '黄色', '白色', '黑色'],
  168. success: (res) => {
  169. const colors = ['蓝色', '绿色', '黄色', '白色', '黑色']
  170. formData.carColor = colors[res.tapIndex]
  171. }
  172. })
  173. }
  174. // 上传图片
  175. const uploadImage = (type: 'vehicle' | 'device') => {
  176. uni.chooseImage({
  177. count: 1, //只能选取一张照片
  178. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  179. sourceType: ["camera", "album"], //从相册选择
  180. success: function (res) {
  181. // 这里可以添加文件上传逻辑
  182. const tempFilePath = res.tempFilePaths[0]
  183. if (type === 'vehicle') {
  184. formData.vehicleImage = tempFilePath
  185. } else {
  186. formData.deviceImage = tempFilePath
  187. }
  188. }
  189. })
  190. }
  191. // 显示拍摄规范
  192. const showSpec = (type: 'vehicle' | 'device') => {
  193. const title = type === 'vehicle' ? '车辆45度照拍摄规范' : 'ETC设备安装照拍摄规范'
  194. const content = type === 'vehicle'
  195. ? '请从车辆前45度角拍摄,确保车牌清晰可见,车辆完整入镜。'
  196. : '请拍摄ETC设备安装位置,确保设备清晰可见,安装牢固。'
  197. uni.showModal({
  198. title,
  199. content,
  200. showCancel: false
  201. })
  202. }
  203. // 发送验证码
  204. const sendCode = () => {
  205. if (!/^1[3-9]\d{9}$/.test(formData.phoneNumber)) {
  206. uni.showToast({ title: '请输入正确手机号', icon: 'none' })
  207. return
  208. }
  209. // 这里调用后端发送验证码接口
  210. uni.showToast({ title: '验证码已发送', icon: 'success' })
  211. waitTime.value = 60
  212. timer = setInterval(() => {
  213. waitTime.value--
  214. if (waitTime.value <= 0) clearInterval(timer)
  215. }, 1000)
  216. }
  217. onUnmounted(() => { if (timer) clearInterval(timer) })
  218. const carNumberInputResult = (val: string) => {
  219. formData.carNumber = val;
  220. };
  221. // 下一步
  222. const nextStep = () => {
  223. // 表单验证
  224. if (!formData.carNumber) {
  225. uni.showToast({
  226. title: '请选择车牌号',
  227. icon: 'none'
  228. })
  229. return
  230. }
  231. if (!formData.carColor) {
  232. uni.showToast({
  233. title: '请选择车牌颜色',
  234. icon: 'none'
  235. })
  236. return
  237. }
  238. if (!formData.phoneNumber) {
  239. uni.showToast({
  240. title: '请输入手机号码',
  241. icon: 'none'
  242. })
  243. return
  244. }
  245. if (!/^1[3-9]\d{9}$/.test(formData.phoneNumber)) {
  246. uni.showToast({
  247. title: '请输入正确的手机号码',
  248. icon: 'none'
  249. })
  250. return
  251. }
  252. if (!formData.vehicleImage) {
  253. uni.showToast({
  254. title: '请上传车辆45度照',
  255. icon: 'none'
  256. })
  257. return
  258. }
  259. if (!formData.deviceImage) {
  260. uni.showToast({
  261. title: '请上传ETC设备安装照',
  262. icon: 'none'
  263. })
  264. return
  265. }
  266. // 提交数据
  267. console.log('表单数据:', formData)
  268. uni.showToast({
  269. title: '提交成功',
  270. icon: 'success'
  271. })
  272. }
  273. </script>
  274. <style lang="scss" scoped>
  275. .container {
  276. min-height: 100vh;
  277. background-color: #f2f5f7;
  278. }
  279. .nav-bar {
  280. background-color: #fff;
  281. position: fixed;
  282. top: 0;
  283. left: 0;
  284. right: 0;
  285. z-index: 100;
  286. .nav-content {
  287. display: flex;
  288. align-items: center;
  289. justify-content: space-between;
  290. padding: 0 30rpx;
  291. .nav-left, .nav-right {
  292. width: 60rpx;
  293. height: 60rpx;
  294. display: flex;
  295. align-items: center;
  296. justify-content: center;
  297. .back-icon {
  298. width: 40rpx;
  299. height: 40rpx;
  300. }
  301. .more-dots {
  302. display: flex;
  303. flex-direction: column;
  304. gap: 4rpx;
  305. .dot {
  306. width: 6rpx;
  307. height: 6rpx;
  308. background-color: #333;
  309. border-radius: 50%;
  310. }
  311. }
  312. }
  313. .nav-title {
  314. font-size: 36rpx;
  315. font-weight: bold;
  316. color: #333;
  317. }
  318. }
  319. }
  320. .content {
  321. padding: 60rpx 30rpx 120rpx;
  322. }
  323. .info-section, .upload-section {
  324. background-color: #fff;
  325. border-radius: 20rpx;
  326. padding: 30rpx;
  327. margin-bottom: 30rpx;
  328. .section-title {
  329. font-size: 32rpx;
  330. font-weight: bold;
  331. color: #333;
  332. margin-bottom: 30rpx;
  333. }
  334. }
  335. .activation-type {
  336. display: flex;
  337. background-color: #f5f5f5;
  338. border-radius: 10rpx;
  339. padding: 4rpx;
  340. margin-bottom: 30rpx;
  341. .type-item {
  342. flex: 1;
  343. text-align: center;
  344. padding: 20rpx 0;
  345. border-radius: 8rpx;
  346. font-size: 28rpx;
  347. color: #666;
  348. transition: all 0.3s;
  349. &.active {
  350. background-color: #c2a75f;
  351. color: #fff;
  352. }
  353. }
  354. }
  355. .form-item {
  356. display: flex;
  357. align-items: center;
  358. margin-bottom: 30rpx;
  359. .form-label {
  360. width: 160rpx;
  361. font-size: 28rpx;
  362. color: #333;
  363. }
  364. .form-input {
  365. flex: 1;
  366. display: flex;
  367. align-items: center;
  368. justify-content: space-between;
  369. height: 80rpx;
  370. padding: 0 20rpx;
  371. background-color: #f8f8f8;
  372. border-radius: 10rpx;
  373. .input-text {
  374. font-size: 28rpx;
  375. color: #333;
  376. &.placeholder {
  377. color: #999;
  378. }
  379. }
  380. .arrow-down {
  381. font-size: 20rpx;
  382. color: #999;
  383. }
  384. }
  385. .form-input-text {
  386. flex: 1;
  387. height: 80rpx;
  388. padding: 0 20rpx;
  389. background-color: #f8f8f8;
  390. border-radius: 10rpx;
  391. font-size: 28rpx;
  392. color: #333;
  393. }
  394. }
  395. .car-number-row {
  396. flex-direction: column;
  397. align-items: flex-start;
  398. .form-label {
  399. margin-bottom: 12rpx;
  400. }
  401. :deep(.car-number-input-root) {
  402. width: 100%;
  403. justify-content: flex-start;
  404. }
  405. }
  406. .picture-wrapper {
  407. margin-top: 30rpx;
  408. .bg1 {
  409. background: #F5F9FB;
  410. border-radius: 10rpx;
  411. padding: 40rpx 30rpx;
  412. display: flex;
  413. justify-content: space-between;
  414. .name {
  415. padding-top: 30rpx;
  416. font-size: 32rpx;
  417. font-family: SourceHanSansSC, SourceHanSansSC;
  418. font-weight: 500;
  419. color: #111;
  420. line-height: 34rpx;
  421. }
  422. .value {
  423. margin-top: 20rpx;
  424. font-size: 22rpx;
  425. font-family: SourceHanSansSC, SourceHanSansSC;
  426. font-weight: 400;
  427. color: #999999;
  428. line-height: 24rpx;
  429. }
  430. .tip {
  431. margin-top: 20rpx;
  432. text-align: center;
  433. width: 100rpx;
  434. height: 30rpx;
  435. border-radius: 6rpx;
  436. border: 1rpx solid #CCB375;
  437. .tip-value {
  438. font-size: 20rpx;
  439. font-family: Microsoft YaHei;
  440. font-weight: 400;
  441. color: #CCB375;
  442. line-height: 30rpx;
  443. opacity: 1;
  444. }
  445. }
  446. }
  447. .icon {
  448. width: 304rpx;
  449. height: 190rpx;
  450. background-image: var(--bgimg);
  451. background-size: 100% 100%;
  452. background-repeat: no-repeat;
  453. }
  454. }
  455. .bottom-button {
  456. position: fixed;
  457. bottom: 0;
  458. left: 0;
  459. right: 0;
  460. height: 100rpx;
  461. background-color: #133850;
  462. color: #fff;
  463. font-size: 32rpx;
  464. font-weight: bold;
  465. display: flex;
  466. align-items: center;
  467. justify-content: center;
  468. }
  469. .send-code-btn {
  470. margin-left: 16rpx;
  471. background: #f8f4e7;
  472. color: #ccb375;
  473. border: 1px solid #ccb375;
  474. border-radius: 10rpx;
  475. font-size: 24rpx;
  476. height: 60rpx;
  477. line-height: 60rpx;
  478. padding: 0 20rpx;
  479. }
  480. </style>