buyagainList.vue 11 KB

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