columnDetail.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <view class="container column-detail">
  3. <view :class="['position-regular', scrollTopNumber != 0 && 'position-content-bg']" :style="{ 'background-image': scrollTopNumber == 0 ? `url(${authorDetail.BgImg})` : '' }">
  4. <view class="nav-bar-wrap" :style="{ height: navBarStyle.height, paddingTop: navBarStyle.paddingTop, paddingBottom: navBarStyle.paddingBottom }">
  5. <view class="content-box" :style="{ color: scrollTopNumber == 0 ? '#fff' : '#333' }">
  6. <text v-if="scrollTopNumber != 0">专栏详情</text>
  7. <view class="arrow-left-icon">
  8. <van-icon name="arrow-left" size="20px" @click="goHandler" />
  9. </view>
  10. </view>
  11. </view>
  12. <view class="name-author">
  13. <view class="author-img">
  14. <view class="img-box">
  15. <image :src="authorDetail.HeadImg"></image>
  16. </view>
  17. <view class="set-btn" @click="followAuthor">{{ authorDetail.IsFollow == 1 ? "取消关注" : "+ 关注" }}</view>
  18. </view>
  19. <view class="name-box" :style="{ color: scrollTopNumber == 0 ? '#fff' : '#333' }">
  20. <text>{{ authorDetail.SpecialName }}</text>
  21. <text>{{ authorDetail.NickName }}</text>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="info-lable-card" :style="{ 'background-image': `url(${authorDetail.BgImgDown})` }">
  26. <view class="info-card-lable">
  27. <text v-for="item in dataProcessing(authorDetail.Label)" :key="item">{{ item }}</text>
  28. </view>
  29. <view class="info-card-fans">
  30. <text>{{ authorDetail.SpecialArticleNum }}</text>
  31. <text>文章</text>
  32. <text>{{ authorDetail.CollectNum }}</text>
  33. <text>被收藏</text>
  34. <text>{{ authorDetail.FollowNum }}</text>
  35. <text>粉丝</text>
  36. </view>
  37. <view style="color: #fff; margin-top: 20rpx"> {{ authorDetail.Introduction }}</view>
  38. </view>
  39. <view class="column-list-content" v-if="specialList && specialList.length > 0">
  40. <column-list-content :authorDetail="authorDetail" :mySpecialList="specialList" @upDateCollectHandler="upDateCollectHandler" />
  41. </view>
  42. <Loading />
  43. </view>
  44. </template>
  45. <script>
  46. import ColumnListContent from "../components/columnListContent.vue";
  47. import infoCard from "../components/infoCard.vue";
  48. import { purchaserApi } from "@/config/api";
  49. export default {
  50. components: { infoCard, ColumnListContent },
  51. data() {
  52. return {
  53. navBarStyle: {
  54. height: 60 + "px",
  55. paddingTop: 40 + "px",
  56. paddingBottom: "4px",
  57. },
  58. scrollTopNumber: 0,
  59. authorDetail: {},
  60. specialList: [],
  61. detailUserId: 0,
  62. };
  63. },
  64. methods: {
  65. initNavBar() {
  66. let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
  67. this.navBarStyle = {
  68. height: menuButtonInfo.height + menuButtonInfo.top + 8 + "px",
  69. paddingTop: menuButtonInfo.top - 4 + "px",
  70. paddingBottom: "4px",
  71. };
  72. },
  73. // 获取作者详情
  74. async getAuthorDetail() {
  75. const res = await purchaserApi.yanxuanSpecialAuthorDetail({ UserId: this.detailUserId });
  76. if (res.Ret === 200) {
  77. this.authorDetail = res.Data || {};
  78. this.getColumnList();
  79. }
  80. },
  81. // 获取专栏列表
  82. async getColumnList() {
  83. const res = await purchaserApi.yanxuanSpecialList({ UserId: this.authorDetail.UserId });
  84. if (res.Ret === 200) {
  85. this.specialList = res.Data.List || [];
  86. }
  87. },
  88. // 数据处理
  89. dataProcessing(item) {
  90. return item ? item.split(",") : [];
  91. },
  92. // 点击关注作者
  93. async followAuthor() {
  94. await this.$store.dispatch("checkHandle");
  95. if (!this.$store.state.isAuth && !this.$store.state.isBind) {
  96. //已授权已绑定
  97. let Status = this.authorDetail.IsFollow == 1 ? 2 : 1;
  98. const res = await purchaserApi.yanxuanSpecialFollow({
  99. FollowUserId: this.authorDetail.UserId,
  100. Status,
  101. });
  102. if (res.Ret === 200) {
  103. this.authorDetail.IsFollow = Status;
  104. Status == 1 &&
  105. uni.showModal({
  106. title: "已关注专栏",
  107. content: "请关注【查研观向小助手】 公众号,及时获取专栏下内容更新提醒",
  108. confirmText: "知道了",
  109. showCancel: false,
  110. confirmColor: "#3385FF",
  111. });
  112. }
  113. }
  114. },
  115. // 左上角的返回按钮
  116. goHandler() {
  117. uni.navigateBack({
  118. fail() {
  119. uni.switchTab({
  120. url: "/pages/index/index",
  121. });
  122. },
  123. });
  124. },
  125. // 更新收藏
  126. upDateCollectHandler(item) {
  127. this.specialList.forEach((key) => {
  128. if (key.Id === item.Id) {
  129. console.log(key);
  130. key.CollectNum = item.IsCollect == 1 ? item.CollectNum - 1 : item.CollectNum + 1;
  131. key.IsCollect = item.IsCollect == 1 ? 0 : 1;
  132. }
  133. });
  134. },
  135. },
  136. onLoad(opacity) {
  137. this.detailUserId = Number(opacity.id) || 0;
  138. this.initNavBar();
  139. this.getAuthorDetail();
  140. },
  141. onPageScroll(e) {
  142. this.scrollTopNumber = e.scrollTop;
  143. },
  144. };
  145. </script>
  146. <style lang="scss" scope>
  147. .column-detail {
  148. position: relative;
  149. background-color: #f3f5f9;
  150. .scroll-top-content,
  151. .position-content-bg {
  152. background-color: #fff;
  153. }
  154. .position-regular {
  155. position: sticky;
  156. height: 350rpx;
  157. top: 0;
  158. left: 0;
  159. width: 100%;
  160. z-index: 99;
  161. background-size: 100% 100%;
  162. background-repeat: no-repeat;
  163. .name-author {
  164. z-index: 99;
  165. display: flex;
  166. height: 178rpx;
  167. padding: 20rpx 40rpx;
  168. .author-img {
  169. position: relative;
  170. display: flex;
  171. justify-content: center;
  172. width: 126rpx;
  173. height: 138rpx;
  174. text-align: center;
  175. .img-box {
  176. width: 110rpx;
  177. height: 110rpx;
  178. border-radius: 50%;
  179. overflow: hidden;
  180. image {
  181. width: 110rpx;
  182. height: 110rpx;
  183. }
  184. }
  185. .set-btn {
  186. position: absolute;
  187. display: flex;
  188. justify-content: center;
  189. align-items: center;
  190. left: 0;
  191. bottom: 0;
  192. width: 126rpx;
  193. height: 48rpx;
  194. border-radius: 150rpx;
  195. background-color: #376cbb;
  196. color: #fff;
  197. }
  198. }
  199. .name-box {
  200. color: #fff;
  201. margin-left: 20rpx;
  202. text:nth-child(1) {
  203. font-size: 36rpx;
  204. font-weight: 500;
  205. line-height: 50rpx;
  206. padding: 20rpx 0;
  207. }
  208. text:nth-child(2) {
  209. font-size: 28rpx;
  210. font-weight: 400;
  211. line-height: 39rpx;
  212. }
  213. }
  214. }
  215. }
  216. .nav-bar-wrap {
  217. width: 100%;
  218. display: flex;
  219. align-items: center;
  220. z-index: 99;
  221. .content-box {
  222. position: relative;
  223. display: flex;
  224. align-items: center;
  225. width: 100%;
  226. justify-content: center;
  227. color: #fff;
  228. font-size: 34rpx;
  229. .arrow-left-icon {
  230. position: absolute;
  231. display: flex;
  232. align-items: center;
  233. justify-content: center;
  234. width: 40rpx;
  235. height: 40rpx;
  236. left: 39rpx;
  237. top: 50%;
  238. transform: translateY(-50%);
  239. z-index: 99;
  240. }
  241. }
  242. }
  243. .column-list-content {
  244. // position: absolute;
  245. width: 682rpx;
  246. margin: 30rpx auto 0;
  247. border-radius: 12rpx 12rpx 0 0;
  248. // top: 580rpx;
  249. // right: 50%;
  250. // transform: translateX(50%);
  251. // z-index: 9;
  252. overflow: hidden;
  253. }
  254. .info-lable-card {
  255. background-size: 100% 100%;
  256. background-repeat: no-repeat;
  257. padding: 0 30rpx 35rpx;
  258. .info-card-lable {
  259. display: flex;
  260. flex-wrap: wrap;
  261. text {
  262. display: flex;
  263. align-items: center;
  264. height: 45rpx;
  265. padding: 0 12rpx;
  266. border-radius: 150rpx;
  267. background-color: rgba(255, 255, 255, 0.4);
  268. margin: 20rpx 20rpx 0rpx 0;
  269. color: #fff;
  270. font-size: 28rpx;
  271. }
  272. }
  273. .info-card-fans {
  274. margin-top: 20rpx;
  275. display: flex;
  276. align-items: center;
  277. text:nth-child(2n + 1) {
  278. color: #ffe8a8;
  279. font-size: 38rpx;
  280. font-weight: 500;
  281. }
  282. text:nth-child(2n) {
  283. margin: 0 40rpx 0 5rpx;
  284. color: #fff;
  285. }
  286. }
  287. }
  288. }
  289. </style>