columnDetail.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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. console.log(key);
  134. key.CollectNum = item.IsCollect == 1 ? item.CollectNum - 1 : item.CollectNum + 1;
  135. key.IsCollect = item.IsCollect == 1 ? 0 : 1;
  136. }
  137. });
  138. },
  139. },
  140. onLoad(opacity) {
  141. this.detailUserId = Number(opacity.id) || 0;
  142. this.initNavBar();
  143. this.getAuthorDetail();
  144. },
  145. onPageScroll(e) {
  146. this.scrollTopNumber = e.scrollTop;
  147. },
  148. /** 用户点击分享 */
  149. onShareAppMessage: function (res) {
  150. return {
  151. title: "研选专栏",
  152. path: "/pages-purchaser/columnDetail/columnDetail?id=" + this.detailUserId,
  153. };
  154. },
  155. };
  156. </script>
  157. <style lang="scss" scope>
  158. .column-detail {
  159. position: relative;
  160. background-color: $uni-bg-color;
  161. .scroll-top-content,
  162. .position-content-bg {
  163. background-color: #fff;
  164. }
  165. .position-regular {
  166. position: sticky;
  167. height: 350rpx;
  168. top: 0;
  169. left: 0;
  170. width: 100%;
  171. z-index: 99;
  172. background-size: 100% 100%;
  173. background-repeat: no-repeat;
  174. .name-author {
  175. z-index: 99;
  176. display: flex;
  177. height: 178rpx;
  178. padding: 20rpx 40rpx;
  179. .author-img {
  180. position: relative;
  181. display: flex;
  182. justify-content: center;
  183. width: 126rpx;
  184. height: 138rpx;
  185. text-align: center;
  186. .img-box {
  187. width: 110rpx;
  188. height: 110rpx;
  189. border-radius: 50%;
  190. overflow: hidden;
  191. image {
  192. width: 110rpx;
  193. height: 110rpx;
  194. }
  195. }
  196. .set-btn {
  197. position: absolute;
  198. display: flex;
  199. justify-content: center;
  200. align-items: center;
  201. left: 0;
  202. bottom: 0;
  203. width: 126rpx;
  204. height: 48rpx;
  205. border-radius: 150rpx;
  206. background-color: #376cbb;
  207. color: #fff;
  208. font-size: 24rpx;
  209. }
  210. }
  211. .name-box {
  212. color: #fff;
  213. margin-left: 20rpx;
  214. text:nth-child(1) {
  215. font-size: 36rpx;
  216. font-weight: 500;
  217. line-height: 50rpx;
  218. padding: 20rpx 0;
  219. }
  220. text:nth-child(2) {
  221. font-size: 28rpx;
  222. font-weight: 400;
  223. line-height: 39rpx;
  224. }
  225. }
  226. }
  227. }
  228. .nav-bar-wrap {
  229. width: 100%;
  230. display: flex;
  231. align-items: center;
  232. z-index: 99;
  233. .content-box {
  234. position: relative;
  235. display: flex;
  236. align-items: center;
  237. width: 100%;
  238. justify-content: center;
  239. color: #fff;
  240. font-size: 34rpx;
  241. .arrow-left-icon {
  242. position: absolute;
  243. display: flex;
  244. align-items: center;
  245. justify-content: center;
  246. width: 40rpx;
  247. height: 40rpx;
  248. left: 39rpx;
  249. top: 50%;
  250. transform: translateY(-50%);
  251. z-index: 99;
  252. }
  253. }
  254. }
  255. .column-list-content {
  256. // position: absolute;
  257. width: 682rpx;
  258. margin: 30rpx auto 0;
  259. border-radius: 12rpx 12rpx 0 0;
  260. // top: 580rpx;
  261. // right: 50%;
  262. // transform: translateX(50%);
  263. // z-index: 9;
  264. overflow: hidden;
  265. }
  266. .info-lable-card {
  267. background-size: 100% 100%;
  268. background-repeat: no-repeat;
  269. padding: 0 30rpx 35rpx;
  270. .info-card-lable {
  271. display: flex;
  272. flex-wrap: wrap;
  273. text {
  274. display: flex;
  275. align-items: center;
  276. height: 45rpx;
  277. padding: 0 12rpx;
  278. border-radius: 150rpx;
  279. background-color: rgba(255, 255, 255, 0.4);
  280. margin: 20rpx 20rpx 0rpx 0;
  281. color: #fff;
  282. font-size: 28rpx;
  283. }
  284. }
  285. .info-card-fans {
  286. padding-top: 20rpx;
  287. display: flex;
  288. align-items: center;
  289. text:nth-child(2n + 1) {
  290. color: #ffe8a8;
  291. font-size: 38rpx;
  292. font-weight: 500;
  293. }
  294. text:nth-child(2n) {
  295. margin: 0 40rpx 0 5rpx;
  296. color: #fff;
  297. }
  298. }
  299. }
  300. }
  301. </style>