buyagainList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. <template>
  2. <view class="container commodity-list-wrapper" :style="{'overflow':(showSkeleton? 'hidden' : 'auto'),'height': (showSkeleton? windowHeight + 'px' : 'auto')}">
  3. <list-skeleton v-if="showSkeleton"></list-skeleton>
  4. <view class="good-search clearfix" v-if="searchStatus">
  5. <view class="search-from name">
  6. <text class="iconfont icon-iconfonticonfontsousuo1"></text>
  7. <input class="input" type="text" v-model="searchInputVal" placeholder="请输入商品名称" @input="onShowClose" maxlength="20"/>
  8. <text class="iconfont icon-shanchu1" v-if="isShowClose" @click="delInputText()"></text>
  9. </view>
  10. <view class="search-btn">
  11. <button class="search-btn" type="default" @click.stop="searchOpertor">搜索</button>
  12. </view>
  13. </view>
  14. <view class="product-container" v-if="!isShowEmpty" :style="{paddingTop:searchStatus?'112rpx':''}">
  15. <scroll-view :style="{'height':scrollHeight+'px'}" @scrolltolower="scrolltolower" scroll-y v-if="productList.length > 0">
  16. <view v-for="(item,index) in productList" :key="index" :id="item.id" class="all-type-list-content commodity-list" @click.stop="navToDetailPage(item.productID)">
  17. <image mode='widthFix' :src="item.mainImage" class="list-img" alt="list-img"></image>
  18. <view class="list-details-info">
  19. <text class="list-details-title">{{item.name}}</text>
  20. <text class="list-details-specs">规格:{{item.unit}}</text>
  21. <text class="list-details-miniQuantity">起订量:{{item.minBuyNumber}}</text>
  22. <view class="list-details-price" v-if="item.price1TextFlag == 1">
  23. <view class="list-none">
  24. <view class="price-small">该商品尚未公开价格</view>
  25. <view class="price-small">购买请致电:0755-22907771</view>
  26. </view>
  27. </view>
  28. <view class="list-details-price" v-else>
  29. <view class="list-shop">
  30. <view class="list-price" >
  31. <text class="price-view activity" v-if="item.isShowActFlg">活动价</text>
  32. <text class="price-view ladder" v-if="item.ladderPriceFlag == 1">阶梯价</text>
  33. <text class="price-larger">¥{{item.retailPrice.toFixed(2)}}</text>
  34. </view>
  35. <view class="list-price-none" v-if="item.repurchasePriceState">
  36. <text class="price-none">¥{{item.discountPrice}}</text>
  37. <text class="iconfont icon-wenhao" @click.stop="repurchModel"></text>
  38. </view>
  39. </view>
  40. <button class="add-cart-btn" @click.stop="operationHanld(item)">选择数量</button>
  41. </view>
  42. </view>
  43. </view>
  44. <button class="show-more-btn" v-if="showRegularBtn" @click="getListFromServer(true)">查看更多</button>
  45. <view v-if="showLoading && productList.length > 4 && !showRegularBtn">
  46. <view class="loading-wrapper loading-wrapper-now" v-if="loadingNow">{{loadingText}}<text v-if="loadingText === '已至底部'">‧ ‧ ‧</text></view>
  47. <view class="loading-wrapper loading-wrapper-btm" v-else>———<text class="btm-text">已至底部</text>———</view>
  48. </view>
  49. </scroll-view>
  50. </view>
  51. <view class="empty-container" v-else>
  52. <image class="empty-container-image" src="https://img.caimei365.com/group1/M00/03/71/Cmis2F3wna6AWdWzAAGlgAP0das422.png" mode="aspectFit"></image>
  53. <text class="error-text">您还没有购买过任何商品哟~</text>
  54. <button class="submit-btn toIndexPage" @click="toIndexPage">去逛逛</button>
  55. </view>
  56. <view class="cart-icon" v-if="!isShowEmpty" @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/module/listTemplate/listSkeleton'
  68. import modalLayer from "@/components/modal-layer"
  69. import uniStars from '@/components/uni-stars/uni-stars.vue'
  70. import { queryAgaingoodslist } from "@/api/product.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: true,
  92. isShowEmpty: false,
  93. userID: '',
  94. scrollHeight: '',
  95. productList: [],
  96. showLoading: false,
  97. loadingNow: true,
  98. loadingText: '上拉加载更多',
  99. pageSize: 10,
  100. pageNum: 1,
  101. hasNextPage: false,
  102. pullFlag: true,
  103. fromRegularPurchasePage: false,
  104. cartQuantity: 0,
  105. showRegularBtn: false,
  106. isPrecedence:false
  107. }
  108. },
  109. created() {
  110. this.setScrollHeight();
  111. this.$api.getStorage().then((resolve) =>{
  112. this.userID = resolve.userID
  113. this.getProductAgainInfo()
  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 = {userId:this.userID,pageNum:this.pageNum,pageSize:this.pageSize}
  137. queryAgaingoodslist(params).then(response =>{
  138. this.isShowWrapper = true
  139. this.cartQuantity = response.data.cartQuantity
  140. const responseData = response.data.pageDate;
  141. if(responseData.results && responseData.results.length > 0){
  142. this.hasNextPage = responseData.hasNextPage;
  143. this.isShowEmpty = false;
  144. if(loadMore) {
  145. this.productList = [...this.productList,...responseData.results];
  146. } else {
  147. this.productList = [...responseData.results];
  148. this.showSkeleton = false;
  149. }
  150. //价格显示处理
  151. let isActFlg,newProductList=[];
  152. this.productList.map((item, index)=> {
  153. if(item.actFlag == 1){
  154. isActFlg = true
  155. }else if(item.actFlag == 1 && item.ladderPriceFlag == 1){
  156. isActFlg = true
  157. }else{
  158. isActFlg = false
  159. }
  160. newProductList.push(Object.assign({},item,{isShowActFlg:isActFlg}))
  161. })
  162. this.productList = newProductList
  163. // 防上拉暴滑
  164. this.pullFlag = false;
  165. setTimeout(()=>{
  166. this.pullFlag = true;
  167. },500)
  168. // 底部提示文案
  169. if(this.hasNextPage) {
  170. this.loadingText = '上拉加载更多';
  171. } else {
  172. this.showLoading = true;
  173. this.loadingNow = false;
  174. }
  175. } else {
  176. if(!loadMore) {
  177. this.isShowEmpty = true;
  178. }
  179. }
  180. }).catch(response =>{
  181. this.$util.msg(response.msg,3000);
  182. })
  183. },
  184. operationHanld(prop){
  185. this.$emit('operationConfim',prop)
  186. },
  187. navToDetailPage(id) {
  188. this.isModallayer = true;
  189. this.$api.navigateTo(`/pages/goods/product?id=${id}`);
  190. this.isModallayer = false;
  191. },
  192. toCartPage() {
  193. uni.switchTab({
  194. url: '/pages/tabBar/cart/cart'
  195. })
  196. },
  197. toIndexPage() {
  198. uni.switchTab({
  199. url: '/pages/tabBar/home/home'
  200. })
  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. .empty-container-image {
  225. margin-top: -300rpx;
  226. }
  227. .toIndexPage {
  228. bottom: 390rpx;
  229. }
  230. .show-more-btn {
  231. width: 276rpx;
  232. height: 52rpx;
  233. line-height: 52rpx;
  234. border: 2rpx solid #D8D8D8;
  235. background: #F7F7F7;
  236. font-size: 26rpx;
  237. margin: 26rpx 0;
  238. position: absolute;
  239. left: 50%;
  240. margin-left: -138rpx;
  241. }
  242. }
  243. .good-search{
  244. height: 64rpx;
  245. width: 702rpx;
  246. padding: 24rpx;
  247. background: #FFFFFF;
  248. display: flex;
  249. align-items: center;
  250. margin-bottom: 20rpx;
  251. position: fixed;
  252. top: 0;
  253. left: 0;
  254. z-index: 999;
  255. .search-from{
  256. width: 582rpx;
  257. height: 64rpx;
  258. background: #F7F7F7;
  259. border-radius: 14rpx;
  260. float: left;
  261. position: relative;
  262. .input{
  263. width: 500rpx;
  264. height: 64rpx;
  265. float: left;
  266. line-height: 64rpx;
  267. color: $text-color;
  268. font-size: $font-size-24;
  269. }
  270. .icon-iconfonticonfontsousuo1{
  271. width: 64rpx;
  272. height: 64rpx;
  273. line-height: 64rpx;
  274. text-align: center;
  275. display: block;
  276. font-size: $font-size-38;
  277. float: left;
  278. color: #999999;
  279. }
  280. .icon-shanchu1{
  281. font-size: $font-size-32;
  282. color: #999999;
  283. position: absolute;
  284. width: 64rpx;
  285. height: 64rpx;
  286. line-height: 64rpx;
  287. top: 0;
  288. right: 0;
  289. text-align: center;
  290. z-index: 10;
  291. }
  292. }
  293. .search-btn{
  294. width: 120rpx;
  295. line-height: 64rpx;
  296. text-align: center;
  297. font-size: $font-size-28;
  298. color: $color-system;
  299. float: left;
  300. background: #FFFFFF;
  301. }
  302. }
  303. .all-type-list-content {
  304. height: 240rpx;
  305. padding: 24rpx;
  306. background: #fff;
  307. margin-bottom: 2rpx;
  308. display: flex;
  309. flex-direction: row;
  310. box-sizing: content-box;
  311. .list-img {
  312. width: 240rpx;
  313. height: 240rpx !important;
  314. margin-right: 26rpx;
  315. border-radius: 10rpx;
  316. border: 2rpx solid #f3f3f3;
  317. }
  318. }
  319. .list-details-info {
  320. width: 442rpx;
  321. flex-direction: column;
  322. font-size: 26rpx;
  323. position: relative;
  324. .list-details-title {
  325. line-height: 38rpx;
  326. text-overflow: ellipsis;
  327. overflow: hidden;
  328. display: -webkit-box;
  329. -webkit-line-clamp: 2;
  330. line-clamp: 2;
  331. -webkit-box-orient: vertical;
  332. }
  333. .list-details-specs {
  334. width: 100%;
  335. display: inline-block;
  336. margin-top: 8rpx;
  337. color: #999999;
  338. }
  339. .list-details-miniQuantity {
  340. width: 100%;
  341. display: inline-block;
  342. margin-top: 7rpx;
  343. }
  344. }
  345. .list-details-price {
  346. width: 100%;
  347. display: flex;
  348. flex-direction: row;
  349. justify-content: space-between;
  350. .price-icon {
  351. width: 22rpx;
  352. height: 28rpx;
  353. vertical-align: middle;
  354. margin-right: 10rpx;
  355. }
  356. .price-icon + text {
  357. font-size: 25rpx;
  358. vertical-align: middle;
  359. }
  360. .list-login-now {
  361. width: 375rpx;
  362. color: #F8C499;
  363. position: absolute;
  364. bottom: 0;
  365. .p-no{
  366. float: left;
  367. font-size: $font-size-24;
  368. color: $color-system;
  369. margin-right: 10rpx;
  370. }
  371. }
  372. .login-now {
  373. padding: 10rpx 10rpx 10rpx 0;
  374. }
  375. .list-none{
  376. margin-top: 30rpx;
  377. .price-small{
  378. font-size:$font-size-24;
  379. line-height: 40rpx;
  380. color: #FF2A2A;
  381. }
  382. }
  383. .list-shop{
  384. width: 100%;
  385. height: auto;
  386. flex: 6;
  387. .list-price {
  388. width: 100%;
  389. color: #FF2A2A;
  390. float: left;
  391. line-height:36rpx ;
  392. align-items: center;
  393. justify-content: center;
  394. .price-larger {
  395. margin-top: 20rpx;
  396. font-size: $font-size-30;
  397. display: inline-block;
  398. }
  399. .price-view{
  400. display: inline-block;
  401. width: 78rpx;
  402. border-radius: 18rpx;
  403. font-size: $font-size-20;
  404. text-align: center;
  405. color: #FFFFFF;
  406. height: 36rpx;
  407. line-height: 36rpx;
  408. margin-right: 8rpx;
  409. &.ladder{
  410. background: linear-gradient(135deg,rgba(255,0,0,1) 0%,rgba(242,143,49,1) 100%);
  411. }
  412. &.activity{
  413. background: linear-gradient(135deg,rgba(128,0,255,1) 0%,rgba(242,49,153,1) 100%);
  414. }
  415. }
  416. }
  417. .list-price-none{
  418. width: 100%;
  419. .price-none{
  420. text-decoration: line-through;
  421. color: #999999;
  422. display: inline-block;
  423. }
  424. .icon-wenhao{
  425. font-size: $font-size-32;
  426. color: #0091FF;
  427. margin-left: 6rpx;
  428. }
  429. }
  430. }
  431. .add-cart-btn {
  432. flex: 4;
  433. width: 156rpx;
  434. height: 64rpx;
  435. line-height: 64rpx;
  436. border-radius: 32rpx;
  437. color: #fff;
  438. font-size: 26rpx;
  439. margin-right: 0;
  440. background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  441. }
  442. }
  443. .cart-icon {
  444. width: 92rpx;
  445. height: 92rpx;
  446. border-radius: 50%;
  447. background: rgba(255, 147, 0, 0.5);
  448. position: fixed;
  449. right: 24rpx;
  450. bottom: 30%;
  451. display: flex;
  452. align-items: center;
  453. justify-content: center;
  454. cursor: pointer;
  455. image {
  456. width: 58rpx;
  457. height: 58rpx;
  458. }
  459. text {
  460. font-size: 28rpx;
  461. position: absolute;
  462. top: -10rpx;
  463. right: 0;
  464. }
  465. }
  466. </style>