good-floor-zone.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. <template>
  2. <view class="container floor clearfix">
  3. <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading="true" :loadingType="5" />
  4. <template v-else>
  5. <view class="container-home">
  6. <view class="tui-floor-item" v-if="imageList.length>0">
  7. <swiper class="tui-floor-swiper" circular @change="swiperChange" :indicator-dots="false" :autoplay="true"
  8. :interval="5000" :duration="500">
  9. <swiper-item v-for="(item, index) in imageList" :key="item">
  10. <view class="tui-floor-swiper" @click="BannerNavigateTo(
  11. item.linkType,
  12. item.linkParam.id ? item.linkParam.id : '',
  13. item.linkParam.crmLink,
  14. item.linkParam.keyword ? item.linkParam.keyword : '')">
  15. <image class="floor-image" :src="item.crmImage" mode=""></image>
  16. </view>
  17. </swiper-item>
  18. </swiper>
  19. <view class="swiper__dots-box">
  20. <view v-for="(item, idx) in imageList" :key="idx"
  21. :class="[idx === current ? 'swiper__dots-long' : 'none']" :data-index="current"
  22. class="swiper__dots-item"></view>
  23. </view>
  24. </view>
  25. <view class="tui-floor-tabs">
  26. <view class="top-tabs-item" :class="tabsIndex === 0 ? 'active': '' " @click="handleClickTabS(0)">全部</view>
  27. <view class="top-tabs-item" :class="tabsIndex === 1 ? 'active': '' " @click="handleClickTabS(1)">产品</view>
  28. <view class="top-tabs-item" :class="tabsIndex === 2 ? 'active': '' " @click="handleClickTabS(2)">仪器</view>
  29. <view class="top-tabs-item" :class="tabsIndex === 3 ? 'active': '' " @click="handleClickTabS(3)">耗材配件</view>
  30. </view>
  31. <view class="floor-item-main" >
  32. <template v-if="productList.length > 0">
  33. <view class="floor-item clearfix" v-for="(pros, idx) in productList" :key="idx"
  34. @click.stop="navToDetailPage(pros)">
  35. <image class="item-img tui-skeleton-fillet" :src="pros.mainImage" mode="aspectFill"></image>
  36. <template-Type :product="pros" />
  37. <view class="floor-item-content">
  38. <view class="title tui-skeleton-rect">
  39. <text class="mclap" :class="pros.beautyActFlag == '1' ? 'indent' : ''">{{ pros.name }}
  40. </text>
  41. </view>
  42. <view class="floor-item-price">
  43. <template>
  44. <template-Tags :product="pros" />
  45. </template>
  46. <view v-if="hasLogin">
  47. <template v-if="pros.productCategory == 1">
  48. <template-Price :product="pros" />
  49. </template>
  50. <template v-else>
  51. <view class="price tui-skeleton-rect" v-if="pros.detailTalkFlag == '2'">
  52. <text class="p sm">¥</text> <text class="p big">价格详聊</text>
  53. </view>
  54. <view class="price tui-skeleton-rect" v-else>
  55. <text class="p sm">¥</text>
  56. <text class="p big">{{ pros.price | NumFormat }}</text>
  57. </view>
  58. </template>
  59. </view>
  60. <view v-else class="no-price">
  61. <template v-if="pros.productCategory == 1">
  62. <view class="p-stars">
  63. <text class="p-no">¥</text>
  64. <uni-grader :grade="Number(pros.priceGrade)" :margin="14" />
  65. </view>
  66. </template>
  67. <template v-else>
  68. <view class="p-stars"> <text class="p-no">¥登录可见</text> </view>
  69. </template>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </template>
  75. <template v-else>
  76. <view class="floor-main-none">
  77. <image
  78. class="none-image"
  79. src="https://static.caimei365.com/app/img/bg/icon_echart_none@2x.png"
  80. mode=""
  81. ></image>
  82. <view class="none-text">暂无数据~</view>
  83. </view>
  84. </template>
  85. </view>
  86. </view>
  87. </template>
  88. </view>
  89. </template>
  90. <script>
  91. import { mapState, mapMutations } from 'vuex'
  92. import uniGrader from '@/components/uni-grade/uni-grade.vue'
  93. import templateTags from '@/components/cm-module/pageTemplate/templateTags.vue'
  94. import templatePrice from '@/components/cm-module/pageTemplate/templatePrice.vue'
  95. import templateType from '@/components/cm-module/pageTemplate/templateType.vue'
  96. import wxLogin from '@/common/config/wxLogin.js'
  97. export default {
  98. name:'GoodFloorZone',
  99. components: {
  100. uniGrader,
  101. templateTags,
  102. templatePrice,
  103. templateType
  104. },
  105. data() {
  106. return {
  107. userId: 0,
  108. userIdentity: 0,
  109. skeletonShow: true,
  110. isScrollTop: false,
  111. current:0,
  112. listQuery: {
  113. userId:0, // 用户Id
  114. zoneId:'', // 专区Id
  115. typeSort:'', // 分类类型 1产品,2仪器,3耗材配件
  116. pageNum:1,
  117. pageSize:12,
  118. source:1
  119. },
  120. imageList: [], //专区轮播
  121. productList:[],//专区商品
  122. nomoreText: '上拉显示更多',
  123. hasNextPage: false,
  124. loadding: false,
  125. pullUpOn: true,
  126. pullFlag: true,
  127. tabsIndex: 0
  128. }
  129. },
  130. filters: {
  131. NumFormat(value) {
  132. //处理金额
  133. return Number(value).toFixed(2)
  134. }
  135. },
  136. computed: {
  137. ...mapState(['hasLogin', 'userInfo','isWxAuthorize'])
  138. },
  139. onLoad(option) {
  140. if (option.type == 'share') {
  141. wxLogin.wxLoginAuthorize()
  142. }
  143. this.initGetUser(option)
  144. },
  145. methods: {
  146. async initGetUser(option){
  147. const user = await this.$api.getStorage()
  148. this.listQuery.zoneId = option.zoneId
  149. this.listQuery.typeSort = option.typeSort
  150. this.tabsIndex = option.typeSort*1
  151. this.listQuery.userId = user.userId ? user.userId : 0
  152. this.userIdentity = user.userIdentity
  153. this.getZoneSecond(this.listQuery)
  154. },
  155. // 切换分类查询
  156. handleClickTabS(index){
  157. this.tabsIndex = index
  158. this.listQuery.typeSort = index
  159. this.listQuery.pageNum = 1
  160. this.getZoneSecond()
  161. },
  162. async getZoneSecond() {
  163. //专区详情
  164. try {
  165. const res = await this.CommonService.getZoneSecond(this.listQuery)
  166. const data = res.data
  167. this.imageList = data.imageList
  168. uni.setNavigationBarTitle({ title: `${data.zone.floorTitle}` })
  169. this.productList = data.products.results
  170. this.hasNextPage = data.products.hasNextPage
  171. this.skeletonShow = false
  172. if (this.hasNextPage) {
  173. this.pullUpOn = false
  174. this.nomoreText = '上拉显示更多'
  175. } else {
  176. if (this.productList.length < 6) {
  177. this.pullUpOn = true
  178. } else {
  179. this.pullUpOn = false
  180. this.loadding = false
  181. this.nomoreText = '已至底部'
  182. }
  183. }
  184. } catch (error) {
  185. console.log('error', error.msg)
  186. }
  187. },
  188. async OnReachBottomData() {
  189. // 上滑加载
  190. try {
  191. this.listQuery.pageNum += 1
  192. const res = await this.CommonService.GetHomeNewFloorList(this.listQuery)
  193. const data = res.data
  194. this.productList = this.productList.concat(data.products.results)
  195. this.hasNextPage = data.products.hasNextPage
  196. if (this.hasNextPage) {
  197. this.pullUpOn = false
  198. this.nomoreText = '上拉显示更多'
  199. } else {
  200. this.pullUpOn = false
  201. this.loadding = false
  202. this.nomoreText = '已至底部'
  203. }
  204. } catch (error) {
  205. console.log('error', error.msg)
  206. }
  207. },
  208. navToDetailPage(pros) {
  209. //跳转商品详情
  210. this.$api.navigateTo(`/pages/goods/product?id=${pros.productId}`)
  211. },
  212. BannerNavigateTo(linkType, linkId, linkHref, keyword) {
  213. //跳转
  214. this.$api.BannerNavigateTo(linkType, linkId, linkHref, keyword)
  215. },
  216. swiperChange(e) {//轮播图切换
  217. this.current = e.detail.current
  218. }
  219. },
  220. onPageScroll(e) {
  221. //实时获取到滚动的值
  222. if (e.scrollTop > 400) {
  223. this.isScrollTop = true
  224. } else {
  225. this.isScrollTop = false
  226. }
  227. },
  228. onPullDownRefresh() {
  229. setTimeout(() => {
  230. this.listQuery.pageNum = 1
  231. this.getZoneSecond()
  232. uni.stopPullDownRefresh()
  233. }, 200)
  234. },
  235. onReachBottom() {
  236. if (this.hasNextPage) {
  237. this.loadding = true
  238. this.pullUpOn = true
  239. this.OnReachBottomData()
  240. }
  241. },
  242. onShareAppMessage(res) {
  243. //分享转发
  244. if (res.from === 'button') {
  245. // 来自页面内转发按钮
  246. }
  247. return {
  248. title: '采美-一站式生/医美采购服务平台',
  249. path: `pages/goods/good-floor-zone?type=share&linkId=${this.pageId}`
  250. }
  251. },
  252. onShow() {}
  253. }
  254. </script>
  255. <style lang="scss">
  256. page {
  257. background-color: #f7f7f7;
  258. }
  259. .container-home {
  260. width: 100%;
  261. height: auto;
  262. box-sizing: border-box;
  263. padding: 24rpx 24rpx 0 24rpx;
  264. }
  265. .tui-floor-item{
  266. width: 100%;
  267. height: 240rpx;
  268. border-radius: 16rpx;
  269. box-sizing: border-box;
  270. padding: 0;
  271. position: relative;
  272. margin-bottom: 24rpx;
  273. .swiper__dots-box{
  274. position: absolute;
  275. bottom: 30rpx;
  276. left: 0;
  277. right: 0;
  278. /* #ifndef APP-NVUE */
  279. display: flex;
  280. /* #endif */
  281. flex: 1;
  282. flex-direction: row;
  283. justify-content: center;
  284. align-items: center;
  285. .swiper__dots-item{
  286. width: 8rpx;
  287. height: 8rpx;
  288. border-radius: 100%;
  289. margin-left: 6px;
  290. background-color:rgba(255,255,255,.7);
  291. }
  292. .swiper__dots-long{
  293. width: 35rpx;
  294. height: 8rpx;
  295. border-radius: 4rpx;
  296. background-color: #ffff;
  297. transition: all 0.4s;
  298. }
  299. }
  300. .tui-floor-swiper{
  301. width: 100%;
  302. height: 240rpx;
  303. text-align: center;
  304. line-height: 240rpx;
  305. float: left;
  306. border-radius: 16rpx;
  307. overflow: hidden;
  308. .floor-image{
  309. width: 100%;
  310. height: 100%;
  311. display: block;
  312. }
  313. }
  314. }
  315. .tui-floor-tabs{
  316. width: 100%;
  317. height: 88rpx;
  318. background-color: #FFFFFF;
  319. border-radius: 16rpx;
  320. display: flex;
  321. justify-content: flex-start;
  322. margin-bottom: 24rpx;
  323. .top-tabs-item{
  324. padding: 0 24rpx;
  325. line-height: 88rpx;
  326. text-align: center;
  327. font-size: 30rpx;
  328. color: #333333;
  329. cursor: pointer;
  330. &.active{
  331. color: #FF5B00;
  332. font-weight: bold;
  333. text-decoration: underline;
  334. }
  335. }
  336. }
  337. .floor-item-main{
  338. width: 100%;
  339. min-height: 600rpx;
  340. display: flex;
  341. justify-content: space-between;
  342. flex-wrap: wrap;
  343. align-items: center;
  344. .floor-item {
  345. width: 339rpx;
  346. height: 524rpx;
  347. font-size: $font-size-24;
  348. color: $text-color;
  349. background: #ffffff;
  350. line-height: 36rpx;
  351. border-radius: 16rpx;
  352. box-sizing: border-box;
  353. position: relative;
  354. margin-right: 20rpx;
  355. margin-bottom: 20rpx;
  356. &:nth-child(2n){
  357. margin-right: 0;
  358. }
  359. .item-img {
  360. width: 339rpx;
  361. height: 339rpx;
  362. border-radius: 16rpx 16rpx 0 0;
  363. display: block;
  364. margin-bottom: 8rpx;
  365. }
  366. .floor-item_tag {
  367. width: 100%;
  368. height: 32rpx;
  369. float: left;
  370. margin: 20rpx 0;
  371. padding: 0 20rpx;
  372. box-sizing: border-box;
  373. text {
  374. display: inline-block;
  375. padding: 0 8rpx;
  376. border: 1px solid #e3ebf7;
  377. border-radius: 8rpx;
  378. color: #9aa5b5;
  379. font-size: $font-size-22;
  380. line-height: 32rpx;
  381. text-align: center;
  382. float: left;
  383. }
  384. }
  385. .floor-item-content {
  386. width: 100%;
  387. padding: 0 20rpx;
  388. box-sizing: border-box;
  389. }
  390. .floor-item-act {
  391. display: block;
  392. width: 100%;
  393. height: 32rpx;
  394. text-align: center;
  395. box-sizing: border-box;
  396. }
  397. .title-none {
  398. font-size: $font-size-26;
  399. color: #ff2a2a;
  400. line-height: 54rpx;
  401. }
  402. .title {
  403. width: 100%;
  404. height: 70rpx;
  405. display: flex;
  406. line-height: 35rpx;
  407. flex-direction: column;
  408. margin: 8rpx 0;
  409. padding: 0;
  410. position: relative;
  411. .mclap {
  412. width: 100%;
  413. line-height: 35rpx;
  414. text-overflow: ellipsis;
  415. display: -webkit-box;
  416. word-break: break-all;
  417. -webkit-box-orient: vertical;
  418. -webkit-line-clamp: 2;
  419. overflow: hidden;
  420. font-size: 26rpx;
  421. &.indent {
  422. text-indent: 95rpx;
  423. }
  424. }
  425. .mclap-tag {
  426. display: block;
  427. width: 84rpx;
  428. height: 32rpx;
  429. background-image: linear-gradient(270deg, #f9c023 0%, #f83600 100%);
  430. border-radius: 4rpx 48rpx 4px 4px;
  431. line-height: 32rpx;
  432. font-size: $font-size-22;
  433. color: #ffffff;
  434. text-align: center;
  435. position: absolute;
  436. left: 0;
  437. top: 0;
  438. }
  439. }
  440. .no-price {
  441. height: 54rpx;
  442. line-height: 54rpx;
  443. display: flex;
  444. box-sizing: border-box;
  445. .p-no {
  446. font-size: $font-size-28;
  447. color: $text-color;
  448. display: block;
  449. float: left;
  450. }
  451. .p-stars {
  452. float: left;
  453. }
  454. }
  455. .price {
  456. color: #ff2a2a;
  457. line-height: 54rpx;
  458. &.none {
  459. text-decoration: line-through;
  460. color: #999999;
  461. }
  462. .sm {
  463. font-size: $font-size-24;
  464. }
  465. .big {
  466. font-size: $font-size-28;
  467. }
  468. }
  469. }
  470. .floor-main-none{
  471. width: 100%;
  472. height: 100%;
  473. display: flex;
  474. align-items: center;
  475. justify-content: center;
  476. flex-direction: column;
  477. .none-image {
  478. width: 220rpx;
  479. height: 220rpx;
  480. }
  481. .none-text {
  482. font-size: $font-size-28;
  483. color: #999999;
  484. line-height: 44rpx;
  485. }
  486. }
  487. }
  488. </style>