buyagainList.vue 11 KB

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