list.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <style lang="scss">
  2. .m-app{
  3. padding: 0px 20rpx;
  4. }
  5. .sreach{
  6. background: #fff;
  7. margin:20rpx 0;
  8. border-radius: 32rpx;
  9. padding: 16rpx 32rpx;
  10. .icon{
  11. width: 46rpx;
  12. height: 46rpx;
  13. }
  14. input{
  15. width: calc(100% - 46rpx - 16rpx - 50px);
  16. font-size: 16px;
  17. }
  18. .search-btn{
  19. font-size: 14px;
  20. color: #FF4C4C;
  21. }
  22. }
  23. .goods-items{
  24. .item{
  25. width: calc(50% - 10rpx);
  26. margin-right: 10rpx;
  27. margin-top: 20rpx;
  28. box-shadow: 0px 0px 20px 0px rgba(50,50,52,0.1);
  29. border-radius: 20rpx;
  30. &:nth-child(2n){
  31. margin-left: 10rpx;
  32. margin-right: 0;
  33. }
  34. .nimg{
  35. width: 100%;
  36. height: calc(50vw - 20rpx - 10rpx);
  37. border-radius: 20rpx 20rpx 0 0;
  38. }
  39. .title{
  40. padding: 20rpx;
  41. height: 80rpx;
  42. overflow:hidden;
  43. text-overflow:ellipsis;
  44. display:-webkit-box;
  45. -webkit-box-orient:vertical;
  46. -webkit-line-clamp:2;
  47. color: #333333;
  48. font-weight: bold;
  49. font-size: 30rpx;
  50. }
  51. .iview{
  52. padding: 20rpx;
  53. .score{
  54. color: #FF4C4C;
  55. font-weight: bold;
  56. font-size: 36rpx;
  57. .tag{
  58. font-weight: bold;
  59. font-size: 18rpx;
  60. color: #FF4C4C;
  61. }
  62. }
  63. .btn{
  64. background: linear-gradient(143.2747deg, #FF6A00, #EE0979);
  65. border-radius: 40rpx;
  66. padding: 10rpx 28rpx;
  67. font-size: 22rpx;
  68. color: #FFFFFF;
  69. }
  70. }
  71. }
  72. }
  73. </style>
  74. <template>
  75. <view class="m-app">
  76. <!--关键词搜索-->
  77. <view class="sreach fx-r fx-bc fx-ac" id="top-main" >
  78. <image class="icon" src="/static/img/tb-seach.png"></image>
  79. <input type="text" confirm-type="search" v-model="keyword" @confirm="tapInput" placeholder="请输入关键词" placeholder-style="color: #B3B3B3;" />
  80. <view class="fx-g1"></view>
  81. <view class="search-btn" @tap="tapInput" v-if="keyword != ''">搜索</view>
  82. </view>
  83. <scroll-view :style="'height:calc(100vh - ' + topHeight + 'px - ' + h5Foot + 'px)'" class="mid-body clearfix" scroll-y="true" @scrolltolower="loadMoreData">
  84. <view class="goods-items fx-r">
  85. <view class="item" @tap="tapOpen" v-for="item in data" :data-url="'/pages/goods/index?id=' + item.id">
  86. <image :src="item.img" mode="aspectFill" class="nimg"></image>
  87. <view class="title">
  88. {{ item.title }}
  89. </view>
  90. <view class="iview fx-r">
  91. <view class="score fx-r fx-be">
  92. {{ item.commission }}
  93. <view class="tag" v-if="sysData.is_audit == 0">>积分</view>
  94. </view>
  95. <view class="fx-g1"></view>
  96. <view class="btn" v-if="sysData.is_audit == 0">>提货</view>
  97. </view>
  98. </view>
  99. </view>
  100. <view class="loading fx-r fx-ac fx-bc" v-if="!page.isFoot">
  101. <image src="/static/img/xloading.png"></image>
  102. <text>正在载入更多...</text>
  103. </view>
  104. <view class="loading complete" :hidden="!page.isFoot">已加载全部</view>
  105. </scroll-view>
  106. </view>
  107. </template>
  108. <script>
  109. import {mapState,mapMutations } from 'vuex'
  110. var cateId = 0;
  111. var brandId = 0;
  112. var activeId = "";//限时抢购rush,秒杀专场seckill
  113. var is_rush = 0;//
  114. var type = "";
  115. export default {
  116. computed: mapState(['user','sysData']),
  117. data() {
  118. return {
  119. keyword : "",
  120. tabIndex : 0,
  121. topHeight:0,
  122. tabPriceIndex : 0,
  123. data : [],
  124. h5Foot : 0,
  125. page:{
  126. page:1,
  127. isLoad:false,
  128. isFoot:false
  129. }
  130. }
  131. },
  132. /**
  133. * 跳转的值
  134. * @param {Object} option
  135. */
  136. onLoad(option){
  137. this.keyword = option.keyword || "";
  138. cateId = option.cateId || 0;
  139. brandId = option.brandId || 0;
  140. activeId = option.activeId || '';
  141. if(this.utils.isDefine(option.title)) {
  142. uni.setNavigationBarTitle({
  143. title:option.title
  144. });
  145. }
  146. this.$nextTick(()=>{
  147. const query = uni.createSelectorQuery().in(this);
  148. query.select("#top-main").boundingClientRect(res=>{
  149. this.topHeight = res.height;
  150. }).exec();
  151. });
  152. //判断是否H5
  153. // #ifdef H5
  154. this.h5Foot = 50;
  155. // #endif
  156. this.getData(true);
  157. },
  158. methods: {
  159. /**
  160. * 输入
  161. */
  162. tapInput:function(ev){
  163. this.page = {page:1,isLoad:false,isFoot:false};
  164. this.getData(true);
  165. },
  166. /**
  167. * 下拉加载
  168. */
  169. loadMoreData:function(){
  170. if(this.page.isFoot || this.page.isLoad) {
  171. return;
  172. }
  173. this.page.page ++;
  174. this.getData();
  175. },
  176. /**
  177. * 获取get数据
  178. */
  179. getData:function(isPull = false){
  180. if (this.page.isLoad) return;
  181. this.page.isLoad = true;
  182. if (isPull) {
  183. uni.showLoading({ title: '获取数据中..'});
  184. }
  185. var post = {};
  186. if(this.keyword != "") {
  187. post.keyword = this.keyword;
  188. }
  189. post.page = this.page.page;
  190. this
  191. .request
  192. .post("goodsList",post)
  193. .then(res => {
  194. uni.hideLoading();
  195. uni.hideLoading();
  196. if (isPull) {
  197. this.data = res.data.list;
  198. uni.stopPullDownRefresh();
  199. } else {
  200. this.data = this.data.concat(res.data.list);
  201. }
  202. this.page.isLoad = false;
  203. //是否到底
  204. if (res.data.list.length != res.data.pageSize) {
  205. this.page.isFoot = true;
  206. }
  207. })
  208. .catch(res=>{
  209. console.log(res);
  210. uni.hideLoading();
  211. uni.showModal({title: '系统提示',content: '加载失败,重新点击尝试!',showCancel: false});
  212. });
  213. },
  214. /**
  215. * 打开其他页面
  216. * @param {Object} ev
  217. */
  218. tapOpen: function(ev) {
  219. let url = ev.currentTarget.dataset.url
  220. uni.navigateTo({
  221. url: url
  222. });
  223. },
  224. /**
  225. * 返回上一页
  226. */
  227. tapBack: function () {
  228. uni.navigateBack({ delta: 1 });
  229. },
  230. }
  231. }
  232. </script>