buyagainList.vue 11 KB

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