buyagainList.vue 10 KB

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