jfgood.vue 5.6 KB

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