mine-qrcode.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <view class="mine-qrcode">
  3. <view class="handlerUpload" @click="handlerUploadQrcode">
  4. <image class="qrcode" :src="qrcode" mode="" v-if="qrcode"></image>
  5. <text v-else>
  6. 请点击上传二维码
  7. </text>
  8. </view>
  9. <button class="upload" @click="handlerUploadQrcode">上传二维码</button>
  10. <button class="save-qrcode" :class="active && 'active'" @click="handlerSave">保存</button>
  11. </view>
  12. </template>
  13. <script>
  14. import { uploadFileImage } from '@/services/public.js'
  15. export default {
  16. data() {
  17. return {
  18. active: false,
  19. userInfo: {},
  20. info: {},
  21. qrcode: ''
  22. }
  23. },
  24. watch: {
  25. qrcode(val) {
  26. if (val) {
  27. this.active = true
  28. }
  29. }
  30. },
  31. mounted() {
  32. this.userInfo = uni.getStorageSync('userInfo')
  33. this.getUserInfo()
  34. },
  35. methods: {
  36. handlerSave() {
  37. if (this.active) {
  38. this.upload()
  39. setTimeout(() => {
  40. this.$api.navigateTo('/pages/seller/remarks/mine-card')
  41. }, 1000)
  42. }
  43. },
  44. handlerUploadQrcode() {
  45. uploadFileImage().then(res => {
  46. this.$util.msg('请稍后')
  47. this.qrcode = JSON.parse(res.data).data
  48. })
  49. },
  50. async getUserInfo() {
  51. const { data } = await this.SellerService.GetSellerHome({ userId: this.userInfo.userId })
  52. this.userInfo = data
  53. this.qrcode = data.qrCode
  54. },
  55. upload() {
  56. if (this.qrcode) {
  57. this.SellerService.updateSellerInfo({
  58. userId: this.userInfo.userId,
  59. image: this.userInfo.image,
  60. qrCode: this.qrcode
  61. }).then(res => {
  62. this.getUserInfo()
  63. this.showActionSheet = false
  64. uni
  65. })
  66. } else {
  67. this.$util.msg('请上传二维码图片')
  68. }
  69. }
  70. }
  71. }
  72. </script>
  73. <style lang="scss" scoped>
  74. .mine-qrcode {
  75. width: 100vw;
  76. height: 100vh;
  77. .handlerUpload {
  78. width: 420rpx;
  79. height: 420rpx;
  80. border: 1px dotted #B2B2B2;
  81. margin: 120rpx auto 0 auto;
  82. text-align: center;
  83. line-height: 420rpx;
  84. color: #B2B2B2;
  85. font-size: 24rpx;
  86. border-radius: 16rpx;
  87. .qrcode {
  88. width: 420rpx;
  89. height: 420rpx;
  90. object-fit: contain;
  91. }
  92. }
  93. .upload {
  94. margin: 101rpx auto 0 auto;
  95. width: 600rpx;
  96. height: 90rpx;
  97. border-radius: 45rpx;
  98. opacity: 1;
  99. border: 1rpx solid #FF5B00;
  100. color: #FF5B00;
  101. line-height: 90rpx;
  102. text-align: center;
  103. }
  104. .save-qrcode {
  105. margin: 24rpx auto 0 auto;
  106. width: 600rpx;
  107. height: 90rpx;
  108. border-radius: 45rpx;
  109. opacity: 1;
  110. color: #FFFFFF;
  111. line-height: 90rpx;
  112. text-align: center;
  113. background-color: #E1E1E1;
  114. }
  115. .active {
  116. background: linear-gradient(90deg, #FF9300 0%, #FF5B00 100%);
  117. }
  118. }
  119. </style>