myInfo.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <view class="my-info-page">
  3. <!-- 导航区域 -->
  4. <customNavbarVue title="个人信息" :show-back-btn="true" @back="handleBack"></customNavbarVue>
  5. <!-- 姓名 -->
  6. <view class="form-label-input">
  7. <view class="phone-form-label"><text class="form-label-require">*</text>姓名</view>
  8. <input v-model="data.realName" placeholder="请输入姓名" />
  9. <icon :style="{ backgroundImage: 'url(' + data.jtIcon + ')' }"></icon>
  10. </view>
  11. <!-- 证件号 -->
  12. <view class="form-label-input">
  13. <view class="phone-form-label" @click="idCardChange">
  14. <text class="form-label-require">*</text>
  15. <text v-if="data.idtype ==1">身份证号</text>
  16. <text v-if="data.idtype ==2">护照号</text>
  17. <icon @click="idCardChange" class="change-icon"
  18. :style="{ backgroundImage: 'url(' + data.changeIcon + ')' }">切换</icon>
  19. </view>
  20. <input v-model="data.idcard" placeholder="请输入证件号" />
  21. <icon :style="{ backgroundImage: 'url(' + data.jtIcon + ')' }"></icon>
  22. </view>
  23. <view class="form-label-input">
  24. <view class="phone-form-label"><text class="form-label-require"></text>具体地址</view>
  25. <input v-model="data.juzhuDizhi" placeholder="请输入具体地址" />
  26. <icon :style="{ backgroundImage: 'url(' + data.jtIcon + ')' }"></icon>
  27. </view>
  28. <button type="default" class="phone-green-btn info-btn" @click="handleUpdate">修改资料</button>
  29. </view>
  30. </template>
  31. <script setup>
  32. import customNavbarVue from "@/components/custom-navbar/custom-navbar.vue";
  33. import * as myApi from "@/api/kehu.js";
  34. import {getAliyunPolicy} from "@/api/jiazheng.js"
  35. import {ref,reactive} from "vue"
  36. import {onLoad} from "@dcloudio/uni-app"
  37. import cacheManager from '@/utils/cacheManager.js';
  38. const defaultImage1 = ref({
  39. url:'', extname: 'png', name: 'moren.png'
  40. })
  41. const imageStyles = ref({
  42. width: '50rpx',
  43. height: '50rpx',
  44. background: 'red'
  45. });
  46. const data = reactive({
  47. from: 'shouye', // my | kaoshi | shouye
  48. realName: '',
  49. idcard: '',
  50. userId: null,
  51. jtIcon: '',
  52. changeIcon: '',
  53. juzhuDizhi: '',
  54. idtype: 1,
  55. })
  56. onLoad((options) => {
  57. data.from = options.from || 'shouye';
  58. data.jtIcon= cacheManager.get('projectImg').nav_bar_jt_bottom;
  59. data.changeIcon = cacheManager.get('projectImg').change_icon;
  60. initPage();
  61. })
  62. function idCardChange() {
  63. data.idtype = data.idtype == 1 ? 2 : 1;
  64. }
  65. function handleUpdate() {
  66. let arr = [];
  67. if (!data.realName) {
  68. arr.push('姓名');
  69. }
  70. if (!data.idcard) {
  71. arr.push('证件号');
  72. }
  73. if (!data.realName ||!data.idcard) {
  74. uni.showToast({
  75. icon: 'none',
  76. title: `请完善${arr.join('、')}信息!`
  77. })
  78. return;
  79. }
  80. const opt = {
  81. juzhuDizhi: data.juzhuDizhi,
  82. idtype: data.idtype,
  83. idcard: data.idcard,
  84. realName: data.realName,
  85. userId: data.userId,
  86. }
  87. myApi.getKehuUpdate(opt).then(res => {
  88. if (res.data) {
  89. uni.showToast({
  90. title: '更新成功'
  91. })
  92. handleBack();
  93. }
  94. })
  95. }
  96. function handleBack() {
  97. uni.navigateBack()
  98. }
  99. function initPage() {
  100. myApi.getKehuUser().then(res => {
  101. const {juzhuDizhi,idtype,idcard,realName,userId} = res.data;
  102. data.idtype = res.data.idtype;
  103. data.idcard = res.data.idcard;
  104. data.realName = res.data.realName;
  105. data.userId = res.data.userId;
  106. data.juzhuDizhi = res.data.juzhuDizhi
  107. })
  108. }
  109. </script>
  110. <style>
  111. </style>