goods-secondary.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  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. 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/page?link=${floor.link}`,
  240. 14:`/h5/pages/article/page?link=${floor.link}`,
  241. 15:`/h5/pages/article/page?link=${floor.link}`,
  242. 17:`/pages/login/register-select`,
  243. 18:`/h5/pages/article/page?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. }
  318. .time{
  319. width: 100%;
  320. height: 48rpx;
  321. position: absolute;
  322. top: 0;
  323. left: 0;
  324. .text{
  325. width: 475rpx;
  326. height: 48rpx;
  327. font-size: $font-size-24;
  328. margin: 0 auto;
  329. line-height: 48rpx;
  330. background: linear-gradient(315deg, #f94b4b 0%, #bc3cff 100%);
  331. color: #FFFFFF;
  332. text-align: center;
  333. }
  334. }
  335. .mack{
  336. width: 100%;
  337. height: 100%;
  338. position: absolute;
  339. top: 0;
  340. left: 0;
  341. z-index: 9999;
  342. background: rgba(0,0,0,.1);
  343. border-radius: 2rpx;
  344. display: flex;
  345. flex-direction: column;
  346. align-items: center;
  347. justify-content: center;
  348. .mack-text{
  349. width: 220rpx;
  350. height: 70rpx;
  351. border-radius: 35rpx;
  352. text-align: center;
  353. background: rgba(0,0,0,.4);
  354. color: #FFFFFF;
  355. line-height: 70rpx;
  356. font-size: $font-size-26;
  357. }
  358. }
  359. }
  360. //二级分类
  361. .instrument{
  362. width: 100%;
  363. height: auto;
  364. .banner{
  365. box-sizing: border-box;
  366. padding:24rpx;
  367. background-color: #FFFFFF;
  368. width: 100%;
  369. .banner-image{
  370. width: 100%;
  371. height: 248rpx;
  372. border-radius: 4rpx;
  373. }
  374. image{
  375. width: 100%;
  376. height: 248rpx;
  377. border-radius: 4rpx;
  378. }
  379. }
  380. .instrument-list{
  381. width: 100%;
  382. height: auto;
  383. box-sizing: border-box;
  384. padding: 0 24rpx;
  385. .list-item-cell{
  386. width: 100%;
  387. height: auto;
  388. float: left;
  389. .list-item-title{
  390. width: 100%;
  391. height: 88rpx;
  392. line-height: 88rpx;
  393. float: left;
  394. .title{
  395. font-size: $font-size-28;
  396. line-height: 80rpx;
  397. color: $text-color;
  398. font-weight: bold;
  399. &.float{
  400. float: left;
  401. }
  402. }
  403. .more{
  404. font-size: $font-size-26;
  405. line-height: 80rpx;
  406. color: #999999;
  407. height: 80rpx;
  408. float: right;
  409. .icon-xiangyou{
  410. font-size: $font-size-28;
  411. margin-left: 10rpx;
  412. }
  413. }
  414. }
  415. .list-item-pros{
  416. width: 100%;
  417. height: auto;
  418. float: left;
  419. .item-pros{
  420. width: 340rpx;
  421. height: 414rpx;
  422. float: left;
  423. margin-right: 20rpx;
  424. margin-bottom: 20rpx;
  425. background-color: #FFFFFF;
  426. border-radius: 4rpx;
  427. &:nth-child(2n){
  428. margin-right: 0;
  429. }
  430. .item-pros-image{
  431. width: 340rpx;
  432. height: 340rpx;
  433. float: left;
  434. image{
  435. width: 340rpx;
  436. height: 340rpx;
  437. display: block;
  438. border-radius: 4rpx 4rpx 0 0;
  439. }
  440. }
  441. .item-pros-name{
  442. width: 100%;
  443. height: 74rpx;
  444. line-height: 74rpx;
  445. box-sizing: border-box;
  446. padding: 0 24rpx;
  447. white-space: normal;
  448. word-break: break-all;
  449. overflow: hidden;
  450. text-overflow: ellipsis;
  451. display: -webkit-box;
  452. -webkit-box-orient: vertical;
  453. -webkit-line-clamp: 1;
  454. text-align: center;
  455. font-size: $font-size-26;
  456. line-height: 74rpx;
  457. text-align: center;
  458. }
  459. }
  460. }
  461. }
  462. }
  463. }
  464. .home-hotmaintab-fixed{
  465. width: 100%;
  466. height:auto;
  467. overflow: hidden;
  468. background: #FFFFFF;
  469. padding-bottom: 20rpx;
  470. position: fixed;
  471. top: 0;
  472. left: 0;
  473. z-index: 999;
  474. .home-flex-tab {
  475. width: 100%;
  476. position: relative;
  477. transition: opacity .25s;
  478. .text-white{
  479. color: #666666;
  480. }
  481. .flex {
  482. .basis-xxl {
  483. flex-basis: 100%;
  484. width: 100%;
  485. z-index: 1;
  486. }
  487. .basis-xxs {
  488. flex-basis: 10%;
  489. z-index: 1;
  490. width: 10%;
  491. }
  492. .sort-icon {
  493. font-size: 55rpx;
  494. height: 64rpx;
  495. line-height: 64rpx;
  496. text-align: center;
  497. }
  498. }
  499. }
  500. }
  501. .nav{
  502. white-space:nowrap;
  503. }
  504. .nav .cu-item {
  505. display: inline-block;
  506. margin: 0 5rpx;
  507. padding: 0 15rpx;
  508. }
  509. .nav.z .cu-item.select {
  510. font-size: $font-size-28;
  511. color: $color-system;
  512. }
  513. .nav.z .cu-item {
  514. height: 80rpx;
  515. font-size: $font-size-26;
  516. line-height: 80rpx;
  517. position: relative;
  518. }
  519. .nav.z .cu-item.select .tab-dot {
  520. position: absolute;
  521. height: 8rpx;
  522. border-radius: 20rpx;
  523. bottom: 0;
  524. left: 0;
  525. right: 0;
  526. width: 40rpx;
  527. margin: auto;
  528. }
  529. .bg-white{
  530. background-color: $color-system;
  531. }
  532. ::-webkit-scrollbar {
  533. display: none;
  534. }
  535. .flex {
  536. display: -webkit-box;
  537. display: -webkit-flex;
  538. display: flex;
  539. }
  540. </style>