infoCard.vue 4.5 KB

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