hotList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <view class="container container-hot-list">
  3. <view class="top-content">
  4. <view class="tab-content">
  5. <view v-for="item in tabList" :key="item.Source" :class="['item', tabsActive == item.Source && 'tab-active']" @click="tabsHandler(item)">
  6. {{ item.Name }}
  7. <image v-if="tabsActive == item.Source" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/border_act.png"></image>
  8. </view>
  9. </view>
  10. </view>
  11. <view class="content">
  12. <view class="content-ul" v-if="hotList.length && tabsActive == 1">
  13. <view class="hot-li" v-for="(item, index) in hotList" :key="item.IndustrialManagementId">
  14. <view class="li-item hot-item">
  15. <view style="display: flex" class="text_oneLine hot-new" @click="themeDetails(item)">
  16. <text class="li-serial serial-number" :style="{ background: serialBackground(index) }">
  17. {{ index + 1 }}
  18. </text>
  19. <text class="title-text text_oneLine" style="display: inline"> # {{ item.IndustryName }} </text>
  20. <view class="industry-color" :style="[classifyColor(item.PermissionName)]">{{ item.PermissionName }}</view>
  21. <image class="new-img" v-if="item.IsNew" src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/new_icon.png"></image>
  22. </view>
  23. <text :class="item.IsFollow ? 'cancel-attention' : 'attention'" @click="isAttention(item, '主题')">{{ item.IsFollow ? "取消关注" : "+ 关注" }}</text>
  24. </view>
  25. <view class="li-item read-more" @click="themeDetails(item)">
  26. <text class="text-box text_oneLine" v-for="val in item.IndustrialSubjectList" :key="val.IndustrialSubjectId">
  27. {{ val.SubjectName }}
  28. </text>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="content-ul" v-if="kolList.length && tabsActive != 1">
  33. <view class="user-li" v-for="(item, index) in kolList" :key="item.ArticleId">
  34. <view class="li-item">
  35. <text class="li-serial" :style="{ background: serialBackground(index) }">
  36. {{ index + 1 }}
  37. </text>
  38. <view>
  39. <text @click="goDetail(item)" style="display: inline; margin-right: 20rpx">{{ item.Title }}</text>
  40. <text class="li-industry" @click="themeDetails(key)" v-for="key in item.List" :key="key.IndustrialManagementId"> # {{ key.IndustryName }} </text>
  41. </view>
  42. </view>
  43. <view class="li-item li-bottom" style="color: #999999">
  44. <view class="li-user text_oneLine">
  45. {{ item.PublishDate }}
  46. <view class="industry-color" :style="[classifyColor(item.PermissionName)]">{{ item.PermissionName }}</view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="content-bottom">最新榜单您已掌握,明天再刷刷看~</view>
  53. <u-modal
  54. v-model="goFollowShow"
  55. :content-style="{ fontSize: '32rpx' }"
  56. @confirm="goFollowShowBtn"
  57. :show-cancel-button="isCancelBtn"
  58. :confirm-text="confirmText"
  59. @cancel="isCancelBtn = false"
  60. :show-title="false"
  61. :cancel-style="{ borderRight: '1rpx solid #EBEBEB' }"
  62. :confirm-style="{ fontWeight: '700' }"
  63. >
  64. <view class="slot-content">
  65. <rich-text :nodes="accounts"></rich-text>
  66. </view>
  67. </u-modal>
  68. </view>
  69. </template>
  70. <script>
  71. import { Reports } from "@/config/api.js";
  72. import { color_word_bg } from "@/utils/styleClassify";
  73. export default {
  74. data() {
  75. return {
  76. tabList: [], //tab
  77. tabsActive: 1,
  78. hotList: [],
  79. kolList: [],
  80. confirmText: "知道了",
  81. accounts: "",
  82. isCancelBtn: false,
  83. goFollowShow: false,
  84. };
  85. },
  86. methods: {
  87. /* 获取tab*/
  88. async getTabList() {
  89. const res = await Reports.getHotTableList();
  90. if (res.Ret === 200) {
  91. this.tabList = res.Data.List || [];
  92. this.tabsActive = this.tabList.length ? this.tabList[0].Source : 1;
  93. this.researchHotList();
  94. }
  95. },
  96. /* 点击一级的tabs*/
  97. tabsHandler(item) {
  98. this.tabsActive = item.Source;
  99. this.listInit();
  100. this.researchHotList();
  101. },
  102. //产业关注 阅读、报告收藏
  103. async researchHotList() {
  104. const res = this.tabsActive == 1 ? await Reports.getIndustryFllowList() : await Reports.getIndustryReadList({ Source: this.tabsActive });
  105. if (res.Ret === 200) {
  106. if (this.tabsActive == 1) {
  107. this.hotList = res.Data.List || [];
  108. } else {
  109. this.kolList = res.Data.List || [];
  110. }
  111. }
  112. },
  113. listInit() {
  114. if (this.tabsActive == 1) {
  115. this.hotList = [];
  116. } else {
  117. this.kolList = [];
  118. }
  119. },
  120. //去往作者详情
  121. authorDetails(item) {
  122. uni.navigateTo({
  123. url: "/reportPages/authorPages/authorPages?id=" + item.DepartmentId,
  124. });
  125. },
  126. //去往主题详情
  127. themeDetails(item) {
  128. this.$store.dispatch("checkHandle", "/reportPages/IndustryReport/IndustryReport?id=" + item.IndustrialManagementId);
  129. },
  130. //计算遍历的颜色
  131. serialBackground(index) {
  132. index += 1;
  133. return index == 1 ? "#D7584F" : index == 2 ? "#E98033" : index == 3 ? "#FDD367" : "#D3D3D3";
  134. },
  135. //关注
  136. async isAttention(item, val) {
  137. const res = val === "主题" ? await Reports.reportFllow({ IndustrialManagementId: item.IndustrialManagementId }) : await Reports.reportFllowDepartment({ DepartmentId: item.DepartmentId });
  138. if (res.Ret === 200) {
  139. item.IsFollow = !item.IsFollow;
  140. if (res.Data.Status == 1) {
  141. this.goFollowShow = true;
  142. this.confirmText = res.Data.GoFollow ? "去关注" : "知道了";
  143. if (res.Data.GoFollow) {
  144. this.accounts = `${val == "主题" ? "产业" : "作者"}关注成功 <br> 想要及时获取该${val === "主题" ? "产业内容的更新推送" : "作者的报告更新提示"},请关注【查研观向小助手】公众号`;
  145. this.isCancelBtn = true;
  146. } else {
  147. this.accounts = `${val == "主题" ? "产业" : "作者"}` + `关注成功<br>请关注【查研观向小助手】公众号,及时获取${val === "主题" ? "产业" : "作者"}报告更新提醒`;
  148. }
  149. } else {
  150. uni.showToast({
  151. title: "已取消关注",
  152. icon: "none",
  153. duration: 2000,
  154. });
  155. }
  156. }
  157. },
  158. //去关注
  159. goFollowShowBtn() {
  160. if (this.confirmText == "去关注") {
  161. uni.navigateTo({
  162. url: "/activityPages/accountsOfficial/accountsOfficial",
  163. });
  164. }
  165. this.goFollowShow = false;
  166. },
  167. goDetail(item) {
  168. uni.navigateTo({
  169. url: "/pageMy/reportDetail/reportDetail?id=" + item.ArticleId,
  170. });
  171. },
  172. classifyColor(item) {
  173. let text_color = color_word_bg.color_word.find((key) => key.name == item).color;
  174. let back_ground = color_word_bg.color_bg.find((key) => key.name == item).color;
  175. let _isColor = { color: text_color, border: ` 1px solid ${text_color}`, "background-color": back_ground };
  176. return _isColor;
  177. },
  178. },
  179. onLoad() {
  180. this.getTabList();
  181. },
  182. };
  183. </script>
  184. <style lang="scss" scoped>
  185. .container-hot-list {
  186. padding: 30rpx;
  187. .top-content {
  188. position: sticky;
  189. top: -1rpx;
  190. left: 0;
  191. z-index: 99;
  192. background-color: #fff;
  193. padding-bottom: 10rpx;
  194. }
  195. .tab-content {
  196. display: flex;
  197. .item {
  198. position: relative;
  199. display: inline-block;
  200. padding-bottom: 10rpx;
  201. font-size: 32rpx;
  202. color: #999999;
  203. margin-right: 50rpx;
  204. font-weight: 400;
  205. image {
  206. position: absolute;
  207. bottom: 0;
  208. left: 50%;
  209. transform: translateX(-50%);
  210. width: 100rpx;
  211. height: 4rpx;
  212. }
  213. }
  214. .tab-active {
  215. color: #333333;
  216. font-weight: 500;
  217. }
  218. }
  219. .children-tabs {
  220. margin-top: 30rpx;
  221. width: 100%;
  222. display: flex;
  223. overflow: hidden;
  224. overflow-x: auto;
  225. .children-item {
  226. padding: 10rpx 20rpx;
  227. background: #f9f9f9;
  228. border-radius: 4px;
  229. margin-right: 40rpx;
  230. }
  231. .children-tab-active {
  232. background-color: #3385ff;
  233. color: #fff;
  234. }
  235. }
  236. .content-ul {
  237. margin: 20rpx 0 0;
  238. border-top: 1px solid #f6f6f6;
  239. .user-li,
  240. .hot-li {
  241. padding: 30rpx 0 20rpx;
  242. border-bottom: 1px solid #f6f6f6;
  243. }
  244. .li-serial {
  245. width: 26rpx;
  246. height: 26rpx;
  247. line-height: 26rpx;
  248. color: #fff;
  249. font-size: 20rpx;
  250. text-align: center;
  251. border-radius: 4rpx 4rpx 4rpx 4rpx;
  252. margin: 7rpx 10rpx 0 20rpx;
  253. flex-shrink: 0;
  254. }
  255. .serial-number {
  256. margin-top: 0 !important;
  257. }
  258. .li-item {
  259. display: flex;
  260. .li-industry {
  261. color: #3385ff;
  262. margin-right: 20rpx;
  263. display: inline-block;
  264. }
  265. .li-user {
  266. margin-left: 46rpx;
  267. display: flex;
  268. align-items: center;
  269. }
  270. .li-title {
  271. display: flex;
  272. }
  273. }
  274. .li-bottom {
  275. display: flex;
  276. justify-content: space-between;
  277. align-items: center;
  278. margin-top: 30rpx;
  279. width: 100%;
  280. image {
  281. width: 23rpx;
  282. height: 26rpx;
  283. margin-right: 10rpx;
  284. }
  285. }
  286. .read-more {
  287. margin-left: 30rpx;
  288. margin-top: 20rpx;
  289. display: flex;
  290. flex-wrap: wrap;
  291. .text-box {
  292. margin-bottom: 27rpx;
  293. margin-right: 40rpx;
  294. padding: 0;
  295. font-size: 24rpx;
  296. color: #408fff;
  297. width: 170rpx;
  298. height: 46rpx;
  299. line-height: 46rpx;
  300. text-align: center !important;
  301. background: url(~@/static/img/report_bg.png) no-repeat;
  302. background-size: 100% 100%;
  303. text-indent: 0em;
  304. }
  305. }
  306. .attention {
  307. flex-shrink: 0;
  308. padding: 5rpx 28rpx;
  309. border-radius: 37rpx 37rpx 37rpx 37rpx;
  310. color: #fff;
  311. background: #3385ff;
  312. font-weight: 400;
  313. font-size: 24rpx;
  314. }
  315. .hot-item {
  316. justify-content: space-between;
  317. align-items: center;
  318. .hot-new {
  319. align-items: center;
  320. flex: 1;
  321. padding-right: 20rpx;
  322. }
  323. .new-img {
  324. width: 26rpx;
  325. height: 28rpx;
  326. margin-left: 15rpx;
  327. flex-shrink: 0;
  328. }
  329. }
  330. }
  331. .content-bottom {
  332. background-color: #fff;
  333. text-align: center;
  334. line-height: 100rpx;
  335. color: #c4c4c4;
  336. font-size: 20rpx;
  337. }
  338. .industry-color {
  339. font-size: 26rpx;
  340. padding: 0rpx 20rpx;
  341. border-radius: 4rpx;
  342. margin-left: 20rpx;
  343. }
  344. .title-text {
  345. font-size: 28rpx;
  346. font-weight: 500;
  347. }
  348. }
  349. </style>