immediatelyList.vue 12 KB

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