integral.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <view class="main">
  3. <!-- <view class="top-search">
  4. <input type="text" class="search-key" placeholder="请输入关键字" v-model="keyword" />
  5. <image src="../../static/icon/search.png" mode="" class="search-logo"></image>
  6. <view class="search-btn" @click.stop="search">搜索</view>
  7. </view> -->
  8. <scroll-view scroll-y="true" :style="{ height: height }" class="scoll-wrap" @scrolltolower="getArticleList()">
  9. <view class="list-box-h">
  10. <view v-for="(item, index) in list" :key="index" class="guess-item" @click="navToDetailPage(item)">
  11. <image :src="item.image"></image>
  12. <view class="guess-box">
  13. <view class="title clamp2">{{ item.store_name }}</view>
  14. <view class="flex itemContent">
  15. <view>
  16. <view class="price flex">{{ item.result.value[0].price }}元+</view>
  17. <view class="price">{{ item.result.value[0].integral }}积分</view>
  18. </view>
  19. <view class="btn">立即购买</view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <uni-load-more :status="loadingType"></uni-load-more>
  25. </scroll-view>
  26. </view>
  27. </template>
  28. <script>
  29. import { jfShop } from '@/api/product.js';
  30. export default {
  31. data() {
  32. return {
  33. height: '',
  34. list: [],
  35. page: 1,
  36. limit: 10,
  37. loadingType: 'more',
  38. total_pages: 0,
  39. keyword: ''
  40. };
  41. },
  42. onLoad(opt) {
  43. this.getArticleList();
  44. },
  45. onReachBottom() {
  46. this.getArticleList();
  47. },
  48. onReady(res) {
  49. var obj = this;
  50. uni.getSystemInfo({
  51. success: resu => {
  52. const query = uni.createSelectorQuery();
  53. query.select('.scoll-wrap').boundingClientRect();
  54. query.exec(function(res) {
  55. console.log(res, 'ddddddddddddd');
  56. obj.height = resu.windowHeight - res[0].top + 'px';
  57. console.log('打印页面的剩余高度', obj.height);
  58. });
  59. },
  60. fail: res => {}
  61. });
  62. },
  63. methods: {
  64. navToDetailPage(item) {
  65. uni.navigateTo({
  66. url: '/pages/product/product?id=' + item.id + '&isJF=1'
  67. });
  68. },
  69. getArticleList() {
  70. let obj = this;
  71. if (obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
  72. return;
  73. }
  74. obj.loadingType = 'loading';
  75. jfShop({
  76. page: obj.page,
  77. limit: obj.limit
  78. }).then(({ data }) => {
  79. console.log(data, 'data');
  80. obj.list = obj.list.concat(data);
  81. // obj.total_pages = data.meta.pagination.total_pages
  82. obj.page++;
  83. if (obj.page <= obj.total_pages) {
  84. obj.loadingType = 'more';
  85. } else {
  86. obj.loadingType = 'noMore';
  87. }
  88. // if (data.length == obj.limit) {
  89. // obj.loadingType = 'more'
  90. // } else {
  91. // obj.loadingType = 'noMore'
  92. // }
  93. });
  94. },
  95. search() {
  96. let obj = this;
  97. obj.page = 1;
  98. obj.list = [];
  99. obj.loadingType = 'more';
  100. obj.getArticleList();
  101. }
  102. }
  103. };
  104. </script>
  105. <style lang="scss" scoped>
  106. page {
  107. background-color: #fff;
  108. min-height: 100%;
  109. }
  110. .list-box-h {
  111. padding: 20rpx;
  112. }
  113. .guess-item {
  114. padding: 10rpx;
  115. display: flex;
  116. min-width: 100%;
  117. width: 0;
  118. margin-bottom: 20rpx;
  119. background: #ffffff;
  120. border-radius: 10rpx;
  121. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  122. image {
  123. width: 200rpx;
  124. height: 200rpx;
  125. border-radius: 10rpx;
  126. flex-shrink: 0;
  127. }
  128. .guess-box {
  129. width: 100%;
  130. padding: 5px;
  131. position: relative;
  132. .itemContent {
  133. position: absolute;
  134. width: 100%;
  135. padding: 20rpx 10rpx;
  136. bottom: 0;
  137. right: 0;
  138. }
  139. .title {
  140. font-size: 30rpx;
  141. font-weight: bold;
  142. color: #333333;
  143. height: 2.5em;
  144. line-height: 1.25em;
  145. }
  146. .price-box {
  147. justify-content: flex-start;
  148. .yuanprice {
  149. font-size: 26rpx;
  150. font-family: PingFang SC;
  151. font-weight: 500;
  152. text-decoration: line-through;
  153. color: #999999;
  154. padding-right: 6rpx;
  155. }
  156. image {
  157. width: 14rpx;
  158. height: 16rpx;
  159. }
  160. .jiang {
  161. padding-left: 2rpx;
  162. font-size: 24rpx;
  163. font-family: PingFang SC;
  164. font-weight: bold;
  165. color: #b59467;
  166. }
  167. }
  168. .price {
  169. font-size: 36rpx;
  170. font-family: PingFang SC;
  171. font-weight: bold;
  172. color: #ff6f0f;
  173. }
  174. .btn {
  175. background: #16cc9f;
  176. border-radius: 28rpx;
  177. font-size: 28rpx;
  178. font-weight: 500;
  179. color: #ffffff;
  180. float: right;
  181. padding: 10rpx 20rpx;
  182. }
  183. }
  184. }
  185. .top-search {
  186. width: 750rpx;
  187. height: 100rpx;
  188. // padding-top: 20rpx;
  189. display: flex;
  190. justify-content: center;
  191. align-items: center;
  192. position: relative;
  193. .search-key {
  194. width: 700rpx;
  195. height: 70rpx;
  196. padding-left: 100rpx;
  197. background: #ffffff;
  198. box-shadow: 0px 1rpx 5rpx #16cc9f;
  199. border-radius: 35rpx;
  200. position: relative;
  201. }
  202. .search-logo {
  203. width: 36rpx;
  204. height: 36rpx;
  205. position: absolute;
  206. top: 0;
  207. bottom: 0;
  208. left: 50rpx;
  209. margin: auto;
  210. }
  211. .search-btn {
  212. width: 150rpx;
  213. height: 70rpx;
  214. border-radius: 30rpx;
  215. color: #16cc9f;
  216. text-align: center;
  217. line-height: 70rpx;
  218. position: absolute;
  219. top: 0;
  220. bottom: 0;
  221. right: 10rpx;
  222. margin: auto;
  223. // background-color: red;
  224. z-index: 9;
  225. }
  226. }
  227. </style>