goods-secondary.vue 14 KB

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