buyagainList.vue 11 KB

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