business-card.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view class="business-card">
  3. <view class="select-item" @click.native="showActionSheet = true">
  4. <view class="select-title">头像</view>
  5. <view class="select-content">
  6. <image
  7. class="aov"
  8. :src="info.image || 'https://static.caimei365.com/app/img/icon/default-head.png'"
  9. mode=""
  10. ></image>
  11. <text class="cell-more iconfont icon-xiayibu"></text>
  12. </view>
  13. </view>
  14. <view class="select-item" @click.native="$api.navigateTo('/pages/seller/remarks/mine-qrcode')">
  15. <view class="select-title">二维码</view>
  16. <view class="select-content">
  17. <image class="aov" :src="info.qrCode" mode="" v-if="info.qrCode"></image>
  18. <text v-else>无</text>
  19. <text class="cell-more iconfont icon-xiayibu"></text>
  20. </view>
  21. </view>
  22. <tui-actionsheet
  23. :show="showActionSheet"
  24. :item-list="itemList"
  25. @click="itemClick"
  26. :isCancel="fasle"
  27. @cancel="closeActionSheet"
  28. ></tui-actionsheet>
  29. </view>
  30. </template>
  31. <script>
  32. import { uploadFileImage } from '@/services/public.js'
  33. export default {
  34. data() {
  35. return {
  36. userInfo: {},
  37. showActionSheet: false,
  38. itemList: [
  39. {
  40. text: '手机相册'
  41. },
  42. {
  43. text: '取消'
  44. }
  45. ],
  46. info: {}
  47. }
  48. },
  49. mounted() {
  50. this.userInfo = uni.getStorageSync('userInfo')
  51. this.getUserInfo()
  52. },
  53. onload() {
  54. uni.$on('updated', () => {
  55. this.getUserInfo()
  56. })
  57. },
  58. methods: {
  59. itemClick(e) {
  60. if (e.index === 1) {
  61. return (this.showActionSheet = false)
  62. } else {
  63. uploadFileImage().then(res => {
  64. this.$util.msg('请稍后')
  65. const img = JSON.parse(res.data).data
  66. if (!img) return this.$util.msg('图片上传失败')
  67. this.SellerService.updateSellerInfo({
  68. userId: this.userInfo.userId,
  69. image: img,
  70. qrcode: this.userInfo.qrcode || ''
  71. }).then(res => {
  72. this.getUserInfo()
  73. this.showActionSheet = false
  74. this.$util.msg('上传成功')
  75. })
  76. })
  77. }
  78. },
  79. closeActionSheet() {
  80. this.showActionSheet = false
  81. },
  82. async getUserInfo() {
  83. const { data } = await this.SellerService.GetSellerHome({ userId: this.userInfo.userId })
  84. this.info = data
  85. }
  86. }
  87. }
  88. </script>
  89. <style lang="scss">
  90. @import '@/uni.scss';
  91. .business-card {
  92. padding: 0 32rpx;
  93. box-sizing: border-box;
  94. .select-item {
  95. display: flex;
  96. justify-content: space-between;
  97. height: 100rpx;
  98. border-bottom: 1rpx solid #e1e1e1;
  99. margin-top: 30rpx;
  100. position: relative;
  101. .select-title {
  102. color: #666666;
  103. font-size: 28rpx;
  104. }
  105. .select-content {
  106. display: flex;
  107. align-items: center;
  108. .aov {
  109. width: 90rpx;
  110. height: 90rpx;
  111. border-radius: 50%;
  112. object-fit: contain;
  113. }
  114. }
  115. }
  116. }
  117. .cell-more {
  118. width: 20rpx;
  119. height: 100rpx;
  120. line-height: 100rpx;
  121. text-align: right;
  122. right: 0;
  123. top: 0;
  124. font-size: $font-size-28;
  125. color: #666666;
  126. .txt {
  127. color: #fb4343;
  128. padding-right: 10rpx;
  129. }
  130. }
  131. </style>