columnDetail.vue 8.6 KB

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