goods-secondary.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  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" @click="NavigateToActivity(item)">
  26. <image class="list-image" :src="item.image" mode="scaleToFill"></image>
  27. <view class="title">{{item.title}}</view>
  28. <view class="time" v-if="item.status!=3">
  29. <view class="text">{{item.detail }}</view>
  30. </view>
  31. <view class="mack" v-if="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 :isScrollTop="isScrollTop" :bottom="200"></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. this.nomoreText = '已至底部'
  194. }
  195. }
  196. }).catch(error =>{
  197. this.$util.msg(error.msg,2000)
  198. })
  199. },
  200. tabSelect(index,item) {//tab菜单被点击
  201. this.headTab.TabCur = index;
  202. this.headTab.scrollLeft = (index - 1) * 50;
  203. this.headTabId = item.linkParam.id;
  204. uni.setNavigationBarTitle({title:item.name});
  205. if(item.linkType === 8){
  206. this.isActivityFlag = true
  207. this.GetPromotionsrList()
  208. }else{
  209. this.isActivityFlag = false
  210. this.GetPageTopicInfo(this.headTabId)
  211. }
  212. },
  213. NavigateToActivity(item){//跳转活动详情
  214. if(item.status!=3){
  215. this.$api.navigateTo(`/h5/pages/activity/activity?id=${item.linkParam.id}`)
  216. }else{
  217. this.$util.msg('活动已经结束',2000)
  218. }
  219. },
  220. NavToDetailPage(floor) {//跳转
  221. console.log(floor)
  222. /**
  223. * 页面跳转类型
  224. * 1、二级页面,2、搜索项目仪器,3、直播页面,4、自由页面,5、商品详情,6、仪器项目详情,7、供应商主页
  225. * 8、专题活动页,9、二手市场介绍,10、二手商品列表,11、二手商品发布,12、商品搜索,13、信息详情
  226. * 14、品牌招商介绍页,15、维修保养介绍页,16、首页,17、注册页,18、信息中心,19、供应商列表
  227. **/
  228. if(floor.linkType){
  229. const typeMap = {
  230. 1:`/pages/goods/goods-instrument?linkId=${floor.linkParam.id}&title=${floor.title}`,
  231. 2:`/pages/goods/instrument-details?id=${floor.linkParam.id}`,
  232. 5:`/pages/goods/product?id=${floor.linkParam.id}`,
  233. 7:`/supplier/pages/user/my-shop?shopId=${floor.linkParam.id}`,
  234. 8:`/h5/pages/activity/activity-list`,
  235. 9:`/second/pages/form/introduce`,
  236. 10:`/second/pages/product/product-list`,
  237. 11:`/second/pages/form/form`,
  238. 12:`/pages/search/search?keyWord=${floor.title}`,
  239. 13:`/h5/pages/article/path?link=${floor.link}`,
  240. 14:`/h5/pages/article/path?link=${floor.link}`,
  241. 15:`/h5/pages/article/path?link=${floor.link}`,
  242. 17:`/pages/login/register-select`,
  243. 18:`/h5/pages/article/path?link=${floor.link}`,
  244. 19:`/pages/search/search-supplier?keyWord=${floor.title}`
  245. }
  246. const url = typeMap[floor.linkType];
  247. this.$api.navigateTo(url)
  248. }
  249. }
  250. },
  251. onReachBottom() {
  252. if(this.isActivityFlag){
  253. if(this.hasNextPage){
  254. this.loadding = true
  255. this.pullUpOn = true
  256. this.GetPromotionsrListBottomData()
  257. }
  258. }
  259. },
  260. onPullDownRefresh() {//下拉刷新
  261. if(this.isActivityFlag){
  262. this.listQuery.pageNum =1
  263. this.GetPromotionsrList()
  264. uni.stopPullDownRefresh()
  265. }else{
  266. this.GetPageTopicInfo(this.headTabId)
  267. uni.stopPullDownRefresh()
  268. }
  269. },
  270. onPageScroll(e){//实时获取到滚动的值
  271. if(e.scrollTop>600){
  272. this.isScrollTop = true
  273. }else{
  274. this.isScrollTop = false
  275. }
  276. },
  277. onShow() {
  278. }
  279. }
  280. </script>
  281. <style lang="scss">
  282. page{
  283. background-color: #F7F7F7;
  284. }
  285. .container-main{
  286. padding-top: 100rpx;
  287. }
  288. // 活动专题列表
  289. .activity-container{
  290. width: 100%;
  291. height: auto;
  292. box-sizing: border-box;
  293. padding: 0 24rpx;
  294. }
  295. .list{
  296. width: 100%;
  297. height: 318rpx;
  298. float: left;
  299. margin-bottom:20rpx;
  300. position: relative;
  301. .list-image{
  302. width: 100%;
  303. height: 318rpx;
  304. display: block;
  305. }
  306. .title{
  307. width: 100%;
  308. height: 72rpx;
  309. line-height: 72rpx;
  310. text-align: center;
  311. background: rgba(254,246,243,0.8);
  312. color: $color-system;
  313. position: absolute;
  314. bottom: 0;
  315. left: 0;
  316. font-size: $font-size-26;
  317. text-overflow:ellipsis;
  318. display: -webkit-box;
  319. word-break: break-all;
  320. -webkit-box-orient: vertical;
  321. -webkit-line-clamp: 1;
  322. overflow: hidden;
  323. }
  324. .time{
  325. width: 100%;
  326. height: 48rpx;
  327. position: absolute;
  328. top: 0;
  329. left: 0;
  330. .text{
  331. width: 475rpx;
  332. height: 48rpx;
  333. font-size: $font-size-24;
  334. margin: 0 auto;
  335. line-height: 48rpx;
  336. background: linear-gradient(315deg, #f94b4b 0%, #bc3cff 100%);
  337. color: #FFFFFF;
  338. text-align: center;
  339. }
  340. }
  341. .mack{
  342. width: 100%;
  343. height: 100%;
  344. position: absolute;
  345. top: 0;
  346. left: 0;
  347. z-index: 9999;
  348. background: rgba(0,0,0,.1);
  349. border-radius: 2rpx;
  350. display: flex;
  351. flex-direction: column;
  352. align-items: center;
  353. justify-content: center;
  354. .mack-text{
  355. width: 220rpx;
  356. height: 70rpx;
  357. border-radius: 35rpx;
  358. text-align: center;
  359. background: rgba(0,0,0,.4);
  360. color: #FFFFFF;
  361. line-height: 70rpx;
  362. font-size: $font-size-26;
  363. }
  364. }
  365. }
  366. //二级分类
  367. .instrument{
  368. width: 100%;
  369. height: auto;
  370. .banner{
  371. box-sizing: border-box;
  372. padding:24rpx;
  373. background-color: #FFFFFF;
  374. width: 100%;
  375. .banner-image{
  376. width: 100%;
  377. height: 248rpx;
  378. border-radius: 4rpx;
  379. }
  380. image{
  381. width: 100%;
  382. height: 248rpx;
  383. border-radius: 4rpx;
  384. }
  385. }
  386. .instrument-list{
  387. width: 100%;
  388. height: auto;
  389. box-sizing: border-box;
  390. padding: 0 24rpx;
  391. .list-item-cell{
  392. width: 100%;
  393. height: auto;
  394. float: left;
  395. .list-item-title{
  396. width: 100%;
  397. height: 88rpx;
  398. line-height: 88rpx;
  399. float: left;
  400. .title{
  401. font-size: $font-size-28;
  402. line-height: 80rpx;
  403. color: $text-color;
  404. font-weight: bold;
  405. &.float{
  406. float: left;
  407. }
  408. }
  409. .more{
  410. font-size: $font-size-26;
  411. line-height: 80rpx;
  412. color: #999999;
  413. height: 80rpx;
  414. float: right;
  415. .icon-xiangyou{
  416. font-size: $font-size-28;
  417. margin-left: 10rpx;
  418. }
  419. }
  420. }
  421. .list-item-pros{
  422. width: 100%;
  423. height: auto;
  424. float: left;
  425. .item-pros{
  426. width: 340rpx;
  427. height: 414rpx;
  428. float: left;
  429. margin-right: 20rpx;
  430. margin-bottom: 20rpx;
  431. background-color: #FFFFFF;
  432. border-radius: 4rpx;
  433. &:nth-child(2n){
  434. margin-right: 0;
  435. }
  436. .item-pros-image{
  437. width: 340rpx;
  438. height: 340rpx;
  439. float: left;
  440. image{
  441. width: 340rpx;
  442. height: 340rpx;
  443. display: block;
  444. border-radius: 4rpx 4rpx 0 0;
  445. }
  446. }
  447. .item-pros-name{
  448. width: 100%;
  449. height: 74rpx;
  450. line-height: 74rpx;
  451. box-sizing: border-box;
  452. padding: 0 24rpx;
  453. white-space: normal;
  454. word-break: break-all;
  455. overflow: hidden;
  456. text-overflow: ellipsis;
  457. display: -webkit-box;
  458. -webkit-box-orient: vertical;
  459. -webkit-line-clamp: 1;
  460. text-align: center;
  461. font-size: $font-size-26;
  462. line-height: 74rpx;
  463. text-align: center;
  464. }
  465. }
  466. }
  467. }
  468. }
  469. }
  470. .home-hotmaintab-fixed{
  471. width: 100%;
  472. height:auto;
  473. overflow: hidden;
  474. background: #FFFFFF;
  475. padding-bottom: 20rpx;
  476. position: fixed;
  477. top: 0;
  478. left: 0;
  479. z-index: 999;
  480. .home-flex-tab {
  481. width: 100%;
  482. position: relative;
  483. transition: opacity .25s;
  484. .text-white{
  485. color: #666666;
  486. }
  487. .flex {
  488. .basis-xxl {
  489. flex-basis: 100%;
  490. width: 100%;
  491. z-index: 1;
  492. }
  493. .basis-xxs {
  494. flex-basis: 10%;
  495. z-index: 1;
  496. width: 10%;
  497. }
  498. .sort-icon {
  499. font-size: 55rpx;
  500. height: 64rpx;
  501. line-height: 64rpx;
  502. text-align: center;
  503. }
  504. }
  505. }
  506. }
  507. .nav{
  508. white-space:nowrap;
  509. }
  510. .nav .cu-item {
  511. display: inline-block;
  512. margin: 0 5rpx;
  513. padding: 0 15rpx;
  514. }
  515. .nav.z .cu-item.select {
  516. font-size: $font-size-28;
  517. color: $color-system;
  518. }
  519. .nav.z .cu-item {
  520. height: 80rpx;
  521. font-size: $font-size-26;
  522. line-height: 80rpx;
  523. position: relative;
  524. }
  525. .nav.z .cu-item.select .tab-dot {
  526. position: absolute;
  527. height: 8rpx;
  528. border-radius: 20rpx;
  529. bottom: 0;
  530. left: 0;
  531. right: 0;
  532. width: 40rpx;
  533. margin: auto;
  534. }
  535. .bg-white{
  536. background-color: $color-system;
  537. }
  538. ::-webkit-scrollbar {
  539. display: none;
  540. }
  541. .flex {
  542. display: -webkit-box;
  543. display: -webkit-flex;
  544. display: flex;
  545. }
  546. </style>