index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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-into-view="'_'+tabIndex">
  21. <block v-for="(item, index) in tabBars" :key="item.ChartPermissionId">
  22. <view :id="'_'+index" class="scroll-tab-item" :class="{ active: tabAct_id === item.ChartPermissionId }" @click.stop="toggleTab(item,index)">
  23. {{item.PermissionName}}
  24. <image src="@/static/img/border_act.png" mode="" class="border_act" v-if="tabAct_id === item.ChartPermissionId"></image>
  25. </view>
  26. </block>
  27. </scroll-view>
  28. </view>
  29. </view>
  30. <block v-if="haveData">
  31. <view class="data-cont">
  32. <view class="report-ul">
  33. <view class="report-item" v-for="(report,index) in dataList" :key="index" v-if="index%2 === 0" @click="goDetail(report)">
  34. <!-- <view class="item-content"><u-parse :html="report.Body"></u-parse></view> -->
  35. <view class="item-content">{{report.Body}}</view>
  36. <view class="line"></view>
  37. <text class="item-title">{{report.Title}}</text>
  38. <view class="item-abstract text_twoLine" v-if="report.ExpertBackground">
  39. <image src="@/static/img/report_ico.png" class="report_ico"></image>
  40. {{report.ExpertBackground}}
  41. </view>
  42. <text class="item-createtime">{{report.CreateDate}}</text>
  43. </view>
  44. </view>
  45. <view class="report-ul">
  46. <view class="report-item" v-for="(report,index) in dataList" :key="index" v-if="index%2 !== 0" @click="goDetail(report)">
  47. <!-- <view class="item-content"><u-parse :html="report.Body"></u-parse></view> -->
  48. <view class="item-content">{{report.Body}}</view>
  49. <view class="line"></view>
  50. <text class="item-title">{{report.Title}}</text>
  51. <view class="item-abstract text_twoLine" v-if="report.ExpertBackground">
  52. <image src="@/static/img/report_ico.png" class="report_ico"></image>
  53. {{report.ExpertBackground}}
  54. </view>
  55. <text class="item-createtime">{{report.CreateDate}}</text>
  56. </view>
  57. </view>
  58. </view>
  59. <u-loadmore :status="status" icon-type="flower" :load-text="loadText" margin-top="20"/>
  60. </block>
  61. <view class="nodata" v-else-if="haveData===false" style="padding-top: 400rpx;">
  62. <image src="@/static/img/nodata.png" mode="" class="nodata_ico"></image>
  63. <text>暂时没有行业数据</text>
  64. </view>
  65. <image class="advice_ico" src="@/static/img/advice_ico.png" @click="adviceHandle"></image>
  66. </view>
  67. </template>
  68. <script>
  69. import {Home} from '@/config/api.js';
  70. import { Throttle } from '@/config/util.js'
  71. let app = getApp()
  72. export default {
  73. data() {
  74. return {
  75. refresh:false,
  76. pageSize:10,//条数
  77. pageNum:1,//页码
  78. haveMore:true,//是否有更多数据
  79. haveData:null,//是否有数据
  80. tabAct_id:0,
  81. //数据列表
  82. dataList:[],
  83. // tab
  84. tabBars:[],
  85. status:'loadmore',
  86. loadText: {
  87. loadmore: '上拉加载更多',
  88. loading: '加载中',
  89. nomore: '已经到底了'
  90. },
  91. }
  92. },
  93. watch: {
  94. tabAct_id: {
  95. handler() {
  96. this.getReportList();
  97. },
  98. immediate:true
  99. }
  100. },
  101. onLoad() {
  102. this.getTabs();
  103. },
  104. onShow() {
  105. // #ifdef MP-WEIXIN
  106. uni.hideHomeButton()
  107. // #endif
  108. },
  109. methods: {
  110. /* 切换分类 */
  111. toggleTab (item,index) {
  112. if(this.tabAct_id !== item.ChartPermissionId) {
  113. this.tabAct_id = item.ChartPermissionId;
  114. this.pageNum = 1;
  115. uni.pageScrollTo({
  116. scrollTop: 0,
  117. duration: 0,
  118. /* */
  119. });
  120. }
  121. },
  122. /* 获取列表 */
  123. getReportList() {
  124. Home.getList({
  125. PageSize: this.pageSize,
  126. CurrentIndex: this.pageNum,
  127. ChartPermissionId:this.tabAct_id || 0
  128. }).then(res => {
  129. if(res.Ret === 200) {
  130. this.status = this.pageNum < res.Data.Paging.Pages ? 'loadmore' : 'nomore'
  131. if(this.pageNum === 1) {
  132. this.dataList = res.Data.List || []
  133. this.haveData = this.dataList.length ? true : false;
  134. }else {
  135. this.dataList = this.dataList.concat(res.Data.List)
  136. }
  137. if(this.refresh) {
  138. uni.stopPullDownRefresh();
  139. this.refresh = false;
  140. }
  141. }
  142. })
  143. },
  144. /* 获取tab分类 */
  145. getTabs() {
  146. Home.Tab().then(res => {
  147. if(res.Ret === 200) {
  148. let arr = res.Data.List;
  149. arr.unshift({
  150. ChartPermissionId: 0,
  151. PermissionName: "最新"
  152. })
  153. this.tabBars = arr;
  154. }
  155. })
  156. },
  157. /* 进入详情 校验是否有该品种权限 */
  158. goDetail(item) {
  159. /* 无需授权且已绑定 检验是或否有权限 */
  160. this.$store.dispatch('checkHandle').then(res => {
  161. app.globalData.isAuth = res.IsAuth;
  162. app.globalData.isBind = res.IsBind;
  163. if((!res.IsAuth) && (!res.IsBind)) { // 已授权已绑定
  164. // if (res.PermissionName.includes(item.CategoryName)) {
  165. uni.navigateTo({
  166. url:'/pages/reportDetail/reportDetail?id=' + item.ArticleId,
  167. });
  168. // }else {
  169. // this.authTip();
  170. // }
  171. }else if(res.IsAuth) { //未授权
  172. uni.navigateTo({
  173. url:'/pages/authGuide/authGuide'
  174. })
  175. }else if(res.IsBind && !res.IsAuth){ //已授权未绑定
  176. uni.navigateTo({
  177. url:'/pages/login/login'
  178. })
  179. }
  180. })
  181. },
  182. /* 搜索 */
  183. goSearch() {
  184. /* */
  185. this.$store.dispatch('checkHandle').then(res => {
  186. app.globalData.isAuth = res.IsAuth;
  187. app.globalData.isBind = res.IsBind;
  188. if((!res.IsAuth) && (!res.IsBind)) { //已授权已绑定
  189. uni.navigateTo({
  190. url:'/pages/search/search',
  191. });
  192. }else if(res.IsAuth) { //未授权
  193. uni.navigateTo({
  194. url:'/pages/authGuide/authGuide'
  195. })
  196. }else if(res.IsBind && !res.IsAuth){ //已授权未绑定
  197. uni.navigateTo({
  198. url:'/pages/login/login'
  199. })
  200. }
  201. })
  202. },
  203. adviceHandle() {
  204. this.$store.dispatch('checkHandle').then(res => {
  205. app.globalData.isAuth = res.IsAuth;
  206. app.globalData.isBind = res.IsBind;
  207. if((!res.IsAuth) && (!res.IsBind)) { //已授权已绑定
  208. uni.navigateTo({url:'/pages/advice/advice'});
  209. }else if(res.IsAuth) { //未授权
  210. uni.navigateTo({
  211. url:'/pages/authGuide/authGuide'
  212. })
  213. }else if(res.IsBind && !res.IsAuth){ //已授权未绑定
  214. uni.navigateTo({
  215. url:'/pages/login/login'
  216. })
  217. }
  218. })
  219. }
  220. },
  221. /* 下拉刷新 */
  222. onPullDownRefresh() {
  223. this.pageNum = 1;
  224. this.refresh = true;
  225. this.getReportList()
  226. },
  227. // 上拉加载
  228. onReachBottom: Throttle(function() {
  229. if(this.status === 'nomore') return ;
  230. this.status = 'loading';
  231. this.pageNum++;
  232. this.getReportList()
  233. }),
  234. /**
  235. * 用户点击分享
  236. */
  237. onShareAppMessage: function (res) {
  238. return {
  239. title: '您手边的研究素材库',
  240. path: '/pages/index/index',
  241. // imageUrl: '/images/icons/wx_share.png',
  242. success: (res)=> {
  243. },
  244. fail: (err)=> {
  245. }
  246. }
  247. },
  248. // onShareTimeline: function(res) {
  249. // return {
  250. // title:'111',
  251. // // query:'',
  252. // // imageUrl:''
  253. // }
  254. // }
  255. }
  256. </script>
  257. <style lang="scss">
  258. .Index-container {
  259. background-color: #F7F7F7;
  260. font-size: 30rpx;
  261. .index-fixed {
  262. width: 750rpx;
  263. position: fixed;
  264. left: 0;
  265. top: 0;
  266. z-index: 999;
  267. .index-header {
  268. background-color: #fff;
  269. padding: 32rpx 34rpx;
  270. position: relative;
  271. .sea_ipt_placeholder {
  272. color: #8D8D8D;
  273. opacity: 0.7;
  274. }
  275. .sea_ipt {
  276. width: 100%;
  277. height: 70rpx;
  278. font-size: 30rpx;
  279. color: #707070;
  280. background-color: #F6F6F6;
  281. padding: 0 34rpx 0 70rpx;
  282. border-radius: 70rpx;
  283. border: 1rpx solid #E5E5E5;
  284. }
  285. .search_ico {
  286. display: block;
  287. position: absolute;
  288. color: #8D8D8D;
  289. left: 60rpx;
  290. top: 50%;
  291. z-index: 100;
  292. transform: translateY(-50%);
  293. }
  294. }
  295. .tab-cont {
  296. padding: 0 26rpx;
  297. background-color: #fff;
  298. font-size: 32rpx;
  299. box-shadow: 0 3rpx 6rpx rgba(187,216,255,0.2);
  300. .scroll-tab {
  301. width: 100%;
  302. white-space: nowrap;
  303. }
  304. .scroll-tab-item {
  305. // flex-grow: 1;
  306. text-align: center;
  307. display: inline-block;
  308. padding: 0 8rpx 30rpx 8rpx;
  309. margin-right: 40rpx;
  310. border-bottom: 8rpx solid transparent;
  311. position: relative;
  312. &:last-child {
  313. margin-right: 0;
  314. }
  315. &.active {
  316. border-bottom: none;
  317. color: #385388;
  318. font-weight: 700;
  319. }
  320. .border_act {
  321. width: 100%;
  322. height: 8rpx;
  323. position: absolute;
  324. bottom: 0;
  325. left: 0;
  326. }
  327. }
  328. }
  329. }
  330. .data-cont {
  331. padding: 228rpx 20rpx 10rpx;
  332. display: flex;
  333. .report-ul {
  334. width: 50%;
  335. &:first-child {
  336. margin-right: 10rpx;
  337. }
  338. .report-item {
  339. padding: 20rpx 20rpx 24rpx 20rpx;
  340. margin-bottom: 20rpx;
  341. border-radius: 8rpx;
  342. box-shadow: 0 3rpx 6rpx rgba($color: #000000, $alpha: 0.16);
  343. background: #fff;
  344. .item-content {
  345. height: 273rpx;
  346. font-size: 24rpx;
  347. line-height: 40rpx;
  348. color: #7F7F7F;
  349. overflow: hidden;
  350. text-overflow: ellipsis;
  351. display: -webkit-box;
  352. -webkit-line-clamp: 7;
  353. -webkit-box-orient: vertical;
  354. }
  355. .line {
  356. margin: 18rpx 0;
  357. content: '';
  358. width: 100%;
  359. height: 1px;
  360. padding: 0 32rpx;
  361. box-sizing: border-box;
  362. background-color: #E5E5E5;
  363. -webkit-transform: scale(1, 0.5);
  364. transform: scale(1, 0.5);
  365. -webkit-transform-origin: center bottom;
  366. transform-origin: center bottom;
  367. }
  368. .item-title {
  369. font-size: 28rpx;
  370. color: #4A4A4A;
  371. margin-bottom: 10rpx;
  372. }
  373. .item-abstract {
  374. font-size: 26rpx;
  375. color: #6A6A6A;
  376. margin-bottom: 10rpx;
  377. .report_ico {
  378. width: 32rpx;
  379. height: 26rpx;
  380. margin-right: 20rpx;
  381. display: inline-block;
  382. }
  383. }
  384. .item-createtime {
  385. color: #ACACAC;
  386. font-size: 24rpx;
  387. }
  388. }
  389. }
  390. }
  391. .advice_ico {
  392. width: 81rpx;
  393. height: 81rpx;
  394. position: fixed;
  395. right: 30rpx;
  396. bottom: 214rpx;
  397. }
  398. }
  399. </style>