index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <view class="">
  3. <van-popup :show="idCardShow" round>
  4. <view class="idCard">
  5. <van-divider contentPosition="center">绑定身份证信息</van-divider>
  6. <van-cell-group>
  7. <van-field :value="idCard" @change='idCardput' label="身份证" maxlength='18' placeholder="请输入身份证号" />
  8. <van-field :value="password" @change='passwordput' type="password" label="密码" placeholder="请输入密码" />
  9. <van-cell title="归属驾校地区" :value="area" @click='popup=!popup' />
  10. </van-cell-group>
  11. <view class="btn-box">
  12. <van-button @click='idCardShow=!idCardShow' type="default">取消绑定</van-button>
  13. <van-button @click='submitBinding' type="info" :loading='loading' loading-text="绑定中..">确认绑定</van-button>
  14. </view>
  15. </view>
  16. </van-popup>
  17. <van-popup :show="popup" position="bottom">
  18. <van-area :columns-placeholder="['请选择', '请选择']" value="35" @cancel='popup=!popup' @confirm='popup=!popup' :area-list="areaList"
  19. @change='regionSelection' columns-num='2' />
  20. </van-popup>
  21. </view>
  22. </template>
  23. <script>
  24. import md5 from 'crypto-js/md5'
  25. import {
  26. login,
  27. getInfo,
  28. bindUserCard
  29. } from '@/api/login.js'
  30. export default {
  31. data() {
  32. return {
  33. loading: false,
  34. idCardShow: true,
  35. popup: false,
  36. idCard: null,
  37. password: null,
  38. areaCode: null,
  39. area: "请点击选择地区",
  40. areaList: {
  41. province_list: {
  42. 35: '福建省',
  43. },
  44. city_list: {
  45. 3501: '福州市',
  46. 3502: '厦门市',
  47. 3503: '莆田市',
  48. 3504: '三明市',
  49. 3505: '泉州市',
  50. 3506: '漳州市',
  51. 3507: '南平市',
  52. 3508: '龙岩市',
  53. 3509: '宁德市',
  54. }
  55. }
  56. }
  57. },
  58. methods: {
  59. regionSelection(e) {
  60. console.log(e)
  61. this.area = `${e.detail.values[0].name} ${e.detail.values[1].name}`
  62. this.areaCode = e.detail.values[1].code
  63. },
  64. idCardput(e) {
  65. this.idCard = e.detail
  66. },
  67. passwordput(e) {
  68. this.password = e.detail
  69. },
  70. submitBinding() {
  71. console.log(this.areaCode, this.idCard, this.password)
  72. this.loading = true
  73. bindUserCard({
  74. city: this.areaCode,
  75. logincode: this.idCard,
  76. password: md5(this.password).toString()
  77. }).then((res) => {
  78. if (res.code == 200) {
  79. Toast.success('绑定成功');
  80. this.idCardShow = false
  81. } else if (res.code == 502) {
  82. Toast.fail(res.msg);
  83. } else {
  84. Toast.fail('系统内部错误');
  85. }
  86. this.loading = false
  87. })
  88. },
  89. }
  90. }
  91. </script>
  92. <style>
  93. .idCard {
  94. width: 600rpx;
  95. padding: 30rpx;
  96. margin: auto;
  97. display: flex;
  98. flex-direction: column;
  99. justify-content: center;
  100. align-items: center;
  101. }
  102. </style>