construction.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <view class="store-list">
  3. <scroll-view scroll-y="true" class="list" @scrolltolower="loadData()" :style="{'height': height}">
  4. <empty v-if="loaded && list.length == 0"></empty>
  5. <view class="store flex" v-for="item in list" @click="navTo('/pages/product/product?id=' + item.id + '&spread=' + userInfo.uid)">
  6. <image :src="item.image" mode="" class="store-img"></image>
  7. <view class="store-info">
  8. <view class="store-name clamp2">{{item.store_name}}</view>
  9. <!-- <view class="store-detail">台州市椒江区市府大道120号</view> -->
  10. <!-- <view class="info clamp">鑫旺零售台州店鑫旺零售台州店</view> -->
  11. <view class="price-box">
  12. <view class="new-price">
  13. {{item.price}}
  14. <!-- <text class="old-price"> ¥220.00</text> -->
  15. </view>
  16. </view>
  17. <view class="qb-btn">立即购买</view>
  18. </view>
  19. </view>
  20. <uni-load-more :status="loadingType" v-if="list != 0"></uni-load-more>
  21. </scroll-view>
  22. </view>
  23. </template>
  24. <script>
  25. import empty from '@/components/empty';
  26. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  27. import {getProducts} from '@/api/product.js'
  28. import { mapState, mapMutations } from 'vuex';
  29. export default {
  30. components: {
  31. uniLoadMore,
  32. empty
  33. },
  34. data() {
  35. return {
  36. list: [],
  37. storeList: [],
  38. loadingType: 'more',
  39. page: 1,
  40. limit: 10,
  41. height: '', //滚动区域高度
  42. loaded: false
  43. };
  44. },
  45. onReady(res) {
  46. var _this = this;
  47. uni.getSystemInfo({
  48. success: resu => {
  49. const query = uni.createSelectorQuery();
  50. query.select('.list').boundingClientRect();
  51. query.exec(function(res) {
  52. console.log(res, 'ddddddddddddd');
  53. _this.height = resu.windowHeight - res[0].top + 'px';
  54. console.log('打印页面的剩余高度', _this.height);
  55. });
  56. },
  57. fail: res => {}
  58. });
  59. },
  60. onLoad() {
  61. this.loadData();
  62. },
  63. computed: {
  64. ...mapState('user', ['hasLogin', 'userInfo']),
  65. },
  66. methods: {
  67. navTo(url) {
  68. uni.navigateTo({
  69. url: url
  70. })
  71. },
  72. //获取施工产品信息
  73. loadData() {
  74. let obj = this;
  75. if (obj.loadingType == 'loading') {
  76. return;
  77. }
  78. if (obj.loadingType == 'noMore') {
  79. return;
  80. }
  81. getProducts({
  82. page: obj.page,
  83. limit: obj.limit,
  84. is_drop: 1
  85. }).then(({data}) => {
  86. console.log(data,'is_drop++++++++++++++++')
  87. let list = data.map(item => {
  88. return item
  89. })
  90. obj.list = obj.list.concat(list)
  91. obj.page++
  92. if (obj.limit == data.length) {
  93. //判断是否还有数据, 有改为 more, 没有改为noMore
  94. obj.loadingType = 'more';
  95. return;
  96. } else {
  97. //判断是否还有数据, 有改为 more, 没有改为noMore
  98. obj.loadingType = 'noMore';
  99. }
  100. // uni.hideLoading();
  101. this.$set(obj, 'loaded', true);
  102. })
  103. }
  104. }
  105. };
  106. </script>
  107. <style lang="scss" scoped>
  108. .store-list {
  109. padding-top: 20rpx;
  110. }
  111. .store {
  112. margin: 0 auto 20rpx;
  113. // width: 710rpx;
  114. // height: 210rpx;
  115. // background: #ffffff;
  116. // box-shadow: 0px 0px 10rpx 0px rgba(0, 0, 0, 0.1);
  117. // border-radius: 10rpx;
  118. padding: 40rpx 20rpx;
  119. justify-content: flex-start;
  120. width: 710rpx;
  121. height: 280rpx;
  122. background: #ffffff;
  123. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  124. border-radius: 8rpx;
  125. .store-img {
  126. flex-shrink: 0;
  127. // background-color: red;
  128. width: 190rpx;
  129. height: 200rpx;
  130. border-radius: 10rpx;
  131. }
  132. .store-info {
  133. width: 481rpx;
  134. height: 100%;
  135. padding-left: 19rpx;
  136. position: relative;
  137. .store-name {
  138. width: 461rpx;
  139. padding-top: 10rpx;
  140. font-size: 30rpx;
  141. font-family: PingFang SC;
  142. font-weight: bold;
  143. color: #333333;
  144. }
  145. .store-detail {
  146. padding-top: 10rpx;
  147. font-size: 22rpx;
  148. font-family: PingFang SC;
  149. font-weight: 500;
  150. color: #666666;
  151. }
  152. .info {
  153. padding-top: 20rpx;
  154. font-size: 24rpx;
  155. font-family: PingFang SC;
  156. font-weight: 500;
  157. color: #FE6A42;
  158. }
  159. .qb-btn {
  160. width: 160rpx;
  161. height: 60rpx;
  162. line-height: 60rpx;
  163. line-height: 60rpx;
  164. text-align: center;
  165. background: linear-gradient(180deg, #fd4646, #ff3535);
  166. box-shadow: 0px 2rpx 20rpx 0px rgba(253, 67, 67, 0.5);
  167. border-radius: 30rpx;
  168. position: absolute;
  169. right: 0;
  170. bottom: 0;
  171. font-size: 28rpx;
  172. font-family: PingFang SC;
  173. font-weight: 500;
  174. color: #ffffff;
  175. text-align: center;
  176. }
  177. .price-box {
  178. padding-left: 20rpx;
  179. display: flex;
  180. align-items: flex-end;
  181. height: 42rpx;
  182. position: absolute;
  183. left: 0;
  184. bottom: 0;
  185. .new-price {
  186. font-size: 32rpx;
  187. font-family: PingFang SC;
  188. font-weight: bold;
  189. color: #ff0000;
  190. .old-price {
  191. display: inline-block;
  192. padding-left: 8rpx;
  193. font-size: 20rpx;
  194. font-family: PingFang SC;
  195. font-weight: 500;
  196. text-decoration: line-through;
  197. color: #999999;
  198. }
  199. }
  200. }
  201. }
  202. }
  203. </style>