index.vue 9.1 KB

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