index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <view class="profile">
  3. <view class="profile-head">
  4. <image
  5. class="profile-head-img"
  6. @click="toProfile"
  7. :src="
  8. userInfo && userInfo.avatar
  9. ? $method.splitImgHost(userInfo.avatar, true)
  10. : defaultHead
  11. "
  12. ></image>
  13. <view>{{ userInfo && userInfo.realname }}</view>
  14. <image
  15. v-if="!userInfo.avatar"
  16. class="profile-head-icon"
  17. src="../../static/image/icon_camer.png"
  18. mode=""
  19. ></image>
  20. </view>
  21. <u-form v-if="userInfo" :model="userInfo" ref="uForm" labelWidth="160">
  22. <u-form-item label="业务员ID">
  23. <u-input disabled v-model="userInfo.userAccount" border="bottom" />
  24. </u-form-item>
  25. <u-form-item label="姓名">
  26. <u-input disabled v-model="userInfo.realname" border="bottom" />
  27. </u-form-item>
  28. <u-form-item label="手机号码">
  29. <u-input
  30. disabled
  31. v-model="userInfo.telphone"
  32. border="bottom"
  33. type="number"
  34. maxlength="11"
  35. />
  36. </u-form-item>
  37. <u-form-item label="身份证号">
  38. <u-input disabled v-model="userInfo.idCard" border="bottom" />
  39. </u-form-item>
  40. </u-form>
  41. </view>
  42. </template>
  43. <script>
  44. import { mapGetters } from "vuex";
  45. import { uploadFile } from "@/common/upload";
  46. import { sellerEdit } from "@/utils/user";
  47. export default {
  48. data() {
  49. return {
  50. defaultHead: require("../../static/image/defhead.png"),
  51. fileList: [],
  52. };
  53. },
  54. async onShow() {
  55. if (this.$method.isLogin()) {
  56. !this.userInfo && (await this.$store.dispatch("getUserInfo"));
  57. }
  58. },
  59. methods: {
  60. toProfile() {
  61. uploadFile().then((avatar) => {
  62. sellerEdit({
  63. avatar,
  64. }).then((res) => {
  65. this.$u.toast("头像已上传");
  66. this.$store.dispatch("getUserInfo");
  67. });
  68. });
  69. },
  70. },
  71. computed: {
  72. ...mapGetters(["userInfo"]),
  73. },
  74. };
  75. </script>
  76. <style scoped lang="scss">
  77. image {
  78. width: 100%;
  79. height: 100%;
  80. }
  81. .profile {
  82. padding: 68rpx 48rpx 0;
  83. .profile-head {
  84. margin: 0 auto 120rpx;
  85. width: 160rpx;
  86. position: relative;
  87. .profile-head-img {
  88. width: 160rpx;
  89. height: 160rpx;
  90. border-radius: 50%;
  91. }
  92. .profile-head-icon {
  93. width: 56rpx;
  94. height: 56rpx;
  95. position: absolute;
  96. top: 104rpx;
  97. right: 0;
  98. }
  99. view {
  100. padding-top: 20rpx;
  101. font-weight: bold;
  102. color: #222222;
  103. font-size: 36rpx;
  104. text-align: center;
  105. }
  106. }
  107. /deep/ {
  108. .u-input {
  109. background-color: #ffffff !important;
  110. }
  111. }
  112. }
  113. </style>