buyagainList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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.mainImage" 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}}</text>
  11. <text class="list-details-miniQuantity">起订量:{{item.minBuyNumber}}</text>
  12. <view class="list-details-price" v-if="item.price1TextFlag == 1">
  13. <view class="list-none">
  14. <view class="price-small">该商品尚未公开价格</view>
  15. <view class="price-small">购买请致电:0755-22907771</view>
  16. </view>
  17. </view>
  18. <view class="list-details-price" v-else>
  19. <view class="list-shop">
  20. <view class="list-price" >
  21. <text class="price-view activity" v-if="item.isShowActFlg">活动价</text>
  22. <text class="price-view ladder" v-if="item.ladderPriceFlag == 1">阶梯价</text>
  23. <text class="price-larger">¥{{item.retailPrice.toFixed(2)}}</text>
  24. </view>
  25. <view class="list-price-none" v-if="item.repurchasePriceState">
  26. <text class="price-none">¥{{item.discountPrice}}</text>
  27. <text class="iconfont icon-wenhao" @click.stop="repurchModel"></text>
  28. </view>
  29. </view>
  30. <button class="add-cart-btn" @click.stop="operationHanld(item)">选择数量</button>
  31. </view>
  32. </view>
  33. </view>
  34. <button class="show-more-btn" v-if="showRegularBtn" @click="getListFromServer(true)">查看更多</button>
  35. <view v-if="showLoading && productList.length > 4 && !showRegularBtn">
  36. <view class="loading-wrapper loading-wrapper-now" v-if="loadingNow">{{loadingText}}<text v-if="loadingText === '已至底部'">‧ ‧ ‧</text></view>
  37. <view class="loading-wrapper loading-wrapper-btm" v-else>———<text class="btm-text">已至底部</text>———</view>
  38. </view>
  39. </scroll-view>
  40. </view>
  41. <view class="empty-container" v-else>
  42. <image class="empty-container-image" src="https://img.caimei365.com/group1/M00/03/71/Cmis2F3wna6AWdWzAAGlgAP0das422.png" mode="aspectFit"></image>
  43. <text class="error-text">您还没有购买过任何商品哟~</text>
  44. <button class="submit-btn toIndexPage" @click="toIndexPage">去逛逛</button>
  45. </view>
  46. <view class="cart-icon" v-if="!isShowEmpty" @click="toCartPage">
  47. <text v-if="cartQuantity > 0" class="uni-badge uni-badge-error uni-small uni-badge--small icon-num">
  48. {{cartQuantity >= 100 ? '99+' : cartQuantity}}
  49. </text>
  50. <image src='../../../static/icon-cart-active@3x.png' mode="widthFix"></image>
  51. </view>
  52. <!-- 透明模态层 -->
  53. <modal-layer v-if='isModallayer'></modal-layer>
  54. </view>
  55. </template>
  56. <script>
  57. import listSkeleton from '@/components/module/listTemplate/listSkeleton'
  58. import modalLayer from "@/components/modal-layer"
  59. import uniStars from '@/components/uni-stars/uni-stars.vue'
  60. import { queryAgaingoodslist } from "@/api/product.js"
  61. import { mapState,mapMutations } from 'vuex';
  62. export default{
  63. name:'productList',
  64. components:{
  65. listSkeleton,
  66. modalLayer,
  67. uniStars
  68. },
  69. props: {
  70. emptyText: {
  71. type: String
  72. },
  73. },
  74. data(){
  75. return{
  76. isModallayer:false,
  77. windowHeight: '',
  78. showSkeleton: true,
  79. isShowEmpty: false,
  80. userID: '',
  81. scrollHeight: '',
  82. productList: [],
  83. showLoading: false,
  84. loadingNow: true,
  85. loadingText: '上拉加载更多',
  86. pageSize: 10,
  87. pageNum: 1,
  88. hasNextPage: false,
  89. pullFlag: true,
  90. fromRegularPurchasePage: false,
  91. cartQuantity: 0,
  92. showRegularBtn: false,
  93. isPrecedence:false
  94. }
  95. },
  96. created() {
  97. this.setScrollHeight();
  98. this.$api.getStorage().then((resolve) =>{
  99. this.userID = resolve.userID
  100. this.getProductAgainInfo()
  101. })
  102. },
  103. computed: {
  104. ...mapState(['hasLogin','userInfo'])
  105. },
  106. methods:{
  107. scrolltolower() {
  108. if(this.hasNextPage && this.pullFlag) {
  109. this.getProductAgainInfo(true);
  110. }
  111. },
  112. setScrollHeight() {
  113. const {windowHeight, pixelRatio} = wx.getSystemInfoSync();
  114. this.windowHeight = windowHeight - 1;
  115. this.scrollHeight = windowHeight - 1;
  116. },
  117. getProductAgainInfo(loadMore) {
  118. this.showLoading = true;
  119. this.loadingNow = true;
  120. this.loadingText = '加载中';
  121. this.isShowEmpty = false;
  122. if(loadMore) {this.pageNum += 1;}
  123. let params = {userId:this.userID,pageNum:this.pageNum,pageSize:this.pageSize}
  124. queryAgaingoodslist(params).then(response =>{
  125. this.isShowWrapper = true
  126. this.cartQuantity = response.data.cartQuantity
  127. const responseData = response.data.pageDate;
  128. if(responseData.results && responseData.results.length > 0){
  129. this.hasNextPage = responseData.hasNextPage;
  130. this.isShowEmpty = false;
  131. if(loadMore) {
  132. this.productList = [...this.productList,...responseData.results];
  133. } else {
  134. this.productList = [...responseData.results];
  135. this.showSkeleton = false;
  136. }
  137. //价格显示处理
  138. let isActFlg,newProductList=[];
  139. this.productList.map((item, index)=> {
  140. if(item.actFlag == 1){
  141. isActFlg = true
  142. }else if(item.actFlag == 1 && item.ladderPriceFlag == 1){
  143. isActFlg = true
  144. }else{
  145. isActFlg = false
  146. }
  147. newProductList.push(Object.assign({},item,{isShowActFlg:isActFlg}))
  148. })
  149. this.productList = newProductList
  150. console.log(this.productList)
  151. // 防上拉暴滑
  152. this.pullFlag = false;
  153. setTimeout(()=>{
  154. this.pullFlag = true;
  155. },500)
  156. // 底部提示文案
  157. if(this.hasNextPage) {
  158. this.loadingText = '上拉加载更多';
  159. } else {
  160. this.showLoading = true;
  161. this.loadingNow = false;
  162. }
  163. } else {
  164. if(!loadMore) {
  165. this.isShowEmpty = true;
  166. }
  167. }
  168. }).catch(response =>{
  169. this.$util.msg(response.msg,3000);
  170. })
  171. },
  172. operationHanld(prop){
  173. this.$emit('operationConfim',prop)
  174. },
  175. navToDetailPage(id) {
  176. this.isModallayer = true;
  177. this.$api.navigateTo(`/pages/goods/product?id=${id}`);
  178. this.isModallayer = false;
  179. },
  180. toCartPage() {
  181. uni.switchTab({
  182. url: '/pages/tabBar/cart/cart'
  183. })
  184. },
  185. toIndexPage() {
  186. uni.switchTab({
  187. url: '/pages/tabBar/home/home'
  188. })
  189. },
  190. repurchModel(){
  191. this.$util.modal('','此商品成本有变化原来的购买价已不适用','知道了','',false,() =>{})
  192. }
  193. }
  194. }
  195. </script>
  196. <style lang="scss">
  197. .commodity-list-wrapper {
  198. scroll-view {
  199. height: 100%;
  200. border-top: 2rpx solid rgba(0,0,0,0.07);
  201. }
  202. .empty-container-image {
  203. margin-top: -300rpx;
  204. }
  205. .toIndexPage {
  206. bottom: 390rpx;
  207. }
  208. .show-more-btn {
  209. width: 276rpx;
  210. height: 52rpx;
  211. line-height: 52rpx;
  212. border: 2rpx solid #D8D8D8;
  213. background: #F7F7F7;
  214. font-size: 26rpx;
  215. margin: 26rpx 0;
  216. position: absolute;
  217. left: 50%;
  218. margin-left: -138rpx;
  219. }
  220. }
  221. .all-type-list-content {
  222. height: 240rpx;
  223. padding: 24rpx;
  224. background: #fff;
  225. margin-bottom: 2rpx;
  226. display: flex;
  227. flex-direction: row;
  228. box-sizing: content-box;
  229. .list-img {
  230. width: 240rpx;
  231. height: 240rpx !important;
  232. margin-right: 26rpx;
  233. border-radius: 10rpx;
  234. border: 2rpx solid #f3f3f3;
  235. }
  236. }
  237. .list-details-info {
  238. width: 442rpx;
  239. flex-direction: column;
  240. font-size: 26rpx;
  241. position: relative;
  242. .list-details-title {
  243. line-height: 38rpx;
  244. text-overflow: ellipsis;
  245. overflow: hidden;
  246. display: -webkit-box;
  247. -webkit-line-clamp: 2;
  248. line-clamp: 2;
  249. -webkit-box-orient: vertical;
  250. }
  251. .list-details-specs {
  252. width: 100%;
  253. display: inline-block;
  254. margin-top: 8rpx;
  255. color: #999999;
  256. }
  257. .list-details-miniQuantity {
  258. width: 100%;
  259. display: inline-block;
  260. margin-top: 7rpx;
  261. }
  262. }
  263. .list-details-price {
  264. width: 100%;
  265. display: flex;
  266. flex-direction: row;
  267. justify-content: space-between;
  268. .price-icon {
  269. width: 22rpx;
  270. height: 28rpx;
  271. vertical-align: middle;
  272. margin-right: 10rpx;
  273. }
  274. .price-icon + text {
  275. font-size: 25rpx;
  276. vertical-align: middle;
  277. }
  278. .list-login-now {
  279. width: 375rpx;
  280. color: #F8C499;
  281. position: absolute;
  282. bottom: 0;
  283. .p-no{
  284. float: left;
  285. font-size: $font-size-24;
  286. color: $color-system;
  287. margin-right: 10rpx;
  288. }
  289. }
  290. .login-now {
  291. padding: 10rpx 10rpx 10rpx 0;
  292. }
  293. .list-none{
  294. margin-top: 30rpx;
  295. .price-small{
  296. font-size:$font-size-24;
  297. line-height: 40rpx;
  298. color: #FF2A2A;
  299. }
  300. }
  301. .list-shop{
  302. width: 100%;
  303. height: auto;
  304. flex: 6;
  305. .list-price {
  306. width: 100%;
  307. color: #FF2A2A;
  308. float: left;
  309. line-height:36rpx ;
  310. align-items: center;
  311. justify-content: center;
  312. .price-larger {
  313. margin-top: 20rpx;
  314. font-size: $font-size-30;
  315. display: inline-block;
  316. }
  317. .price-view{
  318. display: inline-block;
  319. width: 78rpx;
  320. border-radius: 18rpx;
  321. font-size: $font-size-20;
  322. text-align: center;
  323. color: #FFFFFF;
  324. height: 36rpx;
  325. line-height: 36rpx;
  326. margin-right: 8rpx;
  327. &.ladder{
  328. background: linear-gradient(135deg,rgba(255,0,0,1) 0%,rgba(242,143,49,1) 100%);
  329. }
  330. &.activity{
  331. background: linear-gradient(135deg,rgba(128,0,255,1) 0%,rgba(242,49,153,1) 100%);
  332. }
  333. }
  334. }
  335. .list-price-none{
  336. width: 100%;
  337. .price-none{
  338. text-decoration: line-through;
  339. color: #999999;
  340. display: inline-block;
  341. }
  342. .icon-wenhao{
  343. font-size: $font-size-32;
  344. color: #0091FF;
  345. margin-left: 6rpx;
  346. }
  347. }
  348. }
  349. .add-cart-btn {
  350. flex: 4;
  351. width: 156rpx;
  352. height: 64rpx;
  353. line-height: 64rpx;
  354. border-radius: 32rpx;
  355. color: #fff;
  356. font-size: 26rpx;
  357. margin-right: 0;
  358. background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  359. }
  360. }
  361. .cart-icon {
  362. width: 92rpx;
  363. height: 92rpx;
  364. border-radius: 50%;
  365. background: rgba(255, 147, 0, 0.5);
  366. position: fixed;
  367. right: 24rpx;
  368. bottom: 30%;
  369. display: flex;
  370. align-items: center;
  371. justify-content: center;
  372. cursor: pointer;
  373. image {
  374. width: 58rpx;
  375. height: 58rpx;
  376. }
  377. text {
  378. font-size: 28rpx;
  379. position: absolute;
  380. top: -10rpx;
  381. right: 0;
  382. }
  383. }
  384. </style>