buyagainList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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 !=null ? 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. <!-- 可拖动悬浮按钮 -->
  39. <cm-drag :cartNum="cartQuantity"
  40. :isDock="true"
  41. :existTabBar="true"
  42. @btnClick="btnClick"
  43. @btnTouchstart="btnTouchstart"
  44. @btnTouchend="btnTouchend">
  45. </cm-drag>
  46. <!-- 透明模态层 -->
  47. <modal-layer v-if='isModallayer'></modal-layer>
  48. </view>
  49. </template>
  50. <script>
  51. import listSkeleton from '@/components/cm-module/listTemplate/listSkeleton'
  52. import modalLayer from "@/components/modal-layer"
  53. import uniStars from '@/components/uni-stars/uni-stars.vue'
  54. import cmDrag from '@/components/cm-custom/cm-drag.vue'
  55. import { queryAgaingoodslist } from "@/api/product.js"
  56. import { mapState,mapMutations } from 'vuex';
  57. export default{
  58. name:'productList',
  59. components:{
  60. listSkeleton,
  61. modalLayer,
  62. uniStars,
  63. cmDrag
  64. },
  65. data(){
  66. return{
  67. isShowClose:false,
  68. searchInputVal:'',
  69. isModallayer:false,
  70. windowHeight: '',
  71. showSkeleton: true,
  72. isShowEmpty: false,
  73. userID: '',
  74. scrollHeight: '',
  75. productList: [],
  76. showLoading: false,
  77. loadingNow: true,
  78. loadingText: '上拉加载更多',
  79. pageSize: 10,
  80. pageNum: 1,
  81. hasNextPage: false,
  82. pullFlag: true,
  83. fromRegularPurchasePage: false,
  84. cartQuantity: 0,
  85. showRegularBtn: false,
  86. isPrecedence:false,
  87. windowWidth:'',
  88. windowHeight:'',
  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(error =>{
  163. this.$util.msg(error.msg,2000);
  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. repurchModel(){
  175. this.$util.modal('','此商品的价格有变化,原来的购买价已不适用','知道了','',false,() =>{})
  176. },
  177. onShowClose () {//输入框失去焦点时触发
  178. if(this.searchInputVal != ''){
  179. this.isShowClose = true
  180. }else{
  181. this.isShowClose = false
  182. }
  183. },
  184. delInputText(){//清除输入框内容
  185. this.searchInputVal = ''
  186. this.isShowClose = false
  187. },
  188. btnClick() {
  189. this.$emit('goCartPage')
  190. },
  191. btnTouchstart() {
  192. // console.log('btnTouchstart');
  193. },
  194. btnTouchend() {
  195. // console.log('btnTouchend');
  196. }
  197. }
  198. }
  199. </script>
  200. <style lang="scss">
  201. .commodity-list-wrapper {
  202. scroll-view {
  203. height: 100%;
  204. }
  205. .empty-container-image {
  206. margin-top: -300rpx;
  207. }
  208. .toIndexPage {
  209. bottom: 390rpx;
  210. }
  211. .show-more-btn {
  212. width: 276rpx;
  213. height: 52rpx;
  214. line-height: 52rpx;
  215. border: 2rpx solid #D8D8D8;
  216. background: #F7F7F7;
  217. font-size: 26rpx;
  218. margin: 26rpx 0;
  219. position: absolute;
  220. left: 50%;
  221. margin-left: -138rpx;
  222. }
  223. }
  224. .all-type-list-content {
  225. height: 240rpx;
  226. padding: 24rpx;
  227. background: #fff;
  228. margin-bottom: 2rpx;
  229. display: flex;
  230. flex-direction: row;
  231. box-sizing: content-box;
  232. .list-img {
  233. width: 240rpx;
  234. height: 240rpx !important;
  235. margin-right: 26rpx;
  236. border-radius: 10rpx;
  237. border: 2rpx solid #f3f3f3;
  238. }
  239. }
  240. .list-details-info {
  241. width: 442rpx;
  242. flex-direction: column;
  243. font-size: 26rpx;
  244. position: relative;
  245. .list-details-title {
  246. line-height: 38rpx;
  247. text-overflow: ellipsis;
  248. overflow: hidden;
  249. display: -webkit-box;
  250. -webkit-line-clamp: 2;
  251. line-clamp: 2;
  252. -webkit-box-orient: vertical;
  253. }
  254. .list-details-specs {
  255. width: 100%;
  256. display: inline-block;
  257. margin-top: 8rpx;
  258. color: #999999;
  259. }
  260. .list-details-miniQuantity {
  261. width: 100%;
  262. display: inline-block;
  263. margin-top: 7rpx;
  264. }
  265. }
  266. .list-details-price {
  267. width: 100%;
  268. display: flex;
  269. flex-direction: row;
  270. justify-content: space-between;
  271. .price-icon {
  272. width: 22rpx;
  273. height: 28rpx;
  274. vertical-align: middle;
  275. margin-right: 10rpx;
  276. }
  277. .price-icon + text {
  278. font-size: 25rpx;
  279. vertical-align: middle;
  280. }
  281. .list-login-now {
  282. width: 375rpx;
  283. color: #F8C499;
  284. .p-no{
  285. float: left;
  286. font-size: $font-size-24;
  287. color: $color-system;
  288. margin-right: 10rpx;
  289. }
  290. }
  291. .login-now {
  292. padding: 10rpx 10rpx 10rpx 0;
  293. }
  294. .list-none{
  295. margin-top: 15rpx;
  296. .price-small{
  297. font-size:$font-size-24;
  298. line-height: 40rpx;
  299. color: #FF2A2A;
  300. }
  301. }
  302. .list-shop{
  303. width: 100%;
  304. height: auto;
  305. flex: 6;
  306. .list-price {
  307. width: 100%;
  308. color: #FF2A2A;
  309. float: left;
  310. line-height:36rpx ;
  311. align-items: center;
  312. justify-content: center;
  313. .price-larger {
  314. margin-top: 20rpx;
  315. font-size: $font-size-30;
  316. display: inline-block;
  317. }
  318. .price-view{
  319. display: inline-block;
  320. width: 40rpx;
  321. border-radius: 10rpx;
  322. font-size: $font-size-22;
  323. text-align: center;
  324. color: #FFFFFF;
  325. height: 36rpx;
  326. line-height: 36rpx;
  327. margin-right: 8rpx;
  328. &.ladder{
  329. background: linear-gradient(135deg,rgba(255,0,0,1) 0%,rgba(242,143,49,1) 100%);
  330. }
  331. &.activity{
  332. background: linear-gradient(135deg,rgba(128,0,255,1) 0%,rgba(242,49,153,1) 100%);
  333. }
  334. }
  335. }
  336. .list-price-none{
  337. width: 100%;
  338. .price-none{
  339. text-decoration: line-through;
  340. color: #999999;
  341. display: inline-block;
  342. }
  343. .icon-wenhao{
  344. font-size: $font-size-32;
  345. color: #0091FF;
  346. margin-left: 6rpx;
  347. }
  348. }
  349. }
  350. .add-cart-btn {
  351. flex: 4;
  352. width: 156rpx;
  353. height: 64rpx;
  354. line-height: 64rpx;
  355. border-radius: 32rpx;
  356. color: #fff;
  357. font-size: 26rpx;
  358. margin-right: 0;
  359. background:linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  360. }
  361. }
  362. .cart-icon {
  363. width: 92rpx;
  364. height: 92rpx;
  365. border-radius: 50%;
  366. background: rgba(255, 147, 0, 0.5);
  367. position: fixed;
  368. right: 24rpx;
  369. bottom: 28%;
  370. display: flex;
  371. align-items: center;
  372. justify-content: center;
  373. cursor: pointer;
  374. image {
  375. width: 58rpx;
  376. height: 58rpx;
  377. }
  378. text {
  379. font-size: 28rpx;
  380. position: absolute;
  381. top: -10rpx;
  382. right: 0;
  383. }
  384. }
  385. </style>