hotList.vue 12 KB

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