index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  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. <view class="czpt">
  25. <view class="good-wrapper">
  26. <view class="spgood" @click="goProduct(items)" v-for="(items, ind) in goodsList" :key="ind">
  27. <view class="left-wrapper"><image :src="items.image" mode="scaleToFill"></image></view>
  28. <view class="right-wrapper">
  29. <view class="right-title clamp">{{ items.title }}</view>
  30. <view class="ex-addr">
  31. <image src="../../../static/img/shop.png" mode="" class="name-img"></image>
  32. {{checkedStore.name | longstorename }}
  33. <image src="../../../static/img/point.png" mode="" class="point-img"></image>
  34. {{ des | distance }}
  35. </view>
  36. <view class="pepple-num"><image src="../../../static/icon/hot.png" mode="scaleToFill"></image>{{ items.people }}人团</view>
  37. <view class="right-bottom">
  38. <view class="sp-price">
  39. <view class="now-price">¥{{ items.price * 1 }}</view>
  40. <view class="old-price">¥{{ items.product_price * 1 }}</view>
  41. </view>
  42. <view class="sp-btn">马上拼团</view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  51. import { getCombinationList } from '@/api/product.js';
  52. import { mapMutations,mapState } from 'vuex';
  53. export default {
  54. components: {
  55. uniLoadMore
  56. },
  57. data() {
  58. return {
  59. goodsList: [],
  60. loadingType: 'more', //加载更多状态
  61. limit: 20, //每次加载数据条数
  62. page: 1 //当前页数
  63. };
  64. },
  65. computed: {
  66. ...mapState('user', ['userInfo', 'checkedStore', 'des', 'latlng']),
  67. },
  68. onLoad(options) {
  69. this.loadData();
  70. },
  71. //下拉刷新
  72. onPullDownRefresh() {
  73. this.loadData('refresh');
  74. },
  75. //监听页面是否滚动到底部加载更多
  76. onReachBottom() {
  77. this.loadData();
  78. },
  79. filters: {
  80. storename(val) {
  81. let str = ''
  82. if(val) {
  83. str = val
  84. if(val.length > 5) {
  85. str = val.slice(0,5)+'...'
  86. }
  87. }
  88. return str
  89. },
  90. longstorename(val) {
  91. let str = ''
  92. if(val) {
  93. str = val
  94. if(val.length > 10) {
  95. str = val.slice(0,10)+'...'
  96. }
  97. }
  98. return str
  99. },
  100. distance(val) {
  101. let str = ''
  102. if(val) {
  103. if(val*1 > 1000) {
  104. return str = (val*1/1000).toFixed(1) + 'km'
  105. }
  106. }else {
  107. return str = (val*1).toFixed(0) + 'm'
  108. }
  109. return str
  110. }
  111. },
  112. methods: {
  113. //加载商品 ,带下拉刷新和上滑加载
  114. async loadData(type = 'add', loading) {
  115. let obj = this;
  116. let data = {
  117. page: obj.page,
  118. limit: obj.limit
  119. };
  120. //没有更多直接返回
  121. if (type === 'add') {
  122. if (obj.loadingType === 'nomore') {
  123. return;
  124. }
  125. obj.loadingType = 'loading';
  126. } else {
  127. obj.loadingType = 'more';
  128. }
  129. // 加载商品信息
  130. getCombinationList(data)
  131. .then(e => {
  132. console.log(e,'++++++++++++e+++++++')
  133. if (type === 'refresh') {
  134. // 清空数组
  135. obj.goodsList = [];
  136. }
  137. obj.goodsList = obj.goodsList.concat(e.data);
  138. //判断是否还有下一页,有是more 没有是nomore
  139. if (obj.limit == e.data.length) {
  140. obj.page++;
  141. obj.loadingType = 'more';
  142. } else {
  143. obj.loadingType = 'nomore';
  144. }
  145. if (type === 'refresh') {
  146. if (loading == 1) {
  147. uni.hideLoading();
  148. } else {
  149. uni.stopPullDownRefresh();
  150. }
  151. }
  152. })
  153. .catch();
  154. },
  155. goProduct(e) {
  156. uni.navigateTo({
  157. url: '/pages/product/groupBooking/productGroup?id=' + e.id
  158. });
  159. }
  160. }
  161. };
  162. </script>
  163. <style lang="scss">
  164. page {
  165. height: 100%;
  166. }
  167. // 拼团列表
  168. .lyy-f-a {
  169. margin: 0px 15px;
  170. .lyy-flex {
  171. /* 内部模块1*/
  172. display: flex;
  173. justify-content: space-between;
  174. }
  175. .lyy-f-b {
  176. flex-wrap: wrap;
  177. .lyy-f-c {
  178. flex: 0 0 50%;
  179. /* width: 50%; */
  180. margin: 10px 0px 0px 0px;
  181. }
  182. .item:nth-child(2n + 1) .content {
  183. margin: 0px 7.5px 0px 0px;
  184. border-radius: 10px;
  185. }
  186. }
  187. .lyy-f-b .content {
  188. background-color: white;
  189. .lyy-f-image {
  190. width: 100%;
  191. height: 340rpx;
  192. border-radius: 10rpx 10rpx 0rpx 0rpx;
  193. }
  194. .ellipsis {
  195. width: 165px;
  196. white-space: nowrap;
  197. overflow: hidden;
  198. text-overflow: ellipsis;
  199. }
  200. .lyy-f-jl {
  201. padding: 5px 7px;
  202. }
  203. .lyy-f-word1 {
  204. font-size: 12px;
  205. color: rgba(50, 50, 50, 1);
  206. line-height: 20px;
  207. width: 300rpx;
  208. white-space: nowrap;
  209. overflow: hidden;
  210. text-overflow: ellipsis;
  211. }
  212. }
  213. .item:nth-child(2n) .content {
  214. margin: 0px 0 0px 7.5px;
  215. border-radius: 10px;
  216. }
  217. .lyy-f-word3 {
  218. font-size: 12px;
  219. text-decoration: line-through;
  220. color: rgba(139, 139, 139, 1);
  221. }
  222. .lyy-f-word5 {
  223. font-size: 20rpx;
  224. color: rgba(153, 153, 153, 1);
  225. margin: 20rpx 0px 0px 0px;
  226. }
  227. .lyy-f-word4 {
  228. height: 26px;
  229. background: #6fb22f;
  230. color: white;
  231. text-align: center;
  232. }
  233. .lyy-f-d {
  234. height: 24rpx;
  235. border: 1px solid rgba(252, 91, 98, 1);
  236. border-radius: 3px;
  237. font-size: 20rpx;
  238. text-align: center;
  239. width: 50rpx;
  240. color: rgba(252, 91, 98, 1);
  241. margin: 23rpx 0rpx 0rpx 0rpx;
  242. line-height: 24rpx;
  243. }
  244. .lyy-flex2 {
  245. display: flex;
  246. padding-right: 10rpx;
  247. align-items: center;
  248. .lyy-flex3 {
  249. flex: 1;
  250. .lyy-f-word2 {
  251. font-size: 14px;
  252. color: rgba(241, 13, 59, 1);
  253. }
  254. }
  255. &.lyy-a-tu2 {
  256. height: 34rpx;
  257. background: rgba(255, 255, 255, 1);
  258. border: 1px solid #fc5b62;
  259. border-radius: 2px;
  260. margin: 10rpx 0rpx;
  261. .lyy-a-tu3 {
  262. height: 30rpx;
  263. background-color: #fc5b62;
  264. padding: 0px 6px;
  265. text-align: center;
  266. .lyy-a-tu5 {
  267. width: 20rpx;
  268. height: 20rpx;
  269. margin-top: 6rpx;
  270. display: block;
  271. }
  272. }
  273. .lyy-a-tu4 {
  274. margin-left: 4rpx;
  275. font-size: 24rpx;
  276. line-height: 30rpx;
  277. color: #fc5b62;
  278. padding: 0px 10rpx;
  279. text-align: center;
  280. }
  281. }
  282. }
  283. }
  284. .good-wrapper {
  285. width: 710rpx;
  286. background-color: #f7f5f5;
  287. margin: 20rpx auto 0;
  288. .spgood {
  289. width: 710rpx;
  290. height: 280rpx;
  291. background: #FFFFFF;
  292. box-shadow: 0px 0px 20px 0px rgba(50, 50, 52, 0.06);
  293. border-radius: 8rpx;
  294. padding: 40rpx 20rpx;
  295. display: flex;
  296. margin-bottom: 21rpx;
  297. .left-wrapper {
  298. width: 190rpx;
  299. height: 200rpx;
  300. border-radius: 10rpx;
  301. image {
  302. width: 190rpx;
  303. height: 200rpx;
  304. border-radius: 10rpx;
  305. }
  306. }
  307. .right-wrapper {
  308. padding-left: 22rpx;
  309. width: 100%;
  310. height: 200rpx;
  311. // background-color: red;
  312. .right-title {
  313. padding-top: 8rpx;
  314. width: 400rpx;
  315. // height: 29rpx;
  316. font-size: 30rpx;
  317. font-weight: bold;
  318. color: #333333;
  319. }
  320. .right-addr {
  321. margin-top: 18rpx;
  322. display: flex;
  323. .shop-img {
  324. width: 26rpx;
  325. height: 23rpx;
  326. margin: 0 4rpx 0 0;
  327. image {
  328. width: 100%;
  329. height: 100%;
  330. }
  331. }
  332. .shop-name {
  333. // height: 22rpx;
  334. font-size: 22rpx;
  335. font-weight: 500;
  336. color: #dcb876;
  337. }
  338. .point-img {
  339. width: 16rpx;
  340. height: 23rpx;
  341. margin: 0 4rpx 0 14rpx;
  342. image {
  343. width: 100%;
  344. height: 21rpx;
  345. }
  346. }
  347. .point-disc {
  348. font-size: 24rpx;
  349. font-weight: 500;
  350. padding-top: 3rpx;
  351. color: #dcb876;
  352. }
  353. }
  354. .ex-addr {
  355. margin-top: 16rpx;
  356. // padding-left: 22rpx;
  357. height: 24rpx;
  358. font-size: 24rpx;
  359. font-weight: 500;
  360. color: #dcb876;
  361. image {
  362. height: 22rpx;
  363. }
  364. .name-img {
  365. // vertical-align: ;
  366. width: 26rpx;
  367. margin: 0 4rpx -3rpx 0;
  368. }
  369. .point-img {
  370. width: 16rpx;
  371. margin: 0 4rpx -3rpx 14rpx;
  372. }
  373. }
  374. .pepple-num {
  375. // width: 99rpx;
  376. display: inline-block;
  377. padding-right: 15rpx;
  378. height: 36rpx;
  379. // color: #ff3366;
  380. // background: #FC7A0C;
  381. background-color: #fee4ce;
  382. // opacity: 0.2;
  383. border-radius: 18rpx;
  384. font-size: 20rpx;
  385. font-weight: 500;
  386. color: #ff3366;
  387. line-height: 36rpx;
  388. padding-left: 12rpx;
  389. margin-top: 33rpx;
  390. image {
  391. width: 17rpx;
  392. height: 20rpx;
  393. margin-right: 10rpx;
  394. // padding-right: rpx;
  395. }
  396. }
  397. .right-bottom {
  398. margin-top: 2rpx;
  399. // justify-items: flex-end;
  400. display: flex;
  401. justify-content: space-between;
  402. .sp-price {
  403. height: 60rpx;
  404. display: flex;
  405. vertical-align: bottom;
  406. line-height: 60rpx;
  407. .now-price {
  408. font-size: 30rpx;
  409. font-weight: bold;
  410. color: #901b21;
  411. margin-right: 16rpx;
  412. }
  413. .old-price {
  414. font-size: 22rpx;
  415. font-weight: 500;
  416. text-decoration: line-through;
  417. color: #aaaaaa;
  418. }
  419. }
  420. .sp-btn {
  421. width: 160rpx;
  422. height: 60rpx;
  423. border-radius: 30rpx;
  424. font-size: 26rpx;
  425. text-align: center;
  426. line-height: 60rpx;
  427. font-weight: 400;
  428. color: #ffffff;
  429. background-color: #901b21;
  430. }
  431. }
  432. }
  433. }
  434. }
  435. </style>