index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view class="container New-container">
  3. <view class="top-content-box">
  4. <search-bar @goSearch="goSearch" :searchTitle="searchPlaceholderList.SummarySearch" :width="55">
  5. <template slot="content-left">
  6. <view class="box-img" @click="goMyInfo">
  7. <image v-if="info.Headimgurl" :src="info.Headimgurl" alt=""></image>
  8. <image v-else src="https://hzchart.oss-cn-shanghai.aliyuncs.com/cygx/czbk/logo.png" class="avatar"></image>
  9. </view>
  10. </template>
  11. </search-bar>
  12. </view>
  13. <view class="content-ul">
  14. <view class="item-ul">
  15. <block v-for="(item, index) in newDataList" :key="index">
  16. <view v-if="index % 2 == 0">
  17. <block v-if="item.Source === 'article'"> <ReportItem :list="item.Article" /></block>
  18. <block v-if="item.Source === 'newchart'">
  19. <ChartItem :list="item.Newchart" :isMyChartCollection="isMyChartCollection" @myChartIsTop="myChartIsTop" @myChartCollect="myChartCollect" />
  20. </block>
  21. <block v-if="item.Source === 'roadshow' || item.Source === 'activityvideo' || item.Source === 'activityvoice'">
  22. <RoadshowItem :list="item.Roadshow" @isCollectionHandeler="isCollectionHandeler" />
  23. </block>
  24. <block v-if="item.Source === 'activity' || item.Source === 'activityspecial'">
  25. <ActivityItem :list="item.Activity" />
  26. </block>
  27. </view>
  28. </block>
  29. </view>
  30. <view class="item-ul">
  31. <block v-for="(item, index) in newDataList" :key="index">
  32. <view v-if="index % 2 !== 0">
  33. <block v-if="item.Source === 'article'"> <ReportItem :list="item.Article" /></block>
  34. <block v-if="item.Source === 'newchart'">
  35. <ChartItem :list="item.Newchart" :isMyChartCollection="isMyChartCollection" @myChartIsTop="myChartIsTop" @myChartCollect="myChartCollect" />
  36. </block>
  37. <block v-if="item.Source === 'roadshow' || item.Source === 'activityvideo' || item.Source === 'activityvoice'">
  38. <RoadshowItem :list="item.Roadshow" @isCollectionHandeler="isCollectionHandeler" />
  39. </block>
  40. <block v-if="item.Source === 'activity' || item.Source === 'activityspecial'">
  41. <ActivityItem :list="item.Activity" />
  42. </block>
  43. </view>
  44. </block>
  45. </view>
  46. </view>
  47. <u-loadmore :status="status" icon-type="flower" :load-text="loadText" margin-top="20" v-if="page_no > 1" />
  48. <view v-if="newDataList.length === 4" class="bind-btn" @click="goLogin">绑定联系方式后查看更多内容>></view>
  49. <suspenButton :show.sync="wholeShowListData.IsShow" v-if="wholeShowListData.IsShow" />
  50. </view>
  51. </template>
  52. <script>
  53. import { Home, Mine } from "@/config/api";
  54. import ChartItem from "@/components/ItemComponent/chartItem.vue";
  55. import ReportItem from "@/components/ItemComponent/reportItem.vue";
  56. import RoadshowItem from "@/components/ItemComponent/roadshowItem.vue";
  57. import suspenButton from "@/components/suspen_button.vue";
  58. import ActivityItem from "@/components/ItemComponent/activityItem.vue";
  59. import SearchBar from "@/components/search-bar/searchBar.vue";
  60. export default {
  61. data() {
  62. return {
  63. newDataList: [],
  64. page_no: 1,
  65. pageSize: 10,
  66. status: "loadmore",
  67. refresh: false, //正在下拉
  68. loadText: {
  69. loadmore: "上拉加载更多",
  70. loading: "加载中",
  71. nomore: "已经到底了",
  72. },
  73. info: {},
  74. };
  75. },
  76. components: {
  77. ChartItem,
  78. ReportItem,
  79. RoadshowItem,
  80. ActivityItem,
  81. suspenButton,
  82. SearchBar,
  83. },
  84. methods: {
  85. // 获取最先数据
  86. async getNewList() {
  87. const res = await Home.getNewList({
  88. PageSize: this.pageSize,
  89. CurrentIndex: this.page_no,
  90. });
  91. if (res.Ret === 200) {
  92. this.status = !res.Data.Paging.IsEnd ? "loadmore" : "nomore";
  93. let listArr = [];
  94. res.Data.List &&
  95. res.Data.List.forEach((item) => {
  96. listArr.push({
  97. Source: item.Source,
  98. Article: item.Article,
  99. Newchart: item.Newchart,
  100. Activity: item.Activity || item.Activityspecial,
  101. Roadshow: item.Roadshow || item.Activityvideo || item.Activityvoice,
  102. });
  103. });
  104. this.newDataList = this.page_no === 1 ? listArr : [...this.newDataList, ...listArr];
  105. if (this.refresh) {
  106. uni.stopPullDownRefresh();
  107. this.refresh = false;
  108. }
  109. }
  110. },
  111. // 微路演收藏
  112. async isCollectionHandeler(item) {
  113. const res = await Home.microRoadshowCollect({
  114. Id: item.Id,
  115. SourceType: item.Type,
  116. PageRouter: this.$store.state.pageRouterReport,
  117. });
  118. if (res.Ret === 200) {
  119. let index = this.newDataList.findIndex((key) => key.Roadshow && key.Roadshow.Id == item.Id);
  120. res.Data.Status == 1 ? (this.newDataList[index].Roadshow.IsCollect = true) : (this.newDataList[index].Roadshow.IsCollect = false);
  121. uni.showToast({
  122. title: res.Msg,
  123. duration: 2000,
  124. });
  125. }
  126. },
  127. // 跳转到我的页面
  128. goMyInfo() {
  129. uni.navigateTo({
  130. url: "/pageMy/myPage/myPage",
  131. });
  132. },
  133. // 跳转绑定页面
  134. goLogin() {
  135. uni.navigateTo({
  136. url: "/pageMy/login/login",
  137. });
  138. },
  139. /* 搜索 */
  140. goSearch() {
  141. this.$store.dispatch("checkHandle", "/pages-search/indedxSearch/indedxSearch?isType=" + this.topTabsActive + "&source=首页页面");
  142. },
  143. async getUserInfo() {
  144. const res = await Mine.getInfo();
  145. if (res.Ret === 200) {
  146. this.info = res.Data;
  147. }
  148. },
  149. },
  150. mounted() {
  151. uni.$on("updateNewList", (data) => {
  152. this.getNewList();
  153. });
  154. },
  155. onLoad() {
  156. this.getNewList();
  157. },
  158. onShow() {
  159. this.getUserInfo();
  160. this.getRecordTracking("首页");
  161. this.$store.commit("setRouterActivity", "首页");
  162. this.$store.commit("setRouterReport", "首页");
  163. },
  164. // 加载数据
  165. onReachBottom() {
  166. if (this.status === "nomore" || this.newDataList.length < 8) return;
  167. this.status = "loading";
  168. this.page_no++;
  169. this.getNewList();
  170. },
  171. // 下拉刷新
  172. onPullDownRefresh() {
  173. this.page_no = 1;
  174. this.refresh = true;
  175. this.getNewList();
  176. },
  177. /** 用户点击分享*/
  178. onShareAppMessage: function ({ from, target }) {
  179. if (from === "button") {
  180. let item = target.dataset.item;
  181. let audio_id = item.Type == 1 || item.AudioType == 1 ? item.Id : "";
  182. // type=2 -- 活动视频 type=3 -- 产业视频
  183. let video_id = item.Type == 2 || item.Type == 3 ? item.Id : "";
  184. let activity_id = item.Type == 2 && item.ActivityId > 0 ? item.ActivityId : "";
  185. let title_share = item.AudioTitle || item.Title;
  186. this.getRecordTracking("首页转发", { ActivityId: item.ActivityId, Id: item.Id, Type: item.Type });
  187. return {
  188. title: this.isHorzMobile ? "好友向您推荐此内容,上传名片享查研观向免费月卡!" : title_share,
  189. path: "/pages/material/material?topTabsActive=4" + "&audioShareId=" + audio_id + "&videoShareId=" + video_id + "&activityId=" + activity_id,
  190. imageUrl: item.AudioShareImg || item.ShareImg,
  191. };
  192. } else {
  193. return {
  194. title: this.isHorzMobile ? "好友向您推荐此内容,上传名片享查研观向免费月卡!" : "您手边的弘则研究素材检索库",
  195. path: "/pages/index/index",
  196. imageUrl: "https://hzstatic.hzinsights.com/cygx/czbk/home_share.png",
  197. success: (res) => {},
  198. fail: (err) => {},
  199. };
  200. }
  201. },
  202. };
  203. </script>
  204. <style lang="scss" scoped>
  205. .New-container {
  206. background-color: #f5f6fa;
  207. .top-content-box {
  208. position: sticky;
  209. top: 0;
  210. left: 0;
  211. width: 100%;
  212. z-index: 9;
  213. }
  214. /deep/ .nav-bar-wrap {
  215. padding-left: 35rpx;
  216. .box-img {
  217. display: flex;
  218. align-items: center;
  219. justify-content: center;
  220. width: 64rpx;
  221. height: 64rpx;
  222. margin-right: 20rpx;
  223. border-radius: 50%;
  224. overflow: hidden;
  225. image {
  226. width: 100%;
  227. height: 100%;
  228. }
  229. }
  230. }
  231. .content-ul {
  232. padding: 30rpx 10rpx;
  233. display: flex;
  234. justify-content: space-between;
  235. .item-ul {
  236. width: 49%;
  237. &:first-child {
  238. margin-right: 10rpx;
  239. }
  240. }
  241. }
  242. .bind-btn {
  243. padding-top: 110rpx;
  244. text-align: center;
  245. font-size: 24rpx;
  246. color: #3385ff;
  247. line-height: 23rpx;
  248. padding-bottom: 100rpx;
  249. }
  250. }
  251. </style>