index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view class="lyy-bg4">
  3. <view class="lyy-f-a">
  4. <view class="lyy-f-b lyy-flex">
  5. <view class="lyy-f-c item" @click="goProduct(items)" v-for="(items, ind) in goodsList" :key="ind">
  6. <view class="content">
  7. <view><image :src="items.image" class="lyy-f-image" /></view>
  8. <view class="lyy-f-word1 lyy-f-jl ellipsis">{{ items.title }}</view>
  9. <view class="lyy-flex2">
  10. <view class="lyy-flex3">
  11. <view class="lyy-f-word2 lyy-f-jl">¥{{ items.price * 1 }}</view>
  12. </view>
  13. <view class="lyy-a-tu2 lyy-flex2">
  14. <view class="lyy-a-tu3"><image src="../../../static/img/img11.png" class="lyy-a-tu5" /></view>
  15. <view class="lyy-a-tu4">{{ items.people }}人拼</view>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. <uni-load-more :status="loadingType"></uni-load-more>
  23. </view>
  24. </template>
  25. <script>
  26. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  27. import { getCombinationList } from '@/api/product.js';
  28. export default {
  29. components: {
  30. uniLoadMore
  31. },
  32. data() {
  33. return {
  34. goodsList: [],
  35. loadingType: 'more', //加载更多状态
  36. limit: 20, //每次加载数据条数
  37. page: 1 //当前页数
  38. };
  39. },
  40. onLoad(options) {
  41. this.loadData();
  42. },
  43. //下拉刷新
  44. onPullDownRefresh() {
  45. this.loadData('refresh');
  46. },
  47. //监听页面是否滚动到底部加载更多
  48. onReachBottom() {
  49. this.loadData();
  50. },
  51. methods: {
  52. //加载商品 ,带下拉刷新和上滑加载
  53. async loadData(type = 'add', loading) {
  54. let obj = this;
  55. let data = {
  56. page: obj.page,
  57. limit: obj.limit
  58. };
  59. //没有更多直接返回
  60. if (type === 'add') {
  61. if (obj.loadingType === 'nomore') {
  62. return;
  63. }
  64. obj.loadingType = 'loading';
  65. } else {
  66. obj.loadingType = 'more';
  67. }
  68. // 加载商品信息
  69. getCombinationList(data)
  70. .then(e => {
  71. if (type === 'refresh') {
  72. // 清空数组
  73. obj.goodsList = [];
  74. }
  75. obj.goodsList = obj.goodsList.concat(e.data);
  76. //判断是否还有下一页,有是more 没有是nomore
  77. if (obj.limit == e.data.length) {
  78. obj.page++;
  79. obj.loadingType = 'more';
  80. } else {
  81. obj.loadingType = 'nomore';
  82. }
  83. if (type === 'refresh') {
  84. if (loading == 1) {
  85. uni.hideLoading();
  86. } else {
  87. uni.stopPullDownRefresh();
  88. }
  89. }
  90. })
  91. .catch();
  92. },
  93. goProduct(e) {
  94. uni.navigateTo({
  95. url: '/pages/product/groupBooking/productGroup?id=' + e.id
  96. });
  97. }
  98. }
  99. };
  100. </script>
  101. <style lang="scss">
  102. page {
  103. height: 100%;
  104. }
  105. // 拼团列表
  106. .lyy-f-a {
  107. margin: 0px 15px;
  108. .lyy-flex {
  109. /* 内部模块1*/
  110. display: flex;
  111. justify-content: space-between;
  112. }
  113. .lyy-f-b {
  114. flex-wrap: wrap;
  115. .lyy-f-c {
  116. flex: 0 0 50%;
  117. /* width: 50%; */
  118. margin: 10px 0px 0px 0px;
  119. }
  120. .item:nth-child(2n + 1) .content {
  121. margin: 0px 7.5px 0px 0px;
  122. border-radius: 10px;
  123. }
  124. }
  125. .lyy-f-b .content {
  126. background-color: white;
  127. .lyy-f-image {
  128. width: 100%;
  129. height: 340rpx;
  130. border-radius: 10rpx 10rpx 0rpx 0rpx;
  131. }
  132. .ellipsis {
  133. width: 165px;
  134. white-space: nowrap;
  135. overflow: hidden;
  136. text-overflow: ellipsis;
  137. }
  138. .lyy-f-jl {
  139. padding: 5px 7px;
  140. }
  141. .lyy-f-word1 {
  142. font-size: 12px;
  143. color: rgba(50, 50, 50, 1);
  144. line-height: 20px;
  145. width: 300rpx;
  146. white-space: nowrap;
  147. overflow: hidden;
  148. text-overflow: ellipsis;
  149. }
  150. }
  151. .item:nth-child(2n) .content {
  152. margin: 0px 0 0px 7.5px;
  153. border-radius: 10px;
  154. }
  155. .lyy-f-word3 {
  156. font-size: 12px;
  157. text-decoration: line-through;
  158. color: rgba(139, 139, 139, 1);
  159. }
  160. .lyy-f-word5 {
  161. font-size: 20rpx;
  162. color: rgba(153, 153, 153, 1);
  163. margin: 20rpx 0px 0px 0px;
  164. }
  165. .lyy-f-word4 {
  166. height: 26px;
  167. background: #6fb22f;
  168. color: white;
  169. text-align: center;
  170. }
  171. .lyy-f-d {
  172. height: 24rpx;
  173. border: 1px solid rgba(252, 91, 98, 1);
  174. border-radius: 3px;
  175. font-size: 20rpx;
  176. text-align: center;
  177. width: 50rpx;
  178. color: rgba(252, 91, 98, 1);
  179. margin: 23rpx 0rpx 0rpx 0rpx;
  180. line-height: 24rpx;
  181. }
  182. .lyy-flex2 {
  183. display: flex;
  184. padding-right: 10rpx;
  185. align-items: center;
  186. .lyy-flex3 {
  187. flex: 1;
  188. .lyy-f-word2 {
  189. font-size: 14px;
  190. color: rgba(241, 13, 59, 1);
  191. }
  192. }
  193. &.lyy-a-tu2 {
  194. height: 34rpx;
  195. background: rgba(255, 255, 255, 1);
  196. border: 1px solid #fc5b62;
  197. border-radius: 2px;
  198. margin: 10rpx 0rpx;
  199. .lyy-a-tu3 {
  200. height: 30rpx;
  201. background-color: #fc5b62;
  202. padding: 0px 6px;
  203. text-align: center;
  204. .lyy-a-tu5 {
  205. width: 20rpx;
  206. height: 20rpx;
  207. margin-top: 6rpx;
  208. display: block;
  209. }
  210. }
  211. .lyy-a-tu4 {
  212. margin-left: 4rpx;
  213. font-size: 24rpx;
  214. line-height: 30rpx;
  215. color: #fc5b62;
  216. padding: 0px 10rpx;
  217. text-align: center;
  218. }
  219. }
  220. }
  221. }
  222. </style>