goods-secondary.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. <template>
  2. <view class="container instrument">
  3. <!--选项卡-->
  4. <view class="home-hotmaintab-fixed">
  5. <view class="home-flex-tab show">
  6. <view class="flex text-white">
  7. <view class="basis-xxl">
  8. <scroll-view scroll-x class="nav z" scroll-with-animation :scroll-left="headTab.scrollLeft">
  9. <block v-for="(item,index) in headTab.list" :key="index">
  10. <view class="cu-item" :class="index==headTab.TabCur?'select':''" @tap="tabSelect(index,item)" :data-id="index">
  11. <view>{{item.name}}</view>
  12. <view class="tab-dot bg-white"/>
  13. </view>
  14. </block>
  15. </scroll-view>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="container-main">
  21. <!-- 商品专题 -->
  22. <template v-if="isActivityFlag">
  23. <view class="activity-container">
  24. <scroll-view scroll-y="true" >
  25. <view class="list" v-for="(item, index) in activityList" :key="index">
  26. <image class="list-image" :src="item.image" mode="scaleToFill"></image>
  27. <view class="title">{{item.title}}</view>
  28. <view class="time" v-show="item.status!=3">
  29. <view class="text">{{item.detail }}</view>
  30. </view>
  31. <view class="mack" v-show="item.status == 3">
  32. <view class="mack-text">活动已经结束</view>
  33. </view>
  34. </view>
  35. <!--加载loadding-->
  36. <tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
  37. <tui-nomore :visible="!pullUpOn" bgcolor="#F7F7F7" :text='nomoreText'></tui-nomore>
  38. <!--加载loadding-->
  39. </scroll-view>
  40. </view>
  41. </template>
  42. <!-- 列表 -->
  43. <template v-else>
  44. <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading ="true" :loadingType="9"></tui-skeleton>
  45. <template v-else>
  46. <view class="banner">
  47. <view class="banner-image">
  48. <image :src="banner" mode=""></image>
  49. </view>
  50. </view>
  51. <view class="instrument-list">
  52. <view class="list-item-cell" v-for="(item,index) in list" :key="index">
  53. <view class="list-item-title">
  54. <view class="title" :class="item.link ? 'float' : ''">
  55. <text>{{ item.title }}</text>
  56. </view>
  57. <view class="more" v-if="item.link" @click="NavToDetailPage(item)">
  58. <text>查看更多</text>
  59. <text class="iconfont icon-xiangyou"></text>
  60. </view>
  61. </view>
  62. <view class="list-item-pros">
  63. <view class="item-pros" v-for="(pros,prosIndex) in item.floorData" :key="prosIndex" @click="NavToDetailPage(pros)">
  64. <view class="item-pros-image">
  65. <image :src="pros.image" mode=""></image>
  66. </view>
  67. <view class="item-pros-name">{{ pros.title }}</view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </template>
  73. </template>
  74. </view>
  75. <!-- 侧边 -->
  76. <scroll-top v-if="isScrollTop"></scroll-top>
  77. </view>
  78. </template>
  79. <script>
  80. import tuiLoadmore from "@/components/tui-components/loadmore/loadmore"
  81. import tuiNomore from "@/components/tui-components/nomore/nomore"
  82. export default{
  83. components:{
  84. tuiLoadmore,
  85. tuiNomore,
  86. },
  87. data(){
  88. return{
  89. banner:'',
  90. headTab: {
  91. TabCur: 0,
  92. scrollLeft: 0,
  93. list: [],
  94. },
  95. headTabId:0,
  96. list:[],
  97. navMenuId:0,
  98. isScrollTop:false,
  99. listQuery:{
  100. pageNum:1,
  101. pageSize:10,
  102. },
  103. nomoreText: '上拉显示更多',
  104. hasNextPage:false,
  105. loadding: false,
  106. pullUpOn: true,
  107. pullFlag: true,
  108. isActivityFlag:false,
  109. skeletonShow:true,
  110. activityList:[]
  111. }
  112. },
  113. onLoad(option) {
  114. console.log(option)
  115. this.navMenuId = option.linkId
  116. this.GetHomeSubMenu()
  117. },
  118. methods:{
  119. GetHomeSubMenu(){//获取数据
  120. let _self = this
  121. this.CommonService.GetHomeSubMenu({navMenuId:this.navMenuId}).then(response =>{
  122. let data = response.data
  123. this.headTab.list = data
  124. uni.setNavigationBarTitle({title:_self.headTab.list[0].name});
  125. if(this.headTab.list[0].linkType === 8){
  126. this.isActivityFlag = true
  127. this.GetPromotionsrList()
  128. }else{
  129. this.headTabId = this.headTab.list[0].linkParam.id
  130. this.GetPageTopicInfo(this.headTabId)
  131. }
  132. }).catch(error =>{
  133. this.$util.msg(error.msg,2000)
  134. })
  135. },
  136. GetPageTopicInfo(type){//获取数据
  137. this.ProductService.GetPageTopic({type:type}).then(response =>{
  138. let data = response.data
  139. this.list = data
  140. this.GetPageTopicBanner(type)
  141. this.skeletonShow = false
  142. }).catch(error =>{
  143. this.$util.msg(error.msg,2000)
  144. })
  145. },
  146. GetPageTopicBanner(type){//获取banner
  147. this.ProductService.GetPageTopicBanner({type:type}).then(response =>{
  148. let data = response.data
  149. this.banner = data.image
  150. }).catch(error =>{
  151. this.$util.msg(error.msg,2000)
  152. })
  153. },
  154. GetPromotionsrList(){//获取专题列表
  155. this.ProductService.GetPromotionsrList(this.listQuery).then(response =>{
  156. let responseData = response.data
  157. if(responseData.list&&responseData.list.length > 0){
  158. this.isEmpty = false
  159. this.hasNextPage = responseData.hasNextPage
  160. this.activityList = responseData.list
  161. this.pullFlag = false;
  162. setTimeout(()=>{this.pullFlag = true;},500)
  163. if(this.hasNextPage){
  164. this.pullUpOn = false
  165. this.nomoreText = '上拉显示更多'
  166. }else{
  167. this.pullUpOn = true
  168. this.loadding = false
  169. this.nomoreText = '已至底部'
  170. }
  171. }else{
  172. this.isEmpty = true
  173. }
  174. }).catch(error =>{
  175. this.$util.msg(error.msg,2000)
  176. })
  177. },
  178. GetPromotionsrListBottomData(){
  179. this.listQuery.pageNum+=1
  180. this.ProductService.GetPromotionsrList(this.listQuery).then(response =>{
  181. let responseData = response.data
  182. if(responseData.list&&responseData.list.length > 0){
  183. this.hasNextPage = response.data.hasNextPage
  184. this.activityList = this.activityList.concat(responseData.list)
  185. this.pullFlag = false;// 防上拉暴滑
  186. setTimeout(()=>{this.pullFlag = true;},500)
  187. if(this.hasNextPage){
  188. this.pullUpOn = false
  189. this.nomoreText = '上拉显示更多'
  190. }else{
  191. this.pullUpOn = false
  192. this.loadding = false
  193. console.log('2222222222222')
  194. this.nomoreText = '已至底部'
  195. }
  196. }
  197. }).catch(error =>{
  198. this.$util.msg(error.msg,2000)
  199. })
  200. },
  201. tabSelect(index,item) {//tab菜单被点击
  202. console.log(item)
  203. this.headTab.TabCur = index;
  204. this.headTab.scrollLeft = (index - 1) * 50;
  205. this.headTabId = item.linkParam.id;
  206. console.log(this.headTabId)
  207. uni.setNavigationBarTitle({title:item.name});
  208. if(item.linkType === 8){
  209. this.isActivityFlag = true
  210. this.GetPromotionsrList()
  211. }else{
  212. this.isActivityFlag = false
  213. this.GetPageTopicInfo(this.headTabId)
  214. }
  215. },
  216. NavToDetailPage(floor) {//跳转
  217. console.log(floor)
  218. /**
  219. * 页面跳转类型
  220. * 1、二级页面,2、搜索项目仪器,3、直播页面,4、自由页面,5、商品详情,6、仪器项目详情,7、供应商主页
  221. * 8、专题活动页,9、二手市场介绍,10、二手商品列表,11、二手商品发布,12、商品搜索,13、信息详情
  222. * 14、品牌招商介绍页,15、维修保养介绍页,16、首页,17、注册页,18、信息中心,19、供应商列表
  223. **/
  224. if(floor.linkType){
  225. const typeMap = {
  226. 1:`/pages/goods/goods-instrument?linkId=${floor.linkParam.id}&title=${floor.title}`,
  227. 2:`/pages/search/search-instrument?keyword=${floor.title}`,
  228. 5:`/pages/goods/product?id=${floor.linkParam.id}`,
  229. 6:`/pages/goods/instrument-details?id=${floor.linkParam.id}`,
  230. 7:`/supplier/pages/user/my-shop?shopId=${floor.linkParam.id}`,
  231. 8:`/h5/pages/activity/activity-list`,
  232. 9:`/second/pages/form/introduce`,
  233. 10:`/second/pages/product/product-list`,
  234. 11:`/second/pages/form/form`,
  235. 12:`/pages/search/search?keyWord=${floor.title}`,
  236. 13:`/h5/pages/article/page?link=${floor.link}`,
  237. 14:`/h5/pages/article/page?link=${floor.link}`,
  238. 15:`/h5/pages/article/page?link=${floor.link}`,
  239. 17:`/pages/login/register-select`,
  240. 18:`/h5/pages/article/page?link=${floor.link}`,
  241. 19:`/pages/search/search-supplier?keyWord=${floor.title}`
  242. }
  243. const url = typeMap[floor.linkType];
  244. this.$api.navigateTo(url)
  245. }
  246. }
  247. },
  248. onReachBottom() {
  249. if(this.isActivityFlag){
  250. if(this.hasNextPage){
  251. this.loadding = true
  252. this.pullUpOn = true
  253. this.GetPromotionsrListBottomData()
  254. }
  255. }
  256. },
  257. onPullDownRefresh() {//下拉刷新
  258. if(this.isActivityFlag){
  259. this.listQuery.pageNum =1
  260. this.GetPromotionsrListBottomData()
  261. uni.stopPullDownRefresh()
  262. }else{
  263. this.GetPageTopicInfo(this.headTabId)
  264. uni.stopPullDownRefresh()
  265. }
  266. },
  267. onPageScroll(e){//实时获取到滚动的值
  268. if(e.scrollTop>600){
  269. this.isScrollTop = true
  270. }else{
  271. this.isScrollTop = false
  272. }
  273. },
  274. onShow() {
  275. }
  276. }
  277. </script>
  278. <style lang="scss">
  279. page{
  280. background-color: #F7F7F7;
  281. }
  282. .container-main{
  283. padding-top: 100rpx;
  284. }
  285. // 活动专题列表
  286. .activity-container{
  287. width: 100%;
  288. height: auto;
  289. box-sizing: border-box;
  290. padding: 0 24rpx;
  291. }
  292. .list{
  293. width: 100%;
  294. height: 318rpx;
  295. float: left;
  296. margin-bottom:20rpx;
  297. position: relative;
  298. .list-image{
  299. width: 100%;
  300. height: 318rpx;
  301. display: block;
  302. }
  303. .title{
  304. width: 100%;
  305. height: 72rpx;
  306. line-height: 72rpx;
  307. text-align: center;
  308. background: rgba(254,246,243,0.8);
  309. color: $color-system;
  310. position: absolute;
  311. bottom: 0;
  312. left: 0;
  313. font-size: $font-size-26;
  314. }
  315. .time{
  316. width: 100%;
  317. height: 48rpx;
  318. position: absolute;
  319. top: 0;
  320. left: 0;
  321. .text{
  322. width: 475rpx;
  323. height: 48rpx;
  324. font-size: $font-size-24;
  325. margin: 0 auto;
  326. line-height: 48rpx;
  327. background: linear-gradient(315deg, #f94b4b 0%, #bc3cff 100%);
  328. color: #FFFFFF;
  329. text-align: center;
  330. }
  331. }
  332. .mack{
  333. width: 100%;
  334. height: 100%;
  335. position: absolute;
  336. top: 0;
  337. left: 0;
  338. z-index: 9999;
  339. background: rgba(0,0,0,.1);
  340. border-radius: 2rpx;
  341. display: flex;
  342. flex-direction: column;
  343. align-items: center;
  344. justify-content: center;
  345. .mack-text{
  346. width: 220rpx;
  347. height: 70rpx;
  348. border-radius: 35rpx;
  349. text-align: center;
  350. background: rgba(0,0,0,.4);
  351. color: #FFFFFF;
  352. line-height: 70rpx;
  353. }
  354. }
  355. }
  356. //二级分类
  357. .instrument{
  358. width: 100%;
  359. height: auto;
  360. .banner{
  361. box-sizing: border-box;
  362. padding:24rpx;
  363. background-color: #FFFFFF;
  364. width: 100%;
  365. .banner-image{
  366. width: 100%;
  367. height: 248rpx;
  368. border-radius: 4rpx;
  369. }
  370. image{
  371. width: 100%;
  372. height: 248rpx;
  373. border-radius: 4rpx;
  374. }
  375. }
  376. .instrument-list{
  377. width: 100%;
  378. height: auto;
  379. box-sizing: border-box;
  380. padding: 0 24rpx;
  381. .list-item-cell{
  382. width: 100%;
  383. height: auto;
  384. float: left;
  385. .list-item-title{
  386. width: 100%;
  387. height: 88rpx;
  388. line-height: 88rpx;
  389. float: left;
  390. .title{
  391. font-size: $font-size-28;
  392. line-height: 80rpx;
  393. color: $text-color;
  394. font-weight: bold;
  395. &.float{
  396. float: left;
  397. }
  398. }
  399. .more{
  400. font-size: $font-size-26;
  401. line-height: 80rpx;
  402. color: #999999;
  403. height: 80rpx;
  404. float: right;
  405. .icon-xiangyou{
  406. font-size: $font-size-28;
  407. margin-left: 10rpx;
  408. }
  409. }
  410. }
  411. .list-item-pros{
  412. width: 100%;
  413. height: auto;
  414. float: left;
  415. .item-pros{
  416. width: 340rpx;
  417. height: 414rpx;
  418. float: left;
  419. margin-right: 20rpx;
  420. margin-bottom: 20rpx;
  421. background-color: #FFFFFF;
  422. border-radius: 4rpx;
  423. &:nth-child(2n){
  424. margin-right: 0;
  425. }
  426. .item-pros-image{
  427. width: 340rpx;
  428. height: 340rpx;
  429. float: left;
  430. image{
  431. width: 340rpx;
  432. height: 340rpx;
  433. display: block;
  434. border-radius: 4rpx 4rpx 0 0;
  435. }
  436. }
  437. .item-pros-name{
  438. width: 100%;
  439. height: 74rpx;
  440. line-height: 74rpx;
  441. box-sizing: border-box;
  442. padding: 0 24rpx;
  443. white-space: normal;
  444. word-break: break-all;
  445. overflow: hidden;
  446. text-overflow: ellipsis;
  447. display: -webkit-box;
  448. -webkit-box-orient: vertical;
  449. -webkit-line-clamp: 1;
  450. text-align: center;
  451. font-size: $font-size-26;
  452. line-height: 74rpx;
  453. text-align: center;
  454. }
  455. }
  456. }
  457. }
  458. }
  459. }
  460. .home-hotmaintab-fixed{
  461. width: 100%;
  462. height:auto;
  463. overflow: hidden;
  464. background: #FFFFFF;
  465. padding-bottom: 20rpx;
  466. position: fixed;
  467. top: 0;
  468. left: 0;
  469. z-index: 999;
  470. .home-flex-tab {
  471. width: 100%;
  472. position: relative;
  473. transition: opacity .25s;
  474. .text-white{
  475. color: #666666;
  476. }
  477. .flex {
  478. .basis-xxl {
  479. flex-basis: 100%;
  480. width: 100%;
  481. z-index: 1;
  482. }
  483. .basis-xxs {
  484. flex-basis: 10%;
  485. z-index: 1;
  486. width: 10%;
  487. }
  488. .sort-icon {
  489. font-size: 55rpx;
  490. height: 64rpx;
  491. line-height: 64rpx;
  492. text-align: center;
  493. }
  494. }
  495. }
  496. }
  497. .nav{
  498. white-space:nowrap;
  499. }
  500. .nav .cu-item {
  501. display: inline-block;
  502. margin: 0 5rpx;
  503. padding: 0 15rpx;
  504. }
  505. .nav.z .cu-item.select {
  506. font-size: $font-size-28;
  507. color: $color-system;
  508. }
  509. .nav.z .cu-item {
  510. height: 80rpx;
  511. font-size: $font-size-26;
  512. line-height: 80rpx;
  513. position: relative;
  514. }
  515. .nav.z .cu-item.select .tab-dot {
  516. position: absolute;
  517. height: 8rpx;
  518. border-radius: 20rpx;
  519. bottom: 0;
  520. left: 0;
  521. right: 0;
  522. width: 40rpx;
  523. margin: auto;
  524. }
  525. .bg-white{
  526. background-color: $color-system;
  527. }
  528. ::-webkit-scrollbar {
  529. display: none;
  530. }
  531. .flex {
  532. display: -webkit-box;
  533. display: -webkit-flex;
  534. display: flex;
  535. }
  536. </style>