index.vue 9.2 KB

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