myInfo.vue 3.1 KB

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