buyagainList.vue 10 KB

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