buyagainList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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.productId" 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.originalPrice}}</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.originalPrice : item.price) | 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.price | 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. this.ProductService.GetRepeatBuyAgainProductList(
  135. {
  136. userId:this.userId,
  137. pageNum:this.pageNum,
  138. pageSize:this.pageSize,
  139. }
  140. )
  141. .then(response =>{
  142. this.isShowWrapper = true
  143. this.showSkeleton = false;
  144. const listData = response.data.results;
  145. if(listData && listData.length > 0){
  146. this.hasNextPage = responseData.hasNextPage;
  147. this.isShowEmpty = false;
  148. if(loadMore) {
  149. this.productList = [...this.productList,...listData];
  150. } else {
  151. this.productList = [...listData];
  152. }
  153. //价格显示处理
  154. let isActFlg,newProductList=[];
  155. this.productList.map((item, index)=> {
  156. if(item.actStatus == 1){
  157. isActFlg = true
  158. }else if(item.actStatus == 1 && item.ladderPriceFlag == 1){
  159. isActFlg = true
  160. }else{
  161. isActFlg = false
  162. }
  163. newProductList.push(Object.assign({},item,{isShowActFlg:isActFlg}))
  164. })
  165. this.productList = newProductList
  166. console.log(this.productList)
  167. // 防上拉暴滑
  168. this.pullFlag = false;
  169. setTimeout(()=>{
  170. this.pullFlag = true;
  171. },500)
  172. // 底部提示文案
  173. if(this.hasNextPage) {
  174. this.loadingText = '上拉加载更多';
  175. } else {
  176. this.showLoading = true;
  177. this.loadingNow = false;
  178. }
  179. } else {
  180. if(!loadMore) {
  181. this.isShowEmpty = true;
  182. }
  183. }
  184. })
  185. .catch(error =>{
  186. this.$util.msg(error.msg,2000);
  187. })
  188. },
  189. operationHanld(prop){
  190. this.$emit('operationConfim',prop)
  191. },
  192. navToDetailPage(id) {
  193. this.isModallayer = true;
  194. this.$api.navigateTo(`/pages/goods/product?id=${id}`);
  195. this.isModallayer = false;
  196. },
  197. repurchModel(){
  198. this.$util.modal('','此商品的价格有变化,原来的购买价已不适用','知道了','',false,() =>{})
  199. },
  200. PromotionsFormat(promo){//促销活动类型数据处理
  201. if(promo!=null){
  202. if(promo.type == 1 && promo.mode == 1){
  203. return true
  204. }else{
  205. return false
  206. }
  207. }
  208. return false
  209. },
  210. onShowClose () {//输入框失去焦点时触发
  211. if(this.searchInputVal != ''){
  212. this.isShowClose = true
  213. }else{
  214. this.isShowClose = false
  215. }
  216. },
  217. delInputText(){//清除输入框内容
  218. this.searchInputVal = ''
  219. this.isShowClose = false
  220. },
  221. btnClick() {
  222. this.$emit('goCartPage')
  223. },
  224. btnTouchstart() {
  225. // console.log('btnTouchstart');
  226. },
  227. btnTouchend() {
  228. // console.log('btnTouchend');
  229. }
  230. }
  231. }
  232. </script>
  233. <style lang="scss">
  234. .commodity-list-wrapper {
  235. scroll-view {
  236. height: 100%;
  237. }
  238. .empty-container-image {
  239. margin-top: -300rpx;
  240. }
  241. .toIndexPage {
  242. bottom: 390rpx;
  243. }
  244. .show-more-btn {
  245. width: 276rpx;
  246. height: 52rpx;
  247. line-height: 52rpx;
  248. border: 2rpx solid #D8D8D8;
  249. background: #F7F7F7;
  250. font-size: 26rpx;
  251. margin: 26rpx 0;
  252. position: absolute;
  253. left: 50%;
  254. margin-left: -138rpx;
  255. }
  256. }
  257. .all-type-list-content {
  258. height: auto;
  259. padding: 24rpx;
  260. background: #fff;
  261. margin-bottom: 2rpx;
  262. display: flex;
  263. flex-direction: row;
  264. box-sizing: content-box;
  265. .list-img {
  266. width: 240rpx;
  267. height: 240rpx !important;
  268. margin-right: 26rpx;
  269. border-radius: 10rpx;
  270. border: 2rpx solid #f3f3f3;
  271. }
  272. }
  273. .list-details-info {
  274. width: 442rpx;
  275. flex-direction: column;
  276. font-size: 26rpx;
  277. position: relative;
  278. .list-details-title {
  279. line-height: 38rpx;
  280. text-overflow: ellipsis;
  281. overflow: hidden;
  282. display: -webkit-box;
  283. -webkit-line-clamp: 2;
  284. line-clamp: 2;
  285. -webkit-box-orient: vertical;
  286. }
  287. .list-details-specs {
  288. width: 100%;
  289. display: inline-block;
  290. margin-top: 8rpx;
  291. color: #999999;
  292. }
  293. .list-details-miniQuantity {
  294. width: 100%;
  295. display: inline-block;
  296. margin-top: 7rpx;
  297. }
  298. }
  299. .list-details-price {
  300. width: 100%;
  301. float: left;
  302. line-height: 54rpx;
  303. .floor-item-act{
  304. height: 54rpx;
  305. text-align: center;
  306. box-sizing: border-box;
  307. float: left;
  308. .floor-tags{
  309. height: 28rpx;
  310. border-radius: 6rpx;
  311. background-color: #FFFFFF;
  312. line-height: 28rpx;
  313. color: $color-system;
  314. text-align: center;
  315. display: inline-block;
  316. padding:0 16rpx;
  317. font-size: $font-size-20;
  318. margin-left: 15rpx;
  319. border: 1px solid #E15616;
  320. }
  321. }
  322. .price-icon {
  323. width: 22rpx;
  324. height: 28rpx;
  325. vertical-align: middle;
  326. margin-right: 10rpx;
  327. }
  328. .price-icon + text {
  329. font-size: 25rpx;
  330. vertical-align: middle;
  331. }
  332. .list-login-now {
  333. width: 375rpx;
  334. color: #F8C499;
  335. .p-no{
  336. float: left;
  337. font-size: $font-size-24;
  338. color: $color-system;
  339. margin-right: 10rpx;
  340. }
  341. }
  342. .login-now {
  343. padding: 10rpx 10rpx 10rpx 0;
  344. }
  345. .list-none{
  346. margin-top: 15rpx;
  347. .price-small{
  348. font-size:$font-size-24;
  349. line-height: 40rpx;
  350. color: #FF2A2A;
  351. }
  352. }
  353. .list-shop{
  354. height: auto;
  355. float: left;
  356. .list-price {
  357. width: 100%;
  358. color: #FF2A2A;
  359. float: left;
  360. line-height:54rpx ;
  361. align-items: center;
  362. justify-content: center;
  363. .price-larger {
  364. font-size: $font-size-30;
  365. display: inline-block;
  366. &.none{
  367. text-decoration: line-through;
  368. color: #999999;
  369. }
  370. }
  371. }
  372. .list-price-none{
  373. width: 100%;
  374. .price-none{
  375. text-decoration: line-through;
  376. color: #999999;
  377. display: inline-block;
  378. }
  379. .icon-wenhao{
  380. font-size: $font-size-32;
  381. color: #0091FF;
  382. margin-left: 6rpx;
  383. }
  384. }
  385. }
  386. .add-cart-btn {
  387. float: right;
  388. width: 140rpx;
  389. height: 54rpx;
  390. line-height: 54rpx;
  391. border-radius: 27rpx;
  392. color: #fff;
  393. font-size: 24rpx;
  394. margin-right: 0;
  395. background:#FFFFFF;
  396. border: 1px solid #C9C9C9;
  397. color: $text-color;
  398. }
  399. }
  400. .cart-icon {
  401. width: 92rpx;
  402. height: 92rpx;
  403. border-radius: 50%;
  404. background: rgba(255, 147, 0, 0.5);
  405. position: fixed;
  406. right: 24rpx;
  407. bottom: 28%;
  408. display: flex;
  409. align-items: center;
  410. justify-content: center;
  411. cursor: pointer;
  412. image {
  413. width: 58rpx;
  414. height: 58rpx;
  415. }
  416. text {
  417. font-size: 28rpx;
  418. position: absolute;
  419. top: -10rpx;
  420. right: 0;
  421. }
  422. }
  423. </style>