immediatelyList.vue 12 KB

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