productList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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" :listType='0'></list-skeleton>
  4. <view class="product-container" v-if="!isShowEmpty">
  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.id" 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" v-if="item.priceFlag == 1">
  13. <view class="list-none"><view class="price-small">未公开价格</view></view>
  14. </view>
  15. <view class="list-details-price" v-else>
  16. <view class="list-shop">
  17. <view class="list-price-none" v-if="item.repurchaseFlag == 1">
  18. <text class="price-none">¥{{item.originalPrice}}</text>
  19. <text class="iconfont icon-wenhao" @click.stop="repurchModel"></text>
  20. </view>
  21. <view class="list-price" v-else>
  22. <text class="price-larger" :class="PromotionsFormat(item.promotions) ? 'none' : ''">
  23. ¥{{ (PromotionsFormat(item.promotions) ? item.originalPrice : item.price) | NumFormat }}
  24. </text>
  25. </view>
  26. </view>
  27. <button class="add-cart-btn" @click.stop="operationHanld(item)">数量</button>
  28. </view>
  29. <view class="list-details-price" v-if="item.actStatus==1">
  30. <view class="floor-item-act">
  31. <view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
  32. {{item.promotions.name}}<text v-if="item.priceFlag != 1">:¥{{ item.price | NumFormat }}</text>
  33. </view>
  34. <view class="floor-tags" v-else>{{item.promotions.name}}</view>
  35. </view>
  36. <view class="floor-item-act" v-if="item.actStatus ==0 && item.ladderPriceFlag==1">
  37. <view class="floor-tags">阶梯价格</view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <button class="show-more-btn" v-if="showRegularBtn" @click="getListFromServer(true)">查看更多</button>
  43. <view v-if="showLoading && productList.length > 4 && !showRegularBtn">
  44. <view class="loading-wrapper loading-wrapper-now" v-if="loadingNow">{{loadingText}}<text v-if="loadingText === '已至底部'">‧ ‧ ‧</text></view>
  45. <view class="loading-wrapper loading-wrapper-btm" v-else>———<text class="btm-text">已至底部</text>———</view>
  46. </view>
  47. </scroll-view>
  48. </view>
  49. <view class="empty-container" v-else>
  50. <image class="empty-container-image" src="https://img.caimei365.com/group1/M00/03/71/Cmis2F3wna6AWdWzAAGlgAP0das422.png" mode="aspectFit"></image>
  51. <text class="error-text">您还没有购买过任何商品哟~</text>
  52. <button class="submit-btn toIndexPage" @click="toIndexPage">去逛逛</button>
  53. </view>
  54. <!-- 可拖动悬浮按钮 -->
  55. <cm-drag v-if="!isShowEmpty"
  56. :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. props: {
  82. emptyText: {
  83. type: String
  84. },
  85. },
  86. data(){
  87. return{
  88. isModallayer:false,
  89. windowHeight: '',
  90. showSkeleton: true,
  91. isShowEmpty: false,
  92. userId: '',
  93. scrollHeight: '',
  94. productList: [],
  95. showLoading: false,
  96. loadingNow: true,
  97. loadingText: '上拉加载更多',
  98. pageSize: 10,
  99. pageNum: 1,
  100. hasNextPage: false,
  101. pullFlag: true,
  102. fromRegularPurchasePage: false,
  103. cartQuantity: 0,
  104. showRegularBtn: false,
  105. isPrecedence:false
  106. }
  107. },
  108. created() {
  109. this.setScrollHeight();
  110. this.$api.getStorage().then((resolve) =>{
  111. this.userId = resolve.userId ? resolve.userId : 0
  112. this.getProductAgainInfo()
  113. })
  114. },
  115. filters: {
  116. NumFormat:function(text) {//处理金额
  117. return Number(text).toFixed(2);
  118. },
  119. },
  120. computed: {
  121. ...mapState(['hasLogin','userInfo','identity'])
  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:13863,
  143. // userId:this.userId,
  144. identity:this.identity,
  145. pageNum:this.pageNum,
  146. pageSize:this.pageSize,
  147. }
  148. )
  149. .then(response =>{
  150. this.isShowWrapper = true
  151. this.cartQuantity = response.data.cartQuantity
  152. const listData = response.data.results;
  153. if(listData && listData.length > 0){
  154. this.hasNextPage = response.data.hasNextPage;
  155. this.isShowEmpty = false;
  156. if(loadMore) {
  157. this.productList = [...this.productList,...listData];
  158. } else {
  159. this.productList = listData;
  160. this.showSkeleton = false;
  161. }
  162. //价格显示处理
  163. let isActFlg,newProductList=[];
  164. this.productList.map((item, index)=> {
  165. if(item.actStatus == 1){
  166. isActFlg = true
  167. }else if(item.actStatus == 1 && item.ladderPriceFlag == '1'){
  168. isActFlg = true
  169. }else{
  170. isActFlg = false
  171. }
  172. newProductList.push(Object.assign({},item,{isShowActFlg:isActFlg}))
  173. })
  174. this.productList = newProductList
  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. }).catch(response =>{
  193. this.$util.msg(response.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. toIndexPage() {
  205. uni.switchTab({
  206. url: '/pages/tabBar/home/index'
  207. })
  208. },
  209. repurchModel(){
  210. this.$util.modal('','此商品的价格有变化,原来的购买价已不适用','知道了','',false,() =>{})
  211. },
  212. PromotionsFormat(promo){//促销活动类型数据处理
  213. if(promo!=null){
  214. if(promo.type == 1 && promo.mode == 1){
  215. return true
  216. }else{
  217. return false
  218. }
  219. }
  220. return false
  221. },
  222. btnClick() {
  223. this.$api.navigateTo('/pages/goods/cart')
  224. },
  225. btnTouchstart() {
  226. // console.log('btnTouchstart');
  227. },
  228. btnTouchend() {
  229. // console.log('btnTouchend');
  230. }
  231. }
  232. }
  233. </script>
  234. <style lang="scss">
  235. .commodity-list-wrapper {
  236. scroll-view {
  237. height: 100%;
  238. border-top: 2rpx solid rgba(0,0,0,0.07);
  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. line-height: 54rpx;
  304. float: left;
  305. .floor-item-act{
  306. height: 54rpx;
  307. text-align: center;
  308. box-sizing: border-box;
  309. float: left;
  310. .floor-tags{
  311. height: 28rpx;
  312. border-radius: 6rpx;
  313. background-color: #FFFFFF;
  314. line-height: 28rpx;
  315. color: $color-system;
  316. text-align: center;
  317. display: inline-block;
  318. padding:0 16rpx;
  319. font-size: $font-size-20;
  320. margin-left: 15rpx;
  321. border: 1px solid #E15616;
  322. }
  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. position: absolute;
  338. bottom: 0;
  339. .p-no{
  340. float: left;
  341. font-size: $font-size-24;
  342. color: $color-system;
  343. margin-right: 10rpx;
  344. }
  345. }
  346. .login-now {
  347. padding: 10rpx 10rpx 10rpx 0;
  348. }
  349. .list-none{
  350. margin-top: 30rpx;
  351. .price-small{
  352. font-size:$font-size-24;
  353. line-height: 40rpx;
  354. color: #FF2A2A;
  355. }
  356. }
  357. .list-shop{
  358. height: auto;
  359. float: left;
  360. .list-price {
  361. width: 100%;
  362. color: #FF2A2A;
  363. float: left;
  364. line-height:54rpx ;
  365. align-items: center;
  366. justify-content: center;
  367. .price-larger {
  368. font-size: $font-size-30;
  369. display: inline-block;
  370. &.none{
  371. text-decoration: line-through;
  372. color: #999999;
  373. }
  374. }
  375. }
  376. .list-price-none{
  377. width: 100%;
  378. .price-none{
  379. text-decoration: line-through;
  380. color: #999999;
  381. display: inline-block;
  382. }
  383. .icon-wenhao{
  384. font-size: $font-size-32;
  385. color: #0091FF;
  386. margin-left: 6rpx;
  387. }
  388. }
  389. }
  390. .add-cart-btn {
  391. float: right;
  392. width: 140rpx;
  393. height: 54rpx;
  394. line-height: 54rpx;
  395. border-radius: 27rpx;
  396. color: #fff;
  397. font-size: 24rpx;
  398. margin-right: 0;
  399. background:#FFFFFF;
  400. border: 1px solid #C9C9C9;
  401. color: $text-color;
  402. }
  403. }
  404. </style>