immediatelyList.vue 12 KB

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