good-floorMore.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. <template>
  2. <view class="container clearfix tui-skeleton">
  3. <!-- 骨架 -->
  4. <tui-skeleton v-if="skeletonShow" :isLoading="true" loadingType="2"></tui-skeleton>
  5. <!-- 商品列表 -->
  6. <view class="container-section clearfix">
  7. <!-- 商品列表区域 -->
  8. <view class="product-list" v-for="(pro,index) in productList" :key="index" @click.stop="Details(pro)">
  9. <view class="product-list-image">
  10. <image class="product-image" :src="pro.mainImage" mode=""></image>
  11. <!-- 推荐 -->
  12. <image class="product-icon" :src="StaticUrl+'recommend.png'" mode="" v-if="pro.recommend === '1'"></image>
  13. </view>
  14. <view class="product-list-msg">
  15. <view class="product-msg-name">{{ pro.name }}</view>
  16. <view class="product-list-tag " v-if="pro.activeStatus == 1">
  17. <text class="tag tag-02">活动价</text>
  18. </view>
  19. <view class="product-list-pri">
  20. <view class="price">¥{{ pro.price | PriceFormat}}</view>
  21. <view class="carts" @click.stop="handAddCarts(pro)">
  22. <view class="carts-add">
  23. <text class="iconfont icon-gouwuche"></text>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <tui-loadmore :index="2" v-if="hasNextPage"></tui-loadmore>
  31. <tui-nomore text="没有更多了" v-else></tui-nomore>
  32. <!-- 侧边 -->
  33. <scroll-top :isScrollTop="isScrollTop" :bottom="160"></scroll-top>
  34. </view>
  35. </template>
  36. <script>
  37. import tuiSkeleton from "@/components/tui-skeleton/tui-skeleton"
  38. import tuiLoadmore from '@/components/tui-loadmore/tui-loadmore.vue';
  39. import tuiNomore from '@/components/tui-nomore/tui-nomore.vue';
  40. import authorize from '@/common/config/authorize.js'
  41. import btSearch from '@/components/uni-search/bt-search.vue'
  42. import banner from '@/components/cm-module/homeIndex/banner.vue'
  43. import { mapState,mapMutations} from 'vuex';
  44. export default {
  45. components:{
  46. tuiSkeleton,
  47. btSearch,
  48. banner,
  49. tuiLoadmore,
  50. tuiNomore
  51. },
  52. data() {
  53. return {
  54. StaticUrl:this.$Static,
  55. title:'', // 页面标题
  56. floorId:'', //楼层id
  57. userId:0,
  58. skeletonShow: true,
  59. productList:[],//商品列表
  60. pageNum:1,
  61. pageSize:10,
  62. hasNextPage:false,
  63. isScrollTop:false,
  64. isRequest:false,
  65. }
  66. },
  67. filters: {
  68. //处理金额
  69. PriceFormat: function(text) {
  70. return Number(text).toFixed(2)
  71. }
  72. },
  73. onLoad(options) {
  74. console.log(options);
  75. this.floorId = options.floorId
  76. this.userId = this.userInfo?.userId
  77. this.fetchProductList()
  78. uni.setNavigationBarTitle({
  79. title:options.title
  80. })
  81. },
  82. computed: {
  83. ...mapState(['hasLogin','userInfo','identity','isActivity'])
  84. },
  85. methods: {
  86. //初始化商品数据列表
  87. fetchProductList(){
  88. this.ProductService.QueryProductList(
  89. {
  90. pageNum:this.pageNum,
  91. pageSize:this.pageSize,
  92. floorId:this.floorId
  93. }
  94. )
  95. .then(response =>{
  96. let data = response.data;
  97. this.productList = data.list
  98. this.hasNextPage = data.hasNextPage
  99. this.title = data.title
  100. // 获取购物车商品数量
  101. // this.GetCartNumber();
  102. this.skeletonShow = false
  103. })
  104. .catch(error =>{
  105. this.$util.msg(error.msg,2000)
  106. })
  107. },
  108. //上滑加载更多
  109. GetOnReachBottomProductList(){
  110. this.pageNum+=1
  111. this.ProductService.QueryProductList(
  112. {
  113. pageNum:this.pageNum,
  114. pageSize:this.pageSize,
  115. floorId:this.floorId
  116. }
  117. )
  118. .then(response =>{
  119. let data = response.data;
  120. this.hasNextPage = data.hasNextPage
  121. this.productList = this.productList.concat(data.list)
  122. })
  123. .catch(error =>{
  124. this.$util.msg(error.msg,2000)
  125. })
  126. },
  127. // 商品详情
  128. Details(pro){
  129. this.$api.navigateTo(`/pages/goods/product?productId=${pro.productId}`)
  130. },
  131. // 添加到购物车
  132. handAddCarts(pro){
  133. if(!this.hasLogin){
  134. this.$api.navigateTo(`/pages/login/login`)
  135. }else{
  136. this.ProductService.shoppingAddCart(
  137. {
  138. productId:pro.productId,
  139. userId:this.userId,
  140. productCount:1,
  141. heUserId:0,
  142. }
  143. )
  144. .then(response => {
  145. this.$util.msg('加入购物车成功',1500,true,'success')
  146. this.GetCartNumber()
  147. })
  148. .catch(error =>{
  149. this.$util.msg(error.msg,2000);
  150. })
  151. }
  152. },
  153. //查询购物车数量
  154. GetCartNumber(){
  155. this.ProductService.QueryShoppingQuantity(
  156. {
  157. userId:this.userId,
  158. }
  159. )
  160. .then(response => {
  161. this.$store.commit('updateAllNum',response.data)
  162. })
  163. .catch(error =>{
  164. console.log('查询购物车数量错误信息',error)
  165. })
  166. }
  167. },
  168. onShow() {
  169. this.GetCartNumber()
  170. },
  171. // 监听页面滚动事件
  172. onPageScroll(e) {
  173. if(e.scrollTop>400){
  174. this.isScrollTop = true
  175. }else{
  176. this.isScrollTop = false
  177. }
  178. },
  179. onPullDownRefresh() {//下拉刷新
  180. // this.getHomeInformation()
  181. this.pageNum = 1
  182. this.fetchProductList()
  183. setTimeout(()=>{
  184. uni.stopPullDownRefresh()
  185. }, 2000)
  186. },
  187. onReachBottom() {
  188. console.log('触底了..');
  189. if(this.hasNextPage){
  190. this.GetOnReachBottomProductList()
  191. }
  192. },
  193. onShareAppMessage(res){//分享转发
  194. if (res.from === 'button') {
  195. // 来自页面内转发按钮
  196. }
  197. return {
  198. title: '国内外知名美容院线护肤品线上商城~',
  199. path: 'pages/tabBar/index/index',
  200. imageUrl:'https://static.caimei365.com/app/mini-hehe/icon/icon-index-share.jpg'
  201. }
  202. }
  203. }
  204. </script>
  205. <style lang="scss">
  206. page{
  207. background-color: #F7F7F7;
  208. }
  209. .container{
  210. width: 750rxp;
  211. height: 100vh;
  212. }
  213. .navbar-wrap {
  214. position: fixed;
  215. width: 100%;
  216. top: 0;
  217. z-index: 100000;
  218. box-sizing: border-box;
  219. background-image: linear-gradient(0deg, #f83c6c 0%, #fa55bf 100%);
  220. background-size: cover;
  221. border-bottom:none;
  222. &.bgnone{
  223. background: rgba(255,255,255,0);
  224. }
  225. &.bgclass{
  226. background: #F94A9B;
  227. }
  228. }
  229. .navbar-text {
  230. font-size: 30rpx;
  231. color: #000000;
  232. font-weight: 500;
  233. }
  234. .navbar-text.center{
  235. text-align: center;
  236. }
  237. .navbar-text.left{
  238. text-align: left;
  239. padding-left: 45px;
  240. }
  241. .navbar-icon {
  242. position: fixed;
  243. display: flex;
  244. box-sizing: border-box;
  245. }
  246. .navbar-icon .iconfont {
  247. display: inline-block;
  248. overflow: hidden;
  249. font-size: 44rpx;
  250. padding-right:40rpx;
  251. margin-top: 1px;
  252. }
  253. .navbar-icon .icon-iconfonticonfontsousuo1 {
  254. color: #000000;
  255. }
  256. .navbar-icon view {
  257. height: 18px;
  258. border-left: 0.5px solid rgba(0,0,0, 0.3);
  259. margin-top: 6px;
  260. }
  261. .navbar-loading {
  262. background: #fff;
  263. text-align: center;
  264. }
  265. .search-input{
  266. width: 100%;
  267. height: 110rpx;
  268. padding: 20rpx 24rpx;
  269. box-sizing: border-box;
  270. .gosearch-btn{
  271. width: 100%;
  272. height: 100%;
  273. border-radius: 40rpx;
  274. background: #F0F0F0;
  275. margin: 0 auto;
  276. font-size: 28rpx;
  277. line-height: 70rpx;
  278. color: #8A8A8A;
  279. background: #FFFFFF;
  280. position: relative;
  281. box-sizing: border-box;
  282. padding-left: 80rpx;
  283. .search-icon{
  284. width: 80rpx;
  285. height: 70rpx;
  286. position:absolute ;
  287. left: 0;
  288. top: 0;
  289. text-align: center;
  290. line-height: 70rpx;
  291. .icon-iconfonticonfontsousuo1{
  292. margin:0 6rpx;
  293. font-size: $font-size-34;
  294. color: #8A8A8A;
  295. z-index: 10;
  296. }
  297. }
  298. .search-text{
  299. font-size: $font-size-24;
  300. line-height: 70rpx;
  301. color: #8A8A8A;
  302. }
  303. }
  304. }
  305. .container-section{
  306. width: 100%;
  307. height: auto;
  308. background-color: #F7F7F7;
  309. box-sizing: border-box;
  310. padding: 0 24rpx;
  311. .product-list{
  312. width: 339rpx;
  313. height: 532rpx;
  314. float: left;
  315. margin-right: 24rpx;
  316. margin-top: 24rpx;
  317. background-color: #FFFFFF;
  318. border-radius: 16rpx;
  319. &:nth-child(2n){
  320. margin-right: 0;
  321. }
  322. .product-list-image{
  323. width: 100%;
  324. height: 339rpx;
  325. float: left;
  326. position: relative;
  327. .product-image{
  328. width: 100%;
  329. height: 100%;
  330. display: block;
  331. border-radius: 16rpx 16rpx 0 0;
  332. }
  333. .product-icon{
  334. width: 68rpx;
  335. height: 55rpx;
  336. display: block;
  337. position: absolute;
  338. top: 0;
  339. left: 34rpx;
  340. }
  341. }
  342. .product-list-msg{
  343. width: 100%;
  344. height: 193rpx;
  345. box-sizing: border-box;
  346. padding: 16rpx 24rpx;
  347. float: left;
  348. position: relative;
  349. .product-msg-name{
  350. width: 100%;
  351. height: 72rpx;
  352. line-height: 35rpx;
  353. text-overflow: ellipsis;
  354. overflow: hidden;
  355. display: -webkit-box;
  356. -webkit-line-clamp: 2;
  357. line-clamp: 2;
  358. -webkit-box-orient: vertical;
  359. font-size: $font-size-26;
  360. color: #333333;
  361. text-align: justify;
  362. float: left;
  363. }
  364. .product-list-tag{
  365. position: relative;
  366. z-index: 9;
  367. width: 100%;
  368. height: 30rpx;
  369. margin-top: 8rpx;
  370. float: left;
  371. .tag{
  372. display: inline-block;
  373. height: 32rpx;
  374. font-size: 22rpx;
  375. line-height: 30rpx;
  376. text-align: center;
  377. color: #f83c6c;
  378. float: left;
  379. margin-right: 10rpx;
  380. &.tag-02{
  381. width: 80rpx;
  382. background: url(https://static.caimei365.com/app/mini-hehe/icon/icon-active.png)top center no-repeat;
  383. background-size: contain;
  384. }
  385. &.tag-01{
  386. width: 56rpx;
  387. color: #fff;
  388. background-color: #f83c6c;
  389. border-radius: 4rpx;
  390. }
  391. }
  392. }
  393. .product-list-pri{
  394. width: 100%;
  395. height: 44rpx;
  396. float: left;
  397. position: absolute;
  398. bottom: 16rpx;
  399. left: 0;
  400. box-sizing: border-box;
  401. padding: 0 24rpx;
  402. .price{
  403. float: left;
  404. font-size:$font-size-26;
  405. color: #f83c6c;
  406. font-weight: bold;
  407. line-height: 44rpx;
  408. }
  409. .carts{
  410. float: right;
  411. .carts-add{
  412. width: 44rpx;
  413. height: 44rpx;
  414. text-align: center;
  415. line-height: 44rpx;
  416. background-color: #ff457b;
  417. border-radius: 50%;
  418. .iconfont{
  419. font-size: 32rpx;
  420. color: #FFFFFF;
  421. }
  422. }
  423. }
  424. }
  425. }
  426. }
  427. }
  428. .clearfix::after{
  429. content: "";
  430. display: block;
  431. clear: both;
  432. }
  433. </style>