infoCard.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <view class="info-card-detail" :style="{ 'background-image': pagesType == '专栏详情' ? 'url(' + authorDetail.BgImg + ')' : '' }">
  3. <view class="name-author">
  4. <view class="author-img">
  5. <button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  6. <image :src="authorDetail.HeadImg"></image>
  7. </button>
  8. <view class="set-btn" v-if="pagesType == '专栏详情'" @click.stop="editMyColumn"> 编辑专栏</view>
  9. </view>
  10. <view class="name-box">
  11. <text>{{ authorDetail.SpecialName }}</text>
  12. <text>{{ authorDetail.NickName }}</text>
  13. </view>
  14. </view>
  15. <view class="info-card-lable">
  16. <text v-for="item in dataProcessing(authorDetail.Label)" :key="item">{{ item }}</text>
  17. </view>
  18. <view class="info-card-fans">
  19. <text>{{ authorDetail.SpecialArticleNum }}</text>
  20. <text>文章</text>
  21. <text>{{ authorDetail.CollectNum }}</text>
  22. <text>被收藏</text>
  23. <text>{{ authorDetail.FollowNum }}</text>
  24. <text>粉丝</text>
  25. </view>
  26. <view style="color: #fff; margin-top: 20rpx"> {{ authorDetail.Introduction }}</view>
  27. </view>
  28. </template>
  29. <script>
  30. import { purchaserApi, uploadurl } from "@/config/api";
  31. export default {
  32. props: {
  33. authorDetail: {
  34. type: Object,
  35. default: {},
  36. },
  37. pagesType: {
  38. type: String,
  39. default: "",
  40. },
  41. },
  42. data() {
  43. return {};
  44. },
  45. methods: {
  46. // 数据处理
  47. dataProcessing(item) {
  48. return item ? item.split(",") : [];
  49. },
  50. //点击了头像
  51. onChooseAvatar(e) {
  52. let token = this.$db.get("access_token");
  53. let authHeader = token || "";
  54. let that = this;
  55. uni.uploadFile({
  56. url: uploadurl,
  57. filePath: e.detail.avatarUrl,
  58. header: {
  59. "Content-Type": "multipart/form-data",
  60. Authorization: authHeader,
  61. },
  62. name: "file",
  63. success: async (resImg) => {
  64. let data = JSON.parse(resImg.data);
  65. const resUp = await purchaserApi.yanxuanSpecialAuthorImg({
  66. HeadImg: data.Data.ResourceUrl,
  67. UserId: that.authorDetail.UserId,
  68. });
  69. if (resUp.Ret === 200) {
  70. that.$parent.authorDetail.HeadImg = data.Data.ResourceUrl;
  71. }
  72. },
  73. });
  74. },
  75. editMyColumn() {
  76. if (this.pagesType == "专栏详情") {
  77. this.$emit("editColumnHandler");
  78. }
  79. },
  80. },
  81. };
  82. </script>
  83. <style lang="scss" scope>
  84. .info-card-detail {
  85. border-radius: 16rpx;
  86. background-size: 100% 100%;
  87. // 上面的那个盒子用就把上面的样式去掉
  88. width: 100%;
  89. padding: 40rpx 35rpx;
  90. background-repeat: no-repeat;
  91. color: #fff;
  92. .name-author {
  93. display: flex;
  94. background: rgba(0, 0, 0, 0);
  95. .author-img {
  96. position: relative;
  97. display: flex;
  98. justify-content: center;
  99. width: 126rpx;
  100. height: 138rpx;
  101. text-align: center;
  102. background: rgba(0, 0, 0, 0);
  103. .avatar-wrapper {
  104. background: rgba(0, 0, 0, 0);
  105. }
  106. image {
  107. background: rgba(0, 0, 0, 0);
  108. width: 111rpx;
  109. height: 111rpx;
  110. border-radius: 50%;
  111. }
  112. .set-btn {
  113. position: absolute;
  114. display: flex;
  115. justify-content: center;
  116. align-items: center;
  117. left: 0;
  118. bottom: 0;
  119. width: 126rpx;
  120. height: 48rpx;
  121. border-radius: 150rpx;
  122. background-color: #376cbb;
  123. color: #fff;
  124. z-index: 9;
  125. }
  126. }
  127. .name-box {
  128. margin-left: 20rpx;
  129. text:nth-child(1) {
  130. font-size: 36rpx;
  131. font-weight: 500;
  132. line-height: 50rpx;
  133. padding: 20rpx 0;
  134. }
  135. text:nth-child(2) {
  136. font-size: 28rpx;
  137. font-weight: 400;
  138. line-height: 39rpx;
  139. }
  140. }
  141. }
  142. .info-card-lable {
  143. display: flex;
  144. flex-wrap: wrap;
  145. text {
  146. display: flex;
  147. align-items: center;
  148. height: 45rpx;
  149. padding: 0 12rpx;
  150. border-radius: 150rpx;
  151. background-color: #8994a1;
  152. margin: 20rpx 20rpx 0rpx 0;
  153. }
  154. }
  155. .info-card-fans {
  156. margin-top: 20rpx;
  157. display: flex;
  158. align-items: center;
  159. text:nth-child(2n + 1) {
  160. color: #ffe8a8;
  161. font-size: 38rpx;
  162. font-weight: 500;
  163. }
  164. text:nth-child(2n) {
  165. margin: 0 40rpx 0 5rpx;
  166. }
  167. }
  168. }
  169. </style>