info.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <!-- 店鋪信息页 -->
  2. <template>
  3. <view class="wanlshop-info-container">
  4. <view class="edgeInsetTop"></view>
  5. <view class="wanlshop-info-container__main bg-white">
  6. <view class="margin-left-bj shopuser">
  7. <view class="cu-avatar round margin-right-bj" :style="{backgroundImage: 'url(' + $appKit.oss(shopData.avatar, 52, 52) + ')'}"></view>
  8. <view>
  9. <view class="text-df text-cut" style="width: 320rpx;">
  10. <text>{{ shopData.shopname || $t('common.loading') }}</text>
  11. </view>
  12. <view class="wanl-gray text-min">{{ $t('mall.fans') }} {{ shopData.find_user.fans }}</view>
  13. <view class="wanl-gray text-min">{{ shopData.city }}</view>
  14. </view>
  15. </view>
  16. <view class="margin-right-bj">
  17. <button v-if="shopData.isFollow === 0" class="cu-btn radius-bock text-sm" @click.stop="handleFollow">
  18. <text class="wlIcon-tianjia margin-right-xs text-bold"></text>{{ $t('mall.shop.follow') }}
  19. </button>
  20. <button v-else class="cu-btn radius-bock text-sm" @click.stop="handleFollow">
  21. <text class="wlIcon-31xuanze margin-right-xs text-bold"></text>{{ $t('mine.followed') }}
  22. </button>
  23. </view>
  24. </view>
  25. <view class="shop_info bg-white margin-top-bj padding-lr-bj">
  26. <view class="padding-tb-bj solid-bottom">{{ $t('mall.shop.shopIntro') }}</view>
  27. </view>
  28. <view class="bg-white padding-bj">
  29. <rich-text :nodes="shopData.bio"></rich-text>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import { pullMallShopInfo } from '@/features/mall/mall-gateway'
  35. export default {
  36. data() {
  37. return {
  38. shopData: {
  39. id: 0,
  40. avatar: '',
  41. shopname: '',
  42. state: 0,
  43. islive: 0,
  44. isself: 0,
  45. isFollow: 0,
  46. find_user: {
  47. user_no: '',
  48. fans: 0
  49. }
  50. }
  51. }
  52. },
  53. onLoad(option) {
  54. this.loadData(option.id)
  55. },
  56. methods: {
  57. async loadData(shop_id) {
  58. try {
  59. const res = await pullMallShopInfo(shop_id)
  60. if (res.bio) {
  61. res.bio = res.bio.replace(/<img/g, "<img style='display: block;'")
  62. }
  63. this.shopData = res
  64. } catch (e) {
  65. console.error('[shop info] loadData', e)
  66. }
  67. },
  68. async handleFollow() {
  69. const isLogin = this.$store.state.user.isLogin
  70. if (!isLogin) {
  71. uni.navigateTo({ url: '/pages/passport/lobby' })
  72. return
  73. }
  74. try {
  75. await uni.request({
  76. url: '/wanlshop/find/user/setFindUser',
  77. method: 'POST',
  78. data: {
  79. id: this.shopData.find_user.user_no,
  80. type: 'follow'
  81. },
  82. success: res => {
  83. let concern = this.$store.state.statistics.dynamic.concern
  84. if (res.data.data === 0) {
  85. concern -= 1
  86. this.shopData.find_user.fans -= 1
  87. } else {
  88. concern += 1
  89. this.shopData.find_user.fans += 1
  90. }
  91. this.$store.commit('statistics/dynamic', { concern })
  92. this.shopData.isFollow = res.data.data
  93. }
  94. })
  95. } catch (e) {
  96. console.error('[shop info] handleFollow', e)
  97. }
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. .wanlshop-info-container {
  104. &__main {
  105. display: flex;
  106. align-items: center;
  107. justify-content: space-between;
  108. height: 200rpx;
  109. .cu-avatar {
  110. width: 120rpx;
  111. height: 120rpx;
  112. }
  113. .shopuser {
  114. display: flex;
  115. align-items: center;
  116. }
  117. }
  118. }
  119. .wanl-gray { color: #667085; }
  120. </style>