good-coupon-list.vue 11 KB

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