buyagainList.vue 11 KB

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