myInfo.vue 3.6 KB

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