infoCard.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. <image @click="onChooseAvatar" v-if="authorDetail.HasChangeHeadImg == 0" class="is-photo" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/new_cygx/photo_icon.png"></image>
  8. </button>
  9. <view class="set-btn" v-if="pagesType == '专栏详情'" @click.stop="editMyColumn"> 编辑专栏</view>
  10. </view>
  11. <view class="name-box">
  12. <text>{{ authorDetail.SpecialName }}</text>
  13. <text>{{ authorDetail.NickName }}</text>
  14. </view>
  15. </view>
  16. <view class="info-card-lable">
  17. <text v-for="item in dataProcessing(authorDetail.Label)" :key="item">{{ item }}</text>
  18. </view>
  19. <view class="info-card-fans">
  20. <text>{{ authorDetail.SpecialArticleNum }}</text>
  21. <text>文章</text>
  22. <text>{{ authorDetail.CollectNum }}</text>
  23. <text>被收藏</text>
  24. <text>{{ authorDetail.FollowNum }}</text>
  25. <text>粉丝</text>
  26. </view>
  27. <view style="color: #fff; margin-top: 20rpx"> {{ authorDetail.Introduction }}</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. uni.uploadFile({
  57. url: uploadurl,
  58. filePath: e.detail.avatarUrl,
  59. header: {
  60. "Content-Type": "multipart/form-data",
  61. Authorization: authHeader,
  62. },
  63. name: "file",
  64. success: async (resImg) => {
  65. let data = JSON.parse(resImg.data);
  66. const resUp = await purchaserApi.yanxuanSpecialAuthorImg({
  67. HeadImg: data.Data.ResourceUrl,
  68. UserId: that.authorDetail.UserId,
  69. });
  70. if (resUp.Ret === 200) {
  71. that.$parent.authorDetail.HeadImg = data.Data.ResourceUrl;
  72. that.$parent.authorDetail.HasChangeHeadImg = 1;
  73. }
  74. },
  75. });
  76. },
  77. editMyColumn() {
  78. if (this.pagesType == "专栏详情") {
  79. uni.navigateTo({ url: "/pages-purchaser/editSpecialColumn/editSpecialColumn" });
  80. }
  81. },
  82. },
  83. };
  84. </script>
  85. <style lang="scss" scope>
  86. .info-card-detail {
  87. border-radius: 16rpx;
  88. background-size: 100% 100%;
  89. // 上面的那个盒子用就把上面的样式去掉
  90. width: 100%;
  91. padding: 40rpx 35rpx;
  92. background-repeat: no-repeat;
  93. color: #fff;
  94. .name-author {
  95. display: flex;
  96. background: rgba(0, 0, 0, 0);
  97. .author-img {
  98. position: relative;
  99. display: flex;
  100. justify-content: center;
  101. width: 126rpx;
  102. height: 138rpx;
  103. text-align: center;
  104. background: rgba(0, 0, 0, 0);
  105. .avatar-wrapper {
  106. background: rgba(0, 0, 0, 0);
  107. }
  108. .is-photo {
  109. position: absolute;
  110. top: (calc(50% - 15rpx));
  111. left: 50%;
  112. width: 60rpx;
  113. height: 60rpx;
  114. z-index: 9;
  115. transform: translate(-50%, -50%);
  116. }
  117. image {
  118. background: rgba(0, 0, 0, 0);
  119. width: 111rpx;
  120. height: 111rpx;
  121. border-radius: 50%;
  122. }
  123. .set-btn {
  124. position: absolute;
  125. display: flex;
  126. justify-content: center;
  127. align-items: center;
  128. left: 0;
  129. bottom: 0;
  130. width: 126rpx;
  131. height: 48rpx;
  132. border-radius: 150rpx;
  133. background-color: #376cbb;
  134. color: #fff;
  135. z-index: 9;
  136. font-size: 24rpx;
  137. }
  138. }
  139. .name-box {
  140. margin-left: 20rpx;
  141. text:nth-child(1) {
  142. font-size: 36rpx;
  143. font-weight: 500;
  144. line-height: 50rpx;
  145. padding: 20rpx 0;
  146. }
  147. text:nth-child(2) {
  148. font-size: 28rpx;
  149. font-weight: 400;
  150. line-height: 39rpx;
  151. }
  152. }
  153. }
  154. .info-card-lable {
  155. display: flex;
  156. flex-wrap: wrap;
  157. text {
  158. display: flex;
  159. align-items: center;
  160. height: 45rpx;
  161. padding: 0 12rpx;
  162. border-radius: 150rpx;
  163. background-color: #8994a1;
  164. margin: 20rpx 20rpx 0rpx 0;
  165. }
  166. }
  167. .info-card-fans {
  168. margin-top: 20rpx;
  169. display: flex;
  170. align-items: center;
  171. text:nth-child(2n + 1) {
  172. color: #ffe8a8;
  173. font-size: 38rpx;
  174. font-weight: 500;
  175. }
  176. text:nth-child(2n) {
  177. margin: 0 40rpx 0 5rpx;
  178. }
  179. }
  180. }
  181. </style>