index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. <template>
  2. <view class="container Index-container">
  3. <view class="index-fixed">
  4. <view class="index-header">
  5. <input type="text"
  6. placeholder="搜索您想要的纪要"
  7. placeholder-class="sea_ipt_placeholder"
  8. class="sea_ipt"
  9. v-model="searchTxt"
  10. disabled
  11. @click="goSearch"/>
  12. <icon type="search" size="15" class="search_ico"/>
  13. </view>
  14. <!-- 导航条 -->
  15. <view class="tab-cont">
  16. <scroll-view
  17. scroll-x="true"
  18. scroll-with-animation
  19. class="scroll-tab"
  20. @scroll="scrollMove"
  21. :scroll-left="scrollLeft"
  22. :scroll-into-view="'_'+tabIndex">
  23. <block v-for="(item, index) in tabBars" :key="item.ChartPermissionId">
  24. <view :id="'_'+index" class="scroll-tab-item" :class="{ active: tabAct_id == item.ChartPermissionId }" @click.stop="toggleTab(item,index)">
  25. {{item.PermissionName}}
  26. <image src="@/static/img/border_act.png" mode="" class="border_act" v-if="tabAct_id == item.ChartPermissionId"></image>
  27. </view>
  28. </block>
  29. <view class="limit-box" v-if="limitIsShow">
  30. <image class="limit-img" src="../../static/img/limit_icon.png" mode=""></image>
  31. </view>
  32. </scroll-view>
  33. </view>
  34. </view>
  35. <block v-if="haveData">
  36. <view class="data-cont">
  37. <view class="report-ul">
  38. <view class="report-item" v-for="(report,index) in dataList" :key="index" v-if="index%2 === 0" @click="goDetail(report)">
  39. <!-- <view class="item-content"><u-parse :html="report.Body"></u-parse></view> -->
  40. <view class="item-content">{{report.Body}}</view>
  41. <view class="line"></view>
  42. <text class="item-title">{{report.Title}}</text>
  43. <view class="item-abstract text_twoLine" v-if="report.ExpertBackground">
  44. <image src="@/static/img/report_ico.png" class="report_ico"></image>
  45. {{report.ExpertBackground}}
  46. </view>
  47. <view class="item-createtime">
  48. <text>{{report.PublishDate}}</text>
  49. <view class="item-examine">
  50. <image src="../../static/img/examine_icon.png" v-if="report.IsResearch"></image>
  51. <text v-if="report.IsResearch">{{report.Pv}}</text>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="report-ul">
  57. <view class="report-item" v-for="(report,index) in dataList" :key="index" v-if="index%2 !== 0" @click="goDetail(report)">
  58. <!-- <view class="item-content"><u-parse :html="report.Body"></u-parse></view> -->
  59. <view class="item-content">{{report.Body}}</view>
  60. <view class="line"></view>
  61. <text class="item-title">{{report.Title}}</text>
  62. <view class="item-abstract text_twoLine" v-if="report.ExpertBackground">
  63. <image src="@/static/img/report_ico.png" class="report_ico"></image>
  64. {{report.ExpertBackground}}
  65. </view>
  66. <view class="item-createtime">
  67. <text>{{report.PublishDate}}</text>
  68. <view class="item-examine">
  69. <image src="../../static/img/examine_icon.png" v-if="report.IsResearch"></image>
  70. <text v-if="report.IsResearch">{{report.Pv}}</text>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. <u-loadmore :status="status" icon-type="flower" :load-text="loadText" margin-top="20"/>
  77. </block>
  78. <view class="nodata" v-else-if="haveData===false" style="padding-top: 400rpx;">
  79. <image src="@/static/img/nodata.png" mode="" class="nodata_ico"></image>
  80. <text>暂时没有行业数据</text>
  81. </view>
  82. <image class="advice_ico" src="https://hzstatic.hzinsights.com/cygx/czbk/advice_ico.png" @click="adviceHandle"></image>
  83. </view>
  84. </template>
  85. <script>
  86. import {Home} from '@/config/api.js';
  87. import { Throttle } from '@/config/util.js'
  88. let app = getApp()
  89. export default {
  90. data() {
  91. return {
  92. refresh:false,
  93. pageSize:10,//条数
  94. pageNum:1,//页码
  95. haveMore:true,//是否有更多数据
  96. haveData:null,//是否有数据
  97. tabAct_id:0,
  98. //数据列表
  99. dataList:[],
  100. // tab
  101. tabBars:[],
  102. status:'loadmore',
  103. loadText: {
  104. loadmore: '上拉加载更多',
  105. loading: '加载中',
  106. nomore: '已经到底了'
  107. },
  108. totalPage:'',
  109. limitIsShow:false,//限免的隐现
  110. scrollLeft:0
  111. }
  112. },
  113. watch: {
  114. tabAct_id: {
  115. handler() {
  116. this.getReportList();
  117. },
  118. immediate:true
  119. }
  120. },
  121. onLoad(optios) {
  122. this.$store.dispatch("checkHandle",{type:'load',val:optios}).then((res) => {
  123. if(optios.tabid){
  124. this.tabAct_id = optios.tabid
  125. }
  126. this.getTabs();
  127. })
  128. },
  129. onShow() {
  130. this.$store.dispatch("statistics",{PageType:'Summary',ChartPermissionId:Number(this.tabAct_id)})
  131. // #ifdef MP-WEIXIN
  132. uni.hideHomeButton()
  133. // #endif
  134. },
  135. methods: {
  136. /* 切换分类 */
  137. toggleTab (item,index) {
  138. if(this.tabAct_id !== item.ChartPermissionId) {
  139. this.tabAct_id = item.ChartPermissionId;
  140. this.pageNum = 1;
  141. uni.pageScrollTo({
  142. scrollTop: 0,
  143. duration: 0,
  144. });
  145. this.$store.dispatch("statistics",{PageType:'Summary',ChartPermissionId:Number(this.tabAct_id)})
  146. }
  147. this.getRectTab(index)
  148. },
  149. getRectTab(index){
  150. // const query = uni.createSelectorQuery().in(this);
  151. // query.select(`#_${index}`).boundingClientRect(rect => {
  152. // var screen = wx.getSystemInfoSync().windowWidth/2;
  153. // //获取点击item的左边坐标
  154. // var left = rect.left;
  155. // //获取item的宽度de 一半
  156. // var subhalfwidth= rect.width/2
  157. // //需要scrollview 移动的距离是
  158. // var juli = left-screen
  159. // var zuizhongjuli = juli+subhalfwidth
  160. // this.scrollLeft = this.scrollLeft+=zuizhongjuli
  161. // }).exec();
  162. },
  163. scrollMove(e) {
  164. this.scrollLeft = e.detail.scrollLeft;
  165. },
  166. /* 获取列表 */
  167. getReportList() {
  168. Home.getList({
  169. PageSize: this.pageSize,
  170. CurrentIndex: this.pageNum,
  171. ChartPermissionId:Number(this.tabAct_id) || 0
  172. }).then(res => {
  173. if(res.Ret === 200) {
  174. if(!res.Data.HaveResearch){
  175. this.$util.modalShow('','您暂无查看研选权限','',()=>{
  176. uni.reLaunch({
  177. url:'/pages/index/index'
  178. })
  179. })
  180. }
  181. this.status = this.pageNum < res.Data.Paging.Pages ? 'loadmore' : 'nomore'
  182. // this.totalPage = res.Data.Paging.Pages;//总页数
  183. if(this.pageNum === 1) {
  184. this.dataList = res.Data.List || []
  185. this.haveData = this.dataList.length ? true : false;
  186. }else {
  187. this.dataList = this.dataList.concat(res.Data.List)
  188. }
  189. if(this.refresh) {
  190. uni.stopPullDownRefresh();
  191. this.refresh = false;
  192. }
  193. }
  194. })
  195. },
  196. /* 获取tab分类 */
  197. getTabs() {
  198. Home.Tab().then(res => {
  199. if(res.Ret === 200) {
  200. let arr = res.Data.List;
  201. arr.unshift({
  202. ChartPermissionId: 0,
  203. PermissionName: "最新"
  204. })
  205. this.tabBars = arr;
  206. this.limitIsShow=this.tabBars.some(item=>item.IsShowSustainable)
  207. if(this.tabAct_id==0){
  208. this.getReportList();
  209. }
  210. }
  211. })
  212. },
  213. /* 进入详情 校验是否有该品种权限 */
  214. goDetail(item) {
  215. /* 无需授权且已绑定 检验是或否有权限 */
  216. this.$store.dispatch('checkHandle').then(res => {
  217. app.globalData.isAuth = res.IsAuth;
  218. app.globalData.isBind = res.IsBind;
  219. if((!res.IsAuth) && (!res.IsBind)) { // 已授权已绑定
  220. uni.navigateTo({
  221. url:'/pages/reportDetail/reportDetail?id=' + item.ArticleId,
  222. });
  223. }else if(res.IsAuth) { //未授权
  224. uni.navigateTo({
  225. url:'/pages/authGuide/authGuide'
  226. })
  227. }else if(res.IsBind && !res.IsAuth){ //已授权未绑定
  228. uni.navigateTo({
  229. url:'/pages/login/login'
  230. })
  231. }
  232. })
  233. },
  234. /* 搜索 */
  235. goSearch() {
  236. /* */
  237. this.$store.dispatch('checkHandle').then(res => {
  238. app.globalData.isAuth = res.IsAuth;
  239. app.globalData.isBind = res.IsBind;
  240. if((!res.IsAuth) && (!res.IsBind)) { //已授权已绑定
  241. uni.navigateTo({
  242. url:'/pages/search/search',
  243. });
  244. }else if(res.IsAuth) { //未授权
  245. uni.navigateTo({
  246. url:'/pages/authGuide/authGuide'
  247. })
  248. }else if(res.IsBind && !res.IsAuth){ //已授权未绑定
  249. uni.navigateTo({
  250. url:'/pages/login/login'
  251. })
  252. }
  253. })
  254. },
  255. adviceHandle() {
  256. this.$store.dispatch('checkHandle').then(res => {
  257. app.globalData.isAuth = res.IsAuth;
  258. app.globalData.isBind = res.IsBind;
  259. if((!res.IsAuth) && (!res.IsBind)) { //已授权已绑定
  260. uni.navigateTo({url:'/pages/advice/advice'});
  261. }else if(res.IsAuth) { //未授权
  262. uni.navigateTo({
  263. url:'/pages/authGuide/authGuide'
  264. })
  265. }else if(res.IsBind && !res.IsAuth){ //已授权未绑定
  266. uni.navigateTo({
  267. url:'/pages/login/login'
  268. })
  269. }
  270. })
  271. }
  272. },
  273. /* 下拉刷新 */
  274. onPullDownRefresh: Throttle(function() {
  275. this.pageNum = 1;
  276. this.refresh = true;
  277. this.getReportList()
  278. }),
  279. // 上拉加载
  280. onReachBottom: Throttle(function() {
  281. if(this.status === 'nomore') return ;
  282. this.status = 'loading';
  283. this.pageNum++;
  284. this.getReportList()
  285. }),
  286. /**
  287. * 用户点击分享
  288. */
  289. onShareAppMessage: function (res) {
  290. return {
  291. title: '您手边的弘则研究素材检索库',
  292. path: '/pages/index/index?tabid='+this.tabAct_id,
  293. imageUrl: this.tabAct_id==0 ?'https://hzstatic.hzinsights.com/cygx/czbk/home_share.png' : '' ,
  294. success: (res)=> {
  295. },
  296. fail: (err)=> {
  297. }
  298. }
  299. },
  300. // onShareTimeline: function(res) {
  301. // return {
  302. // title:'111',
  303. // // query:'',
  304. // // imageUrl:''
  305. // }
  306. // }
  307. }
  308. </script>
  309. <style lang="scss">
  310. .Index-container {
  311. background-color: #F7F7F7;
  312. font-size: 30rpx;
  313. .index-fixed {
  314. width: 750rpx;
  315. position: fixed;
  316. left: 0;
  317. top: 0;
  318. z-index: 999;
  319. .index-header {
  320. background-color: #fff;
  321. padding: 32rpx 34rpx;
  322. position: relative;
  323. .sea_ipt_placeholder {
  324. color: #8D8D8D;
  325. opacity: 0.7;
  326. }
  327. .sea_ipt {
  328. width: 100%;
  329. height: 70rpx;
  330. font-size: 30rpx;
  331. color: #707070;
  332. background-color: #F6F6F6;
  333. padding: 0 34rpx 0 70rpx;
  334. border-radius: 70rpx;
  335. border: 1rpx solid #E5E5E5;
  336. }
  337. .search_ico {
  338. display: block;
  339. position: absolute;
  340. color: #8D8D8D;
  341. left: 60rpx;
  342. top: 50%;
  343. z-index: 100;
  344. transform: translateY(-50%);
  345. }
  346. }
  347. .tab-cont {
  348. padding: 0 26rpx ;
  349. background-color: #fff;
  350. font-size: 32rpx;
  351. box-shadow: 0 3rpx 6rpx rgba(187,216,255,0.2);
  352. .scroll-tab {
  353. position: relative;
  354. width: 100%;
  355. white-space: nowrap;
  356. }
  357. .limit-box {
  358. position: absolute;
  359. text-align: center;
  360. display: inline-block;
  361. padding-right: 50rpx;
  362. top: -9rpx;
  363. margin-left: -38rpx;
  364. image {
  365. width: 46rpx;
  366. height: 26rpx;
  367. }
  368. }
  369. .scroll-tab-item {
  370. // flex-grow: 1;
  371. text-align: center;
  372. display: inline-block;
  373. padding: 10rpx 8rpx 20rpx 8rpx;
  374. margin-right: 35rpx;
  375. border-bottom: 8rpx solid transparent;
  376. position: relative;
  377. &:last-child {
  378. margin-right: 0;
  379. }
  380. &.active {
  381. border-bottom: none;
  382. color: #2C83FF;
  383. font-weight: 700;
  384. }
  385. .border_act {
  386. width: 100%;
  387. height: 8rpx;
  388. position: absolute;
  389. bottom: 0;
  390. left: 0;
  391. }
  392. }
  393. }
  394. }
  395. .data-cont {
  396. padding: 228rpx 20rpx 10rpx;
  397. display: flex;
  398. .report-ul {
  399. width: 50%;
  400. &:first-child {
  401. margin-right: 10rpx;
  402. }
  403. .report-item {
  404. padding: 20rpx 20rpx 24rpx 20rpx;
  405. margin-bottom: 20rpx;
  406. border-radius: 8rpx;
  407. box-shadow: 0 3rpx 6rpx rgba($color: #000000, $alpha: 0.16);
  408. background: #fff;
  409. .item-content {
  410. height: 273rpx;
  411. font-size: 24rpx;
  412. line-height: 40rpx;
  413. color: #7F7F7F;
  414. overflow: hidden;
  415. text-overflow: ellipsis;
  416. display: -webkit-box;
  417. -webkit-line-clamp: 7;
  418. -webkit-box-orient: vertical;
  419. }
  420. .line {
  421. margin: 18rpx 0;
  422. content: '';
  423. width: 100%;
  424. height: 1px;
  425. padding: 0 32rpx;
  426. box-sizing: border-box;
  427. background-color: #E5E5E5;
  428. -webkit-transform: scale(1, 0.5);
  429. transform: scale(1, 0.5);
  430. -webkit-transform-origin: center bottom;
  431. transform-origin: center bottom;
  432. }
  433. .item-title {
  434. font-size: 28rpx;
  435. color: #4A4A4A;
  436. margin-bottom: 10rpx;
  437. }
  438. .item-abstract {
  439. font-size: 26rpx;
  440. color: #6A6A6A;
  441. margin-bottom: 10rpx;
  442. .report_ico {
  443. width: 32rpx;
  444. height: 26rpx;
  445. margin-right: 20rpx;
  446. display: inline-block;
  447. }
  448. }
  449. .item-createtime {
  450. display: flex;
  451. align-items: center;
  452. justify-content: space-between;
  453. color: #ACACAC;
  454. font-size: 24rpx;
  455. .item-examine {
  456. display: flex;
  457. align-items: center;
  458. image {
  459. width: 30rpx;
  460. height: 24rpx;
  461. margin: 0 10rpx 0 15rpx;
  462. }
  463. }
  464. }
  465. }
  466. }
  467. }
  468. .advice_ico {
  469. width: 81rpx;
  470. height: 81rpx;
  471. position: fixed;
  472. right: 30rpx;
  473. bottom: 214rpx;
  474. }
  475. }
  476. </style>