index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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. totalPage:''
  92. }
  93. },
  94. watch: {
  95. tabAct_id: {
  96. handler() {
  97. this.getReportList();
  98. },
  99. immediate:true
  100. }
  101. },
  102. onLoad() {
  103. this.getTabs();
  104. },
  105. onShow() {
  106. // #ifdef MP-WEIXIN
  107. uni.hideHomeButton()
  108. // #endif
  109. },
  110. methods: {
  111. /* 切换分类 */
  112. toggleTab (item,index) {
  113. if(this.tabAct_id !== item.ChartPermissionId) {
  114. this.tabAct_id = item.ChartPermissionId;
  115. this.pageNum = 1;
  116. uni.pageScrollTo({
  117. scrollTop: 0,
  118. duration: 0,
  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. // this.totalPage = res.Data.Paging.Pages;//总页数
  132. if(this.pageNum === 1) {
  133. this.dataList = res.Data.List || []
  134. this.haveData = this.dataList.length ? true : false;
  135. }else {
  136. this.dataList = this.dataList.concat(res.Data.List)
  137. }
  138. if(this.refresh) {
  139. uni.stopPullDownRefresh();
  140. this.refresh = false;
  141. }
  142. }
  143. })
  144. },
  145. /* 获取tab分类 */
  146. getTabs() {
  147. Home.Tab().then(res => {
  148. if(res.Ret === 200) {
  149. let arr = res.Data.List;
  150. arr.unshift({
  151. ChartPermissionId: 0,
  152. PermissionName: "最新"
  153. })
  154. this.tabBars = arr;
  155. }
  156. })
  157. },
  158. /* 进入详情 校验是否有该品种权限 */
  159. goDetail(item) {
  160. /* 无需授权且已绑定 检验是或否有权限 */
  161. this.$store.dispatch('checkHandle').then(res => {
  162. app.globalData.isAuth = res.IsAuth;
  163. app.globalData.isBind = res.IsBind;
  164. if((!res.IsAuth) && (!res.IsBind)) { // 已授权已绑定
  165. uni.navigateTo({
  166. url:'/pages/reportDetail/reportDetail?id=' + item.ArticleId,
  167. });
  168. }else if(res.IsAuth) { //未授权
  169. uni.navigateTo({
  170. url:'/pages/authGuide/authGuide'
  171. })
  172. }else if(res.IsBind && !res.IsAuth){ //已授权未绑定
  173. uni.navigateTo({
  174. url:'/pages/login/login'
  175. })
  176. }
  177. })
  178. },
  179. /* 搜索 */
  180. goSearch() {
  181. /* */
  182. this.$store.dispatch('checkHandle').then(res => {
  183. app.globalData.isAuth = res.IsAuth;
  184. app.globalData.isBind = res.IsBind;
  185. if((!res.IsAuth) && (!res.IsBind)) { //已授权已绑定
  186. uni.navigateTo({
  187. url:'/pages/search/search',
  188. });
  189. }else if(res.IsAuth) { //未授权
  190. uni.navigateTo({
  191. url:'/pages/authGuide/authGuide'
  192. })
  193. }else if(res.IsBind && !res.IsAuth){ //已授权未绑定
  194. uni.navigateTo({
  195. url:'/pages/login/login'
  196. })
  197. }
  198. })
  199. },
  200. adviceHandle() {
  201. this.$store.dispatch('checkHandle').then(res => {
  202. app.globalData.isAuth = res.IsAuth;
  203. app.globalData.isBind = res.IsBind;
  204. if((!res.IsAuth) && (!res.IsBind)) { //已授权已绑定
  205. uni.navigateTo({url:'/pages/advice/advice'});
  206. }else if(res.IsAuth) { //未授权
  207. uni.navigateTo({
  208. url:'/pages/authGuide/authGuide'
  209. })
  210. }else if(res.IsBind && !res.IsAuth){ //已授权未绑定
  211. uni.navigateTo({
  212. url:'/pages/login/login'
  213. })
  214. }
  215. })
  216. }
  217. },
  218. /* 下拉刷新 */
  219. onPullDownRefresh: Throttle(function() {
  220. this.pageNum = 1;
  221. this.refresh = true;
  222. this.getReportList()
  223. }),
  224. // 上拉加载
  225. onReachBottom: Throttle(function() {
  226. if(this.status === 'nomore') return ;
  227. this.status = 'loading';
  228. this.pageNum++;
  229. this.getReportList()
  230. }),
  231. /**
  232. * 用户点击分享
  233. */
  234. onShareAppMessage: function (res) {
  235. return {
  236. title: '您手边的研究素材库',
  237. path: '/pages/index/index',
  238. imageUrl: '/static/img/home_share.jpg',
  239. success: (res)=> {
  240. },
  241. fail: (err)=> {
  242. }
  243. }
  244. },
  245. // onShareTimeline: function(res) {
  246. // return {
  247. // title:'111',
  248. // // query:'',
  249. // // imageUrl:''
  250. // }
  251. // }
  252. }
  253. </script>
  254. <style lang="scss">
  255. .Index-container {
  256. background-color: #F7F7F7;
  257. font-size: 30rpx;
  258. .index-fixed {
  259. width: 750rpx;
  260. position: fixed;
  261. left: 0;
  262. top: 0;
  263. z-index: 999;
  264. .index-header {
  265. background-color: #fff;
  266. padding: 32rpx 34rpx;
  267. position: relative;
  268. .sea_ipt_placeholder {
  269. color: #8D8D8D;
  270. opacity: 0.7;
  271. }
  272. .sea_ipt {
  273. width: 100%;
  274. height: 70rpx;
  275. font-size: 30rpx;
  276. color: #707070;
  277. background-color: #F6F6F6;
  278. padding: 0 34rpx 0 70rpx;
  279. border-radius: 70rpx;
  280. border: 1rpx solid #E5E5E5;
  281. }
  282. .search_ico {
  283. display: block;
  284. position: absolute;
  285. color: #8D8D8D;
  286. left: 60rpx;
  287. top: 50%;
  288. z-index: 100;
  289. transform: translateY(-50%);
  290. }
  291. }
  292. .tab-cont {
  293. padding: 0 26rpx;
  294. background-color: #fff;
  295. font-size: 32rpx;
  296. box-shadow: 0 3rpx 6rpx rgba(187,216,255,0.2);
  297. .scroll-tab {
  298. width: 100%;
  299. white-space: nowrap;
  300. }
  301. .scroll-tab-item {
  302. // flex-grow: 1;
  303. text-align: center;
  304. display: inline-block;
  305. padding: 0 8rpx 30rpx 8rpx;
  306. margin-right: 40rpx;
  307. border-bottom: 8rpx solid transparent;
  308. position: relative;
  309. &:last-child {
  310. margin-right: 0;
  311. }
  312. &.active {
  313. border-bottom: none;
  314. color: #385388;
  315. font-weight: 700;
  316. }
  317. .border_act {
  318. width: 100%;
  319. height: 8rpx;
  320. position: absolute;
  321. bottom: 0;
  322. left: 0;
  323. }
  324. }
  325. }
  326. }
  327. .data-cont {
  328. padding: 228rpx 20rpx 10rpx;
  329. display: flex;
  330. .report-ul {
  331. width: 50%;
  332. &:first-child {
  333. margin-right: 10rpx;
  334. }
  335. .report-item {
  336. padding: 20rpx 20rpx 24rpx 20rpx;
  337. margin-bottom: 20rpx;
  338. border-radius: 8rpx;
  339. box-shadow: 0 3rpx 6rpx rgba($color: #000000, $alpha: 0.16);
  340. background: #fff;
  341. .item-content {
  342. height: 273rpx;
  343. font-size: 24rpx;
  344. line-height: 40rpx;
  345. color: #7F7F7F;
  346. overflow: hidden;
  347. text-overflow: ellipsis;
  348. display: -webkit-box;
  349. -webkit-line-clamp: 7;
  350. -webkit-box-orient: vertical;
  351. }
  352. .line {
  353. margin: 18rpx 0;
  354. content: '';
  355. width: 100%;
  356. height: 1px;
  357. padding: 0 32rpx;
  358. box-sizing: border-box;
  359. background-color: #E5E5E5;
  360. -webkit-transform: scale(1, 0.5);
  361. transform: scale(1, 0.5);
  362. -webkit-transform-origin: center bottom;
  363. transform-origin: center bottom;
  364. }
  365. .item-title {
  366. font-size: 28rpx;
  367. color: #4A4A4A;
  368. margin-bottom: 10rpx;
  369. }
  370. .item-abstract {
  371. font-size: 26rpx;
  372. color: #6A6A6A;
  373. margin-bottom: 10rpx;
  374. .report_ico {
  375. width: 32rpx;
  376. height: 26rpx;
  377. margin-right: 20rpx;
  378. display: inline-block;
  379. }
  380. }
  381. .item-createtime {
  382. color: #ACACAC;
  383. font-size: 24rpx;
  384. }
  385. }
  386. }
  387. }
  388. .advice_ico {
  389. width: 81rpx;
  390. height: 81rpx;
  391. position: fixed;
  392. right: 30rpx;
  393. bottom: 214rpx;
  394. }
  395. }
  396. </style>