buyagainList.vue 10 KB

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