index.vue 3.0 KB

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