immediatelyList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. <template>
  2. <view class="container commodity-list-wrapper" :style="{'overflow':(showSkeleton? 'hidden' : 'auto'),'height': (showSkeleton? windowHeight + 'px' : 'auto')}">
  3. <view class="good-search clearfix" v-if="searchStatus">
  4. <view class="search-from name">
  5. <text class="iconfont icon-iconfonticonfontsousuo1"></text>
  6. <input class="input" type="text" v-model="searchInputVal" placeholder="请输入商品关键词" @input="onShowClose" maxlength="20"/>
  7. <text class="iconfont icon-shanchu1" v-if="isShowClose" @click="delInputText()"></text>
  8. </view>
  9. <view class="search-btn">
  10. <button class="search-btn" type="default" @click.stop="searchOpertor">搜索</button>
  11. </view>
  12. </view>
  13. <list-skeleton v-if="showSkeleton"></list-skeleton>
  14. <view class="empty-container" v-if="isShowEmpty" >
  15. <image class="empty-container-image" src="https://img.caimei365.com/group1/M00/03/71/Cmis2F3wna6AY2ZjAABpmnBICH4247.png"></image>
  16. <text class="error-text">{{isShowEmptyText}}</text>
  17. </view>
  18. <view class="product-container" v-else :style="{paddingTop:searchStatus?'112rpx':''}">
  19. <scroll-view :style="{'height':scrollHeight+'px'}" @scrolltolower="scrolltolower" scroll-y v-if="productList.length > 0">
  20. <view v-for="(item,index) in productList" :key="index" :id="item.id" class="all-type-list-content commodity-list" @click.stop="navToDetailPage(item.productID)">
  21. <image mode='widthFix' :src="item.mainImage" class="list-img" alt="list-img"></image>
  22. <view class="list-details-info">
  23. <text class="list-details-title">{{item.name}}</text>
  24. <text class="list-details-specs">规格:{{item.unit?item.unit:''}}</text>
  25. <text class="list-details-miniQuantity">起订量:{{item.minBuyNumber}}</text>
  26. <view class="list-details-price" v-if="item.price1TextFlag == 1">
  27. <view class="list-none">
  28. <view class="price-small">未公开价格</view>
  29. </view>
  30. </view>
  31. <view class="list-details-price" v-else>
  32. <view class="list-shop">
  33. <view class="list-price" >
  34. <text class="price-view activity" v-if="item.isShowActFlg">活动价</text>
  35. <text class="price-view ladder" v-if="item.ladderPriceFlag == '1'">阶梯价</text>
  36. <text class="price-larger">¥{{item.retailPrice.toFixed(2)}}</text>
  37. </view>
  38. <view class="list-price-none" v-if="item.repurchasePriceState">
  39. <text class="price-none">¥{{item.discountPrice}}</text>
  40. <text class="iconfont icon-wenhao" @click.stop="repurchModel"></text>
  41. </view>
  42. </view>
  43. <button class="add-cart-btn" @click.stop="operationHanld(item)">选择数量</button>
  44. </view>
  45. </view>
  46. </view>
  47. <view v-if="showLoading && productList.length > 4 && !showRegularBtn">
  48. <view class="loading-wrapper loading-wrapper-now" v-if="loadingNow">{{loadingText}}<text v-if="loadingText === '已至底部'">‧ ‧ ‧</text></view>
  49. <view class="loading-wrapper loading-wrapper-btm" v-else>———<text class="btm-text">已至底部</text>———</view>
  50. </view>
  51. </scroll-view>
  52. </view>
  53. <view class="cart-icon" @click="toCartPage">
  54. <text v-if="cartQuantity > 0" class="uni-badge uni-badge-error uni-small uni-badge--small icon-num">
  55. {{cartQuantity >= 100 ? '99+' : cartQuantity}}
  56. </text>
  57. <image src='../../../static/icon-cart-active@3x.png' mode="widthFix"></image>
  58. </view>
  59. <!-- 透明模态层 -->
  60. <modal-layer v-if='isModallayer'></modal-layer>
  61. </view>
  62. </template>
  63. <script>
  64. import listSkeleton from '@/components/module/listTemplate/listSkeleton'
  65. import modalLayer from "@/components/modal-layer"
  66. import uniStars from '@/components/uni-stars/uni-stars.vue'
  67. import { getSellerProduct } from "@/api/seller.js"
  68. import { mapState,mapMutations } from 'vuex';
  69. export default{
  70. name:'productList',
  71. components:{
  72. listSkeleton,
  73. modalLayer,
  74. uniStars
  75. },
  76. props: {
  77. searchStatus:{
  78. type:Boolean,
  79. default:false
  80. }
  81. },
  82. data(){
  83. return{
  84. isShowClose:false,
  85. searchInputVal:'',
  86. isModallayer:false,
  87. windowHeight: '',
  88. showSkeleton: false,
  89. isShowEmpty: true,
  90. isShowEmptyText: '搜索相关商品',
  91. clubUserId: '',
  92. scrollHeight: '',
  93. productList: [],
  94. showLoading: false,
  95. loadingNow: true,
  96. loadingText: '上拉加载更多',
  97. pageSize: 10,
  98. pageNum: 1,
  99. hasNextPage: false,
  100. pullFlag: true,
  101. fromRegularPurchasePage: false,
  102. cartQuantity: 0,
  103. showRegularBtn: false,
  104. isPrecedence:false,
  105. }
  106. },
  107. created() {
  108. this.setScrollHeight();
  109. this.$api.getComStorage('orderUserInfo').then((resolve) =>{
  110. this.clubUserId = resolve.userID
  111. })
  112. },
  113. computed: {
  114. ...mapState(['hasLogin','userInfo'])
  115. },
  116. methods:{
  117. scrolltolower() {
  118. if(this.hasNextPage && this.pullFlag) {
  119. this.getProductAgainInfo(true);
  120. }
  121. },
  122. setScrollHeight() {
  123. const {windowHeight, pixelRatio} = wx.getSystemInfoSync();
  124. this.windowHeight = windowHeight - 1;
  125. this.scrollHeight = windowHeight - 1;
  126. },
  127. getProductAgainInfo(loadMore) {
  128. this.showLoading = true;
  129. this.loadingNow = true;
  130. this.loadingText = '加载中';
  131. this.isShowEmpty = false;
  132. if(loadMore) {this.pageNum += 1;}
  133. let params = {clubUserId:this.clubUserId,pageNum:this.pageNum,pageSize:this.pageSize,searchWord:this.searchInputVal}
  134. getSellerProduct(params).then(response =>{
  135. this.isShowWrapper = true
  136. const responseData = response.data;
  137. if(responseData.results && responseData.results.length > 0){
  138. this.hasNextPage = responseData.hasNextPage;
  139. this.isShowEmpty = false;
  140. if(loadMore) {
  141. this.productList = [...this.productList,...responseData.results];
  142. } else {
  143. this.productList = [...responseData.results];
  144. this.showSkeleton = false;
  145. }
  146. //价格显示处理
  147. let isActFlg,newProductList=[];
  148. this.productList.map((item, index)=> {
  149. if(item.actStatus == 1){
  150. isActFlg = true
  151. }else if(item.actStatus == 1 && item.ladderPriceFlag == '1'){
  152. isActFlg = true
  153. }else{
  154. isActFlg = false
  155. }
  156. newProductList.push(Object.assign({},item,{isShowActFlg:isActFlg}))
  157. })
  158. this.productList = newProductList
  159. // 防上拉暴滑
  160. this.pullFlag = false;
  161. setTimeout(()=>{
  162. this.pullFlag = true;
  163. },500)
  164. // 底部提示文案
  165. if(this.hasNextPage) {
  166. this.loadingText = '上拉加载更多';
  167. } else {
  168. this.showLoading = true;
  169. this.loadingNow = false;
  170. }
  171. } else {
  172. this.isShowEmpty = true;
  173. this.isShowEmptyText ='暂无相关商品'
  174. }
  175. }).catch(response =>{
  176. this.$util.msg(response.msg,3000);
  177. })
  178. },
  179. searchOpertor(){//搜索商品
  180. if(this.searchInputVal == ''){
  181. this.$util.msg('请输入商品关键词',3000)
  182. return
  183. }
  184. this.pageNum = 1
  185. this.showSkeleton = true;
  186. this.getProductAgainInfo();
  187. },
  188. operationHanld(prop){
  189. this.$emit('operationConfim',prop)
  190. },
  191. navToDetailPage(id) {
  192. this.isModallayer = true;
  193. this.$api.navigateTo(`/pages/goods/product?id=${id}`);
  194. this.isModallayer = false;
  195. },
  196. toCartPage() {
  197. this.$emit('goCartPage')
  198. },
  199. repurchModel(){
  200. this.$util.modal('','此商品的价格有变化,原来的购买价已不适用','知道了','',false,() =>{})
  201. },
  202. onShowClose () {//输入框失去焦点时触发
  203. if(this.searchInputVal != ''){
  204. this.isShowClose = true
  205. }else{
  206. this.isShowClose = false
  207. }
  208. },
  209. delInputText(){//清除输入框内容
  210. this.searchInputVal = ''
  211. this.isShowClose = false
  212. }
  213. }
  214. }
  215. </script>
  216. <style lang="scss">
  217. .commodity-list-wrapper {
  218. scroll-view {
  219. height: 100%;
  220. }
  221. .show-more-btn {
  222. width: 276rpx;
  223. height: 52rpx;
  224. line-height: 52rpx;
  225. border: 2rpx solid #D8D8D8;
  226. background: #F7F7F7;
  227. font-size: 26rpx;
  228. margin: 26rpx 0;
  229. position: absolute;
  230. left: 50%;
  231. margin-left: -138rpx;
  232. }
  233. }
  234. .good-search{
  235. height: 64rpx;
  236. width: 702rpx;
  237. padding: 24rpx;
  238. background: #FFFFFF;
  239. display: flex;
  240. align-items: center;
  241. margin-bottom: 20rpx;
  242. position: fixed;
  243. top: 0;
  244. left: 0;
  245. z-index: 999;
  246. .search-from{
  247. width: 582rpx;
  248. height: 64rpx;
  249. background: #F7F7F7;
  250. border-radius: 14rpx;
  251. float: left;
  252. position: relative;
  253. .input{
  254. width: 500rpx;
  255. height: 64rpx;
  256. float: left;
  257. line-height: 64rpx;
  258. color: $text-color;
  259. font-size: $font-size-24;
  260. }
  261. .icon-iconfonticonfontsousuo1{
  262. width: 64rpx;
  263. height: 64rpx;
  264. line-height: 64rpx;
  265. text-align: center;
  266. display: block;
  267. font-size: $font-size-38;
  268. float: left;
  269. color: #999999;
  270. }
  271. .icon-shanchu1{
  272. font-size: $font-size-32;
  273. color: #999999;
  274. position: absolute;
  275. width: 64rpx;
  276. height: 64rpx;
  277. line-height: 64rpx;
  278. top: 0;
  279. right: 0;
  280. text-align: center;
  281. z-index: 10;
  282. }
  283. }
  284. .search-btn{
  285. width: 120rpx;
  286. line-height: 64rpx;
  287. text-align: center;
  288. font-size: $font-size-28;
  289. color: $color-system;
  290. float: left;
  291. background: #FFFFFF;
  292. }
  293. }
  294. .all-type-list-content {
  295. height: 240rpx;
  296. padding: 24rpx;
  297. background: #fff;
  298. margin-bottom: 2rpx;
  299. display: flex;
  300. flex-direction: row;
  301. box-sizing: content-box;
  302. .list-img {
  303. width: 240rpx;
  304. height: 240rpx !important;
  305. margin-right: 26rpx;
  306. border-radius: 10rpx;
  307. border: 2rpx solid #f3f3f3;
  308. }
  309. }
  310. .list-details-info {
  311. width: 442rpx;
  312. flex-direction: column;
  313. font-size: 26rpx;
  314. position: relative;
  315. .list-details-title {
  316. line-height: 38rpx;
  317. text-overflow: ellipsis;
  318. overflow: hidden;
  319. display: -webkit-box;
  320. -webkit-line-clamp: 2;
  321. line-clamp: 2;
  322. -webkit-box-orient: vertical;
  323. }
  324. .list-details-specs {
  325. width: 100%;
  326. display: inline-block;
  327. margin-top: 8rpx;
  328. color: #999999;
  329. }
  330. .list-details-miniQuantity {
  331. width: 100%;
  332. display: inline-block;
  333. margin-top: 7rpx;
  334. }
  335. }
  336. .list-details-price {
  337. width: 100%;
  338. display: flex;
  339. flex-direction: row;
  340. justify-content: space-between;
  341. .price-icon {
  342. width: 22rpx;
  343. height: 28rpx;
  344. vertical-align: middle;
  345. margin-right: 10rpx;
  346. }
  347. .price-icon + text {
  348. font-size: 25rpx;
  349. vertical-align: middle;
  350. }
  351. .list-login-now {
  352. width: 375rpx;
  353. color: #F8C499;
  354. position: absolute;
  355. bottom: 0;
  356. .p-no{
  357. float: left;
  358. font-size: $font-size-24;
  359. color: $color-system;
  360. margin-right: 10rpx;
  361. }
  362. }
  363. .login-now {
  364. padding: 10rpx 10rpx 10rpx 0;
  365. }
  366. .list-none{
  367. margin-top: 15rpx;
  368. .price-small{
  369. font-size:$font-size-24;
  370. line-height: 40rpx;
  371. color: #FF2A2A;
  372. }
  373. }
  374. .list-shop{
  375. width: 100%;
  376. height: auto;
  377. flex: 6;
  378. .list-price {
  379. width: 100%;
  380. color: #FF2A2A;
  381. float: left;
  382. line-height:36rpx ;
  383. align-items: center;
  384. justify-content: center;
  385. .price-larger {
  386. margin-top: 20rpx;
  387. font-size: $font-size-30;
  388. display: inline-block;
  389. }
  390. .price-view{
  391. display: inline-block;
  392. width: 78rpx;
  393. border-radius: 18rpx;
  394. font-size: $font-size-20;
  395. text-align: center;
  396. color: #FFFFFF;
  397. height: 36rpx;
  398. line-height: 36rpx;
  399. margin-right: 8rpx;
  400. &.ladder{
  401. background: linear-gradient(135deg,rgba(255,0,0,1) 0%,rgba(242,143,49,1) 100%);
  402. }
  403. &.activity{
  404. background: linear-gradient(135deg,rgba(128,0,255,1) 0%,rgba(242,49,153,1) 100%);
  405. }
  406. }
  407. }
  408. .list-price-none{
  409. width: 100%;
  410. .price-none{
  411. text-decoration: line-through;
  412. color: #999999;
  413. display: inline-block;
  414. }
  415. .icon-wenhao{
  416. font-size: $font-size-32;
  417. color: #0091FF;
  418. margin-left: 6rpx;
  419. }
  420. }
  421. }
  422. .add-cart-btn {
  423. flex: 4;
  424. width: 156rpx;
  425. height: 64rpx;
  426. line-height: 64rpx;
  427. border-radius: 32rpx;
  428. color: #fff;
  429. font-size: 26rpx;
  430. margin-right: 0;
  431. background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  432. }
  433. }
  434. .cart-icon {
  435. width: 92rpx;
  436. height: 92rpx;
  437. border-radius: 50%;
  438. background: rgba(255, 147, 0, 0.5);
  439. position: fixed;
  440. right: 24rpx;
  441. bottom: 37%;
  442. display: flex;
  443. align-items: center;
  444. justify-content: center;
  445. cursor: pointer;
  446. image {
  447. width: 58rpx;
  448. height: 58rpx;
  449. }
  450. text {
  451. font-size: 28rpx;
  452. position: absolute;
  453. top: -10rpx;
  454. right: 0;
  455. }
  456. }
  457. </style>