buyagainList.vue 11 KB

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