goods-secondary.vue 14 KB

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