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