immediatelyList.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  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="nav-tab-bar u-f-ajc">
  5. <block v-for="(tab,index) in tabBars" :key='tab.id'>
  6. <view class="tabstyle u-f-ajc" :class="{'addstyle':tabIndex==index}" @click="changeTab(index)">{{tab.name}}
  7. <i v-if='(tabIndex==index)' class='nav-tab-line'>√</i>
  8. </view>
  9. </block>
  10. </view>
  11. <view class="search-from name">
  12. <text class="iconfont icon-iconfonticonfontsousuo1"></text>
  13. <input class="input"
  14. type="text"
  15. focus
  16. confirm-type="search"
  17. v-model="searchInputVal"
  18. placeholder="请输入商品关键词"
  19. @input="onShowClose"
  20. @confirm="searchOpertor"
  21. maxlength="20"/>
  22. <text class="iconfont icon-shanchu1" v-if="isShowClose" @click="delInputText()"></text>
  23. </view>
  24. <view class="search-btn">
  25. <button class="search-btn" type="default" @click.stop="searchOpertor">搜索</button>
  26. </view>
  27. </view>
  28. <list-skeleton v-if="showSkeleton"></list-skeleton>
  29. <view class="empty-container" v-if="isShowEmpty" >
  30. <image class="empty-container-image" src="https://img.caimei365.com/group1/M00/03/71/Cmis2F3wna6AY2ZjAABpmnBICH4247.png"></image>
  31. <text class="error-text">{{isShowEmptyText}}</text>
  32. </view>
  33. <view class="product-container" v-else :style="{paddingTop:searchStatus?'112rpx':''}" >
  34. <swiper :current="tabIndex" style="height: 1190rpx;">
  35. <swiper-item>
  36. <scroll-view :style="{'height':scrollHeight+'px'}" @scrolltolower="scrolltolower" scroll-y v-if="productList.length > 0">
  37. <view v-for="(item,index) in productList" :key="index" :id="item.id" class="all-type-list-content commodity-list" @click.stop="navToDetailPage(item.productID)">
  38. <image mode='widthFix' :src="item.mainImage" class="list-img" alt="list-img"></image>
  39. <view class="list-details-info">
  40. <text class="list-details-title">{{item.name}}</text>
  41. <text class="list-details-specs">规格:{{item.unit?item.unit:''}}</text>
  42. <text class="list-details-miniQuantity">起订量:{{item.minBuyNumber}}</text>
  43. <view class="list-details-price">
  44. <view class="list-shop">
  45. <view class="list-price" >
  46. <text class="price-view activity" v-if="item.isShowActFlg">活动价</text>
  47. <text class="price-larger">¥{{item.retailPrice.toFixed(2)}}</text>
  48. <text class="price-view ladder" v-if="item.ladderPriceFlag == '1'">阶</text>
  49. </view>
  50. <view class="list-price-none" v-if="item.repurchasePriceState">
  51. <text class="price-none">¥{{item.discountPrice}}</text>
  52. <text class="iconfont icon-wenhao" @click.stop="repurchModel"></text>
  53. </view>
  54. </view>
  55. <button class="add-cart-btn" @click.stop="operationHanld(item)">选择数量</button>
  56. </view>
  57. </view>
  58. </view>
  59. <view v-if="showLoading && productList.length > 4 && !showRegularBtn">
  60. <view class="loading-wrapper loading-wrapper-now" v-if="loadingNow">{{loadingText}}<text v-if="loadingText === '已至底部'">‧ ‧ ‧</text></view>
  61. <view class="loading-wrapper loading-wrapper-btm" v-else>———<text class="btm-text">已至底部</text>———</view>
  62. </view>
  63. </scroll-view>
  64. </swiper-item>
  65. <!-- 组合商品list -->
  66. <swiper-item>
  67. <scroll-view :style="{'height':scrollHeight+'px'}" @scrolltolower="scrolltolower" scroll-y>
  68. <view class="zuhe_title">组合组合组合组合组合</view>
  69. <view v-for="(item,index) in productList" :key="index" :id="item.id" class="zuhe-list-content commodity-list" @click.stop="navToDetailPage(item.productID)">
  70. <view class="list-details-info">
  71. <text class="list-details-title zuhe_list_text">商品编码:{{item.name}}</text>
  72. <text class="list-details-specs zuhe_list_text">{{item.name}}</text>
  73. <view class="list-details-price zuhe_list_price">
  74. <view class="list-shop">
  75. <view class="list-price zuhe_list_price" >
  76. <text class="zuhe_price-larger zuhe_list_text" >价格:¥{{item.retailPrice.toFixed(2)}}</text>
  77. <text class="price-two zuhe_list_text">总价:<text class="zuhe_list_zj">¥ 12451.00</text></text>
  78. <text class="price-view ladder" v-if="item.ladderPriceFlag == '1'">阶</text>
  79. <text class="price-view activity" v-if="item.isShowActFlg">活动价</text>
  80. </view>
  81. <view class="list-price-none" v-if="item.repurchasePriceState">
  82. <!-- -->
  83. <text class="price-none">价格:¥{{item.discountPrice}}</text>
  84. <text class="price-two">总价:<span>¥12401.00</span></text>
  85. <text class="iconfont icon-wenhao" @click.stop="repurchModel"></text>
  86. </view>
  87. </view>
  88. <button class="add-cart-btn zuhe_btn" @click.stop="operationHanld(item)">选择数量</button>
  89. </view>
  90. </view>
  91. </view>
  92. <view class="foot_conten" >
  93. <view class="zuhe_foot-box">
  94. <text>种类:10</text>
  95. <text>总数:12450</text>
  96. <text>总额:1215421</text>
  97. </view>
  98. <button type="default" class="buycart" @click.stop="operationHanld(item)">加入购物车</button>
  99. </view>
  100. </scroll-view>
  101. </swiper-item>
  102. </swiper>
  103. </view>
  104. <view class="cart-icon" @click="toCartPage">
  105. <text v-if="cartQuantity > 0" class="uni-badge uni-badge-error uni-small uni-badge--small icon-num">
  106. {{cartQuantity >= 100 ? '99+' : cartQuantity}}
  107. </text>
  108. <image src='../../../static/icon-cart-active@3x.png' mode="widthFix"></image>
  109. </view>
  110. <!-- 透明模态层 -->
  111. <modal-layer v-if='isModallayer'></modal-layer>
  112. </view>
  113. </template>
  114. <script>
  115. import listSkeleton from '@/components/cm-module/listTemplate/listSkeleton'
  116. import modalLayer from "@/components/modal-layer"
  117. import uniStars from '@/components/uni-stars/uni-stars.vue'
  118. import { getSellerProduct } from "@/api/seller.js"
  119. import { mapState,mapMutations } from 'vuex';
  120. export default{
  121. name:'productList',
  122. components:{
  123. listSkeleton,
  124. modalLayer,
  125. uniStars
  126. },
  127. props: {
  128. searchStatus:{
  129. type:Boolean,
  130. default:false
  131. }
  132. },
  133. data(){
  134. return{
  135. isShowClose:false,
  136. searchInputVal:'',
  137. isModallayer:false,
  138. windowHeight: '',
  139. showSkeleton: false,
  140. isShowEmpty: false,
  141. isShowEmptyText: '搜索相关商品',
  142. clubUserId: '',
  143. scrollHeight: '',
  144. productList: [],
  145. showLoading: false,
  146. loadingNow: true,
  147. loadingText: '上拉加载更多',
  148. pageSize: 10,
  149. pageNum: 1,
  150. hasNextPage: false,
  151. pullFlag: true,
  152. fromRegularPurchasePage: false,
  153. cartQuantity: 0,
  154. showRegularBtn: false,
  155. isPrecedence:false,
  156. tabIndex:0,
  157. tabBars:[
  158. {name:'单一商品',id:'danyi'},
  159. {name:'组合商品',id:'zuhe'}
  160. ]
  161. }
  162. },
  163. created() {
  164. this.setScrollHeight();
  165. this.$api.getComStorage('orderUserInfo').then((resolve) =>{
  166. this.clubUserId = resolve.userID
  167. })
  168. },
  169. computed: {
  170. ...mapState(['hasLogin','userInfo'])
  171. },
  172. methods:{
  173. scrolltolower() {
  174. if(this.hasNextPage && this.pullFlag) {
  175. this.getProductAgainInfo(true);
  176. }
  177. },
  178. changeTab(index){
  179. this.tabIndex = index;
  180. },
  181. setScrollHeight() {
  182. const {windowHeight, pixelRatio} = wx.getSystemInfoSync();
  183. this.windowHeight = windowHeight - 1;
  184. this.scrollHeight = windowHeight - 1;
  185. },
  186. getProductAgainInfo(loadMore) {
  187. this.showLoading = true;
  188. this.loadingNow = true;
  189. this.loadingText = '加载中';
  190. this.isShowEmpty = false;
  191. if(loadMore) {this.pageNum += 1;}
  192. let params = {clubUserId:this.clubUserId,pageNum:this.pageNum,pageSize:this.pageSize,searchWord:this.searchInputVal}
  193. getSellerProduct(params).then(response =>{
  194. this.isShowWrapper = true
  195. const responseData = response.data;
  196. if(responseData.results && responseData.results.length > 0){
  197. this.hasNextPage = responseData.hasNextPage;
  198. this.isShowEmpty = false;
  199. if(loadMore) {
  200. this.productList = [...this.productList,...responseData.results];
  201. } else {
  202. this.productList = [...responseData.results];
  203. this.showSkeleton = false;
  204. }
  205. //价格显示处理
  206. let isActFlg,newProductList=[];
  207. this.productList.map((item, index)=> {
  208. if(item.actStatus == 1){
  209. isActFlg = true
  210. }else if(item.actStatus == 1 && item.ladderPriceFlag == '1'){
  211. isActFlg = true
  212. }else{
  213. isActFlg = false
  214. }
  215. newProductList.push(Object.assign({},item,{isShowActFlg:isActFlg}))
  216. })
  217. this.productList = newProductList
  218. // 防上拉暴滑
  219. this.pullFlag = false;
  220. setTimeout(()=>{
  221. this.pullFlag = true;
  222. },500)
  223. // 底部提示文案
  224. if(this.hasNextPage) {
  225. this.loadingText = '上拉加载更多';
  226. } else {
  227. this.showLoading = true;
  228. this.loadingNow = false;
  229. }
  230. } else {
  231. this.isShowEmpty = true;
  232. this.isShowEmptyText ='暂无相关商品'
  233. }
  234. }).catch(error =>{
  235. this.$util.msg(error.msg,2000);
  236. })
  237. },
  238. searchOpertor(){//搜索商品
  239. if(this.searchInputVal == ''){
  240. this.$util.msg('请输入商品关键词',2000)
  241. }else{
  242. this.pageNum = 1
  243. this.showSkeleton = true;
  244. this.getProductAgainInfo();
  245. }
  246. },
  247. operationHanld(prop){
  248. this.$emit('operationConfim',prop)
  249. },
  250. navToDetailPage(id) {
  251. this.isModallayer = true;
  252. this.$api.navigateTo(`/pages/goods/product?id=${id}`);
  253. this.isModallayer = false;
  254. },
  255. toCartPage() {
  256. this.$emit('goCartPage')
  257. },
  258. repurchModel(){
  259. this.$util.modal('','此商品的价格有变化,原来的购买价已不适用','知道了','',false,() =>{})
  260. },
  261. onShowClose () {//输入框失去焦点时触发
  262. if(this.searchInputVal != ''){
  263. this.isShowClose = true
  264. }else{
  265. this.isShowClose = false
  266. }
  267. },
  268. delInputText(){//清除输入框内容
  269. this.searchInputVal = ''
  270. this.isShowClose = false
  271. }
  272. }
  273. }
  274. </script>
  275. <style lang="scss">
  276. .foot_conten{
  277. width: 100%;
  278. position: fixed;
  279. left:0px;
  280. bottom:100rpx;
  281. z-index: 9999;
  282. background: #fff;
  283. font-size: 28rpx;
  284. text-align: center;
  285. height: 120rpx;
  286. line-height: 120rpx;
  287. display: inline-block;
  288. }
  289. .zuhe_foot-box{
  290. width: 70%;
  291. float: left;
  292. }
  293. .zuhe_foot-box text{
  294. margin-right: 30rpx;
  295. }
  296. .foot_conten .buycart{
  297. width: 162rpx;
  298. height: 64rpx;
  299. background: #EFAF00 !important;
  300. color: #fff;
  301. font-size: 28rpx;
  302. border-radius: 36rpx;
  303. text-align: center;
  304. line-height: 64rpx;
  305. margin-top: 25rpx
  306. }
  307. .price-none{
  308. font-size: 24rpx;
  309. color: #666666;
  310. }
  311. .zuhe_title{
  312. background:#FFFFFF;
  313. height: 76rpx;
  314. color: #E15616;
  315. font-size: 28rpx;
  316. border-bottom: 2rpx solid #E15616;
  317. line-height: 76rpx;
  318. padding-left: 30rpx;;
  319. }
  320. .nav-tab-line{
  321. color: #E15616;
  322. position: absolute;
  323. top: 20rpx;
  324. right: 4rpx;
  325. font-weight: bold
  326. }
  327. .addstyle{
  328. background: linear-gradient(-42deg, transparent 28rpx, #E15616 0) top right;
  329. color: #FFFFFF;
  330. }
  331. .tabstyle{
  332. width: 128rpx;
  333. height: 64rpx;
  334. font-size: 26rpx;
  335. display: inline-block;
  336. border-radius: 10rpx;
  337. text-align: center;
  338. line-height: 64rpx;
  339. border: 2rpx solid #EEEEEE;
  340. position: relative;
  341. margin-right: 12rpx;
  342. }
  343. .commodity-list-wrapper {
  344. scroll-view {
  345. height: 100%;
  346. }
  347. .show-more-btn {
  348. width: 276rpx;
  349. height: 52rpx;
  350. line-height: 52rpx;
  351. border: 2rpx solid #D8D8D8;
  352. background: #F7F7F7;
  353. font-size: 26rpx;
  354. margin: 26rpx 0;
  355. position: absolute;
  356. left: 50%;
  357. margin-left: -138rpx;
  358. }
  359. }
  360. .good-search{
  361. height: 64rpx;
  362. width: 702rpx;
  363. padding: 24rpx;
  364. background: #FFFFFF;
  365. display: flex;
  366. align-items: center;
  367. margin-bottom: 20rpx;
  368. position: fixed;
  369. top: 0;
  370. left: 0;
  371. z-index: 999;
  372. .search-from{
  373. width: 326rpx;
  374. height: 64rpx;
  375. background: #F7F7F7;
  376. border-radius: 14rpx;
  377. float: left;
  378. position: relative;
  379. .input{
  380. // width: 500rpx;
  381. height: 64rpx;
  382. float: left;
  383. line-height: 64rpx;
  384. color: $text-color;
  385. font-size: $font-size-24;
  386. }
  387. .icon-iconfonticonfontsousuo1{
  388. width: 64rpx;
  389. height: 64rpx;
  390. line-height: 64rpx;
  391. text-align: center;
  392. display: block;
  393. font-size: $font-size-38;
  394. float: left;
  395. color: #999999;
  396. }
  397. .icon-shanchu1{
  398. font-size: $font-size-32;
  399. color: #999999;
  400. position: absolute;
  401. width: 64rpx;
  402. height: 64rpx;
  403. line-height: 64rpx;
  404. top: 0;
  405. right: 0;
  406. text-align: center;
  407. z-index: 10;
  408. }
  409. }
  410. .search-btn{
  411. // width: 120rpx;
  412. line-height: 64rpx;
  413. text-align: center;
  414. font-size: $font-size-28;
  415. color: $color-system;
  416. float: left;
  417. background: #FFFFFF;
  418. margin-left: 10rpx;
  419. }
  420. }
  421. .all-type-list-content {
  422. height: 240rpx;
  423. padding: 24rpx;
  424. background: #fff;
  425. margin-bottom: 2rpx;
  426. display: flex;
  427. flex-direction: row;
  428. box-sizing: content-box;
  429. .list-img {
  430. width: 240rpx;
  431. height: 240rpx !important;
  432. margin-right: 26rpx;
  433. border-radius: 10rpx;
  434. border: 2rpx solid #f3f3f3;
  435. }
  436. }
  437. .zuhe-list-content{
  438. width: 655rpx;
  439. // height: 214rpx;
  440. background: #fff;
  441. border: 2px solid #FFF0DE;
  442. display: flex;
  443. flex-direction: row;
  444. box-sizing: content-box;
  445. margin-top: 10rpx;
  446. border-radius: 14rpx;
  447. margin: 10rpx auto;
  448. padding: 20rpx;
  449. }
  450. .list-details-info {
  451. width: 100%;
  452. flex-direction: column;
  453. font-size: 26rpx;
  454. position: relative;
  455. .list-details-title {
  456. line-height: 38rpx;
  457. text-overflow: ellipsis;
  458. overflow: hidden;
  459. display: -webkit-box;
  460. -webkit-line-clamp: 2;
  461. line-clamp: 2;
  462. -webkit-box-orient: vertical;
  463. }
  464. .list-details-specs {
  465. width: 100%;
  466. display: inline-block;
  467. margin-top: 8rpx;
  468. color: #999999;
  469. }
  470. .list-details-miniQuantity {
  471. width: 100%;
  472. display: inline-block;
  473. margin-top: 7rpx;
  474. }
  475. }
  476. .list-details-price {
  477. width: 100%;
  478. display: flex;
  479. flex-direction: row;
  480. justify-content: space-between;
  481. .price-icon {
  482. width: 22rpx;
  483. height: 28rpx;
  484. vertical-align: middle;
  485. margin-right: 10rpx;
  486. }
  487. .price-icon + text {
  488. font-size: 25rpx;
  489. vertical-align: middle;
  490. }
  491. .list-login-now {
  492. width: 375rpx;
  493. color: #F8C499;
  494. position: absolute;
  495. bottom: 0;
  496. .p-no{
  497. float: left;
  498. font-size: $font-size-24;
  499. color: $color-system;
  500. margin-right: 10rpx;
  501. }
  502. }
  503. .login-now {
  504. padding: 10rpx 10rpx 10rpx 0;
  505. }
  506. .list-none{
  507. margin-top: 15rpx;
  508. .price-small{
  509. font-size:$font-size-24;
  510. line-height: 40rpx;
  511. color: #FF2A2A;
  512. }
  513. }
  514. .list-shop{
  515. width: 100%;
  516. height: auto;
  517. flex: 6;
  518. .list-price {
  519. width: 100%;
  520. color: #FF2A2A;
  521. float: left;
  522. line-height:36rpx ;
  523. align-items: center;
  524. justify-content: center;
  525. .price-larger {
  526. margin-top: 20rpx;
  527. font-size: $font-size-30;
  528. display: inline-block;
  529. }
  530. .zuhe_price-larger{
  531. color: #666666;
  532. float: left;
  533. }
  534. .price-two{
  535. color: #666666;
  536. float: left;
  537. margin-left: 25rpx;
  538. }
  539. .zuhe_list_zj{
  540. color: #FF2A2A;
  541. }
  542. .price-view{
  543. display: inline-block;
  544. width: 40rpx;
  545. border-radius: 10rpx;
  546. font-size: $font-size-24;
  547. text-align: center;
  548. color: #FFFFFF;
  549. height: 36rpx;
  550. line-height: 36rpx;
  551. margin-right: 8rpx;
  552. &.ladder{
  553. background: linear-gradient(135deg,rgba(255,0,0,1) 0%,rgba(242,143,49,1) 100%);
  554. }
  555. &.activity{
  556. background: linear-gradient(135deg,rgba(128,0,255,1) 0%,rgba(242,49,153,1) 100%);
  557. }
  558. }
  559. }
  560. .zuhe_list_price .price-view{
  561. margin-top: 20rpx;
  562. float: right;
  563. margin-right: 0;
  564. }
  565. .zuhe_list_price{
  566. width: 70%;
  567. }
  568. .list-price-none{
  569. width: 100%;
  570. .price-none{
  571. text-decoration: line-through;
  572. color: #999999;
  573. display: inline-block;
  574. }
  575. .icon-wenhao{
  576. font-size: $font-size-32;
  577. color: #0091FF;
  578. margin-left: 6rpx;
  579. }
  580. }
  581. }
  582. .add-cart-btn {
  583. flex: 4;
  584. width: 156rpx;
  585. height: 64rpx;
  586. line-height: 64rpx;
  587. border-radius: 32rpx;
  588. color: #333333;
  589. font-size: 26rpx;
  590. margin-right: 0;
  591. // background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  592. background: #FFFFFF;
  593. border: 2rpx solid #C9C9C9;
  594. }
  595. .zuhe_btn{
  596. float: right;
  597. }
  598. }
  599. .zuhe_list_price{
  600. display: block !important;
  601. }
  602. .cart-icon {
  603. width: 92rpx;
  604. height: 92rpx;
  605. border-radius: 50%;
  606. background: rgba(255, 147, 0, 0.5);
  607. position: fixed;
  608. right: 24rpx;
  609. bottom: 37%;
  610. display: flex;
  611. align-items: center;
  612. justify-content: center;
  613. cursor: pointer;
  614. image {
  615. width: 58rpx;
  616. height: 58rpx;
  617. }
  618. text {
  619. font-size: 28rpx;
  620. position: absolute;
  621. top: -10rpx;
  622. right: 0;
  623. }
  624. }
  625. .zuhe_list_text{
  626. margin-top: 20rpx;
  627. }
  628. </style>