index.vue 5.1 KB

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