goodsList.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <view class="container">
  3. <uv-navbar title="商品列表" placeholder @leftClick="goBack"></uv-navbar>
  4. <uv-sticky :customNavHeight="tabTop">
  5. <view class="zdtopbox">
  6. <div class="search-box">
  7. <div class="search-wap">
  8. <!-- <text class="iconfont search-icon">&#xe7a6;</text> -->
  9. <text class="iconfont search-icon">&#xe618;</text>
  10. <input type="text" class="sput" placeholder-style="color: #ddd;" confirm-type="search" v-model="value" placeholder="请输入搜索关键字" @confirm="confirmSubmit" />
  11. </div>
  12. <div class="word" @click="search()">搜索</div>
  13. </div>
  14. <view class="tabs">
  15. <view class="screen" @click="screening(1)">
  16. <view :class="screeningIndex == 1 ? 'activeColors' : ''">综合</view>
  17. </view>
  18. <view class="screen" @click="screening(4)">
  19. <view :class="screeningIndex == 4 ? 'activeColors' : ''">销量</view>
  20. </view>
  21. <view class="screen sortScreen" @click="screening(3)">
  22. <view :class="screeningIndex == 3 ? 'activeColors' : ''">价格</view>
  23. <view class="linge-box">
  24. <view class="iconfont linge" :class="screeningIndex == 3 && !price ? 'activeColors' : ''">&#xe648;
  25. </view>
  26. <view class="iconfont linge" :class="screeningIndex == 3 && price ? 'activeColors' : ''">&#xe645;
  27. </view>
  28. </view>
  29. </view>
  30. <view class="screen" @click="screening(2)">
  31. <view :class="screeningIndex == 2 ? 'activeColors' : ''">新品</view>
  32. </view>
  33. </view>
  34. </view>
  35. </uv-sticky>
  36. <view class="list">
  37. <view class="item" v-for="(v,i) in list" :key="i" @click="goDetails(v)">
  38. <view class="item_l">
  39. <image :src="v.coverImage" mode="" />
  40. </view>
  41. <view class="item_r">
  42. <view class="item_r_title">
  43. <!-- <view class="tipsStatus">自营</view> -->
  44. <text>{{v.title}}</text>
  45. </view>
  46. <view class="item_r_sold">已售 <text>{{v.showSales}}</text>件 </view>
  47. <view class="item_r_price">
  48. <text v-if="v.productPaymentMode==1" style="font-size:22rpx;">{{v.minPoints}}积分</text>
  49. <rich-text v-else :nodes="mUtil.priceBigSmall(v.salePrice||v.minSalePrice)"></rich-text>
  50. <text class="marketPrice">¥{{ v.marketPrice||v.minMarketPrice }}</text>
  51. </view>
  52. <view class="item_r_comments">
  53. <text>0</text>条评论 评分:
  54. <!-- <text>5.0</text> -->
  55. <text style="margin-left: 2rpx;">{{v.average}}</text>
  56. </view>
  57. <view class="item_r_shop">
  58. {{v.businessName}}
  59. <text class="iconfont" style="font-size: 20rpx;">&#xe6c7;</text>
  60. </view>
  61. </view>
  62. </view>
  63. <noData v-if="list.length<=0" :config="{ top: 20, content: '暂无商品~' }"></noData>
  64. <uv-load-more v-else :status="status" />
  65. </view>
  66. <!--页面加载动画-->
  67. <ldLoading isFullScreen :active="loading"></ldLoading>
  68. </view>
  69. </template>
  70. <script setup>
  71. import { shopProductPage_Api } from "@/api/shop.js"
  72. import ldLoading from '@/components/ld-Loading/ld-loading.vue'
  73. import { ref, getCurrentInstance } from 'vue'
  74. import { onShow, onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
  75. const { proxy } = getCurrentInstance();
  76. const mUtil = proxy.$mUtil;
  77. const screeningIndex = ref(1);
  78. const status = ref('nomore');//loadmore - 加载前,loading - 加载中,nomore - 没有数据
  79. const loading = ref(false);
  80. const list = ref([]);
  81. const params = ref({
  82. pageSize: 10,
  83. pageNum: 1,
  84. orderType: 1, //1是综合(按发布时间),2是新品,3价格,4销量
  85. order_mode: '', //asc 或 desc
  86. orderByColumn: undefined,
  87. isAsc: undefined,
  88. newStatus: undefined,//新品
  89. })
  90. const value = ref("");
  91. const goodsList = ref([]);
  92. const tabTop = ref(0);
  93. const price=ref(false);
  94. onLoad((options) => {
  95. uni.getSystemInfo({
  96. success: (res) => {
  97. tabTop.value = res.statusBarHeight + 44;
  98. },
  99. });
  100. let id = uni.getStorageSync('businessId');
  101. if (id) {
  102. params.value.businessId = id;
  103. }
  104. if (options.keyword) {
  105. params.value.title = options.keyword;
  106. value.value = options.keyword || '';
  107. }
  108. getList();
  109. })
  110. const search = () => {
  111. params.value.title = value.value;
  112. params.value.pageNum = 1;
  113. getList();
  114. }
  115. const goBack = () => {
  116. uni.navigateBack()
  117. }
  118. const goDetails = (item) => {
  119. uni.navigateTo({
  120. url: `/pages/shop/goodsDetails?id=${item.productId}`
  121. });
  122. }
  123. // 下拉刷新
  124. onPullDownRefresh(() => {
  125. params.value.pageNum = 1
  126. getList()
  127. })
  128. // 上拉加载更多
  129. onReachBottom(() => {
  130. if (status.value == 'loadmore') {
  131. params.value.pageNum++
  132. getList()
  133. }
  134. })
  135. const screening = (e) => {
  136. loading.value = true;
  137. params.value.orderType = e;
  138. screeningIndex.value = e;
  139. if (e == 3) {
  140. price.value = !price.value;
  141. if (price.value) {
  142. params.value.orderMode = 'asc';
  143. } else {
  144. params.value.orderMode = 'desc';
  145. }
  146. } else if (e == 4) {
  147. params.value.orderMode = 'desc';
  148. } else {
  149. params.value.orderMode = '';
  150. }
  151. params.value.pageNum=1
  152. getList();
  153. }
  154. const getList = () => {
  155. status.value = 'loading';
  156. loading.value = true;
  157. shopProductPage_Api(params.value).then(res => {
  158. if (params.value.pageNum == 1) {
  159. list.value = res.rows
  160. if (res.rows.length > 0) {
  161. reset(params.value.title)
  162. }
  163. } else {
  164. list.value = [...list.value, ...res.rows]
  165. }
  166. if (list.value.length < res.total) {
  167. status.value = 'loadmore'
  168. } else {
  169. status.value = 'noMore'
  170. }
  171. uni.stopPullDownRefresh();
  172. loading.value = false;
  173. }).catch(e => {
  174. uni.stopPullDownRefresh()
  175. status.value = 'loadmore';
  176. loading.value = false;
  177. })
  178. }
  179. const reset = (text) => {
  180. let recordList = uni.getStorageSync('history') ? uni.getStorageSync('history') : [];
  181. recordList.unshift(text);
  182. let arr = JSON.parse(JSON.stringify(recordList));
  183. let newArr = Array.from(new Set(arr));
  184. recordList = newArr;
  185. uni.setStorageSync('history', JSON.parse(JSON.stringify(recordList)));
  186. }
  187. </script>
  188. <style lang='scss'>
  189. page {
  190. background-color: #f5f5f5;
  191. }
  192. </style>
  193. <style lang='scss' scoped>
  194. ::v-deep.hx-navbar__content__main_search_hxicon {
  195. span {
  196. font-size: 30rpx;
  197. }
  198. }
  199. .zdtopbox {
  200. background-color: #fff;
  201. padding: 8rpx 30rpx 10rpx;
  202. // position: fixed;
  203. // left: 0;
  204. width: 100%;
  205. z-index: 66;
  206. box-sizing: border-box;
  207. }
  208. .search-box {
  209. width: 100%;
  210. display: flex;
  211. .search-wap {
  212. width: 600rpx;
  213. height: 60rpx;
  214. display: flex;
  215. align-items: center;
  216. background: #fff;
  217. border: 1px solid rgba(0, 0, 0, 0.42);
  218. border-radius: 30rpx;
  219. position: relative;
  220. .search-icon {
  221. font-size: 18px;
  222. margin-left: 30rpx;
  223. }
  224. .sput {
  225. margin-left: 25rpx;
  226. font-size: 22rpx;
  227. width: 100%;
  228. }
  229. }
  230. .word {
  231. font-size: 28rpx;
  232. margin-left: 24rpx;
  233. line-height: 60rpx;
  234. }
  235. }
  236. .tabs {
  237. display: flex;
  238. align-items: center;
  239. justify-content: space-around;
  240. margin: 30rpx 0 10rpx;
  241. .screen {
  242. > view {
  243. font-size: 28rpx;
  244. }
  245. }
  246. .sortScreen {
  247. display: flex;
  248. align-items: center;
  249. .linge {
  250. line-height: 14rpx;
  251. font-size: 15rpx;
  252. }
  253. }
  254. .activeColors {
  255. color: #fa6138;
  256. font-weight: bold;
  257. }
  258. }
  259. .list {
  260. padding: 0 30rpx 30rpx;
  261. .item {
  262. padding: 30rpx 20rpx;
  263. background: #ffffff;
  264. border-radius: 10rpx;
  265. display: flex;
  266. margin-top: 20rpx;
  267. .item_l {
  268. image {
  269. width: 226rpx;
  270. height: 226rpx;
  271. border-radius: 8rpx;
  272. overflow: hidden;
  273. margin-right: 20rpx;
  274. }
  275. }
  276. .item_r {
  277. .item_r_title {
  278. overflow: hidden;
  279. text-overflow: ellipsis;
  280. display: -webkit-box;
  281. -webkit-line-clamp: 2;
  282. -webkit-box-orient: vertical;
  283. .tipsStatus {
  284. display: inline-block;
  285. padding: -0 10rpx;
  286. background: #ff0000;
  287. border-radius: 10rpx 0px 10rpx 0px;
  288. line-height: 40rpx;
  289. text-align: center;
  290. margin-right: 10rpx;
  291. color: #fff;
  292. font-size: 20rpx;
  293. }
  294. text {
  295. font-size: 28rpx;
  296. color: #181818;
  297. }
  298. }
  299. .item_r_sold {
  300. font-size: 20rpx;
  301. margin-top: 5rpx;
  302. text {
  303. color: #ff6600;
  304. }
  305. }
  306. .item_r_price {
  307. font-size: 32rpx;
  308. color: #ff6600;
  309. display: flex;
  310. align-items: center;
  311. .marketPrice {
  312. font-size: 22rpx;
  313. color: #999;
  314. margin-left: 20rpx;
  315. text-decoration: line-through;
  316. }
  317. }
  318. .item_r_comments {
  319. font-size: 10px;
  320. color: #999999;
  321. margin-top: 15px;
  322. text {
  323. color: #ff4e15;
  324. }
  325. }
  326. .item_r_shop {
  327. color: #999999;
  328. font-size: 24rpx;
  329. font-weight: 500;
  330. align-items: center;
  331. margin-top: 4rpx;
  332. }
  333. }
  334. }
  335. }
  336. </style>