buyagainList.vue 11 KB

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