immediately.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. <template>
  2. <view class="container all-type-list-wrapper">
  3. <immediately-list ref="productList"
  4. :search-status="true"
  5. @operationConfim="hanldOperationConfim"
  6. @alertjietiConfim ="hanldalertjietiConfim"
  7. @goCartPage="hanldToCartPage"
  8. :tabBars="tabBars"
  9. :tabIndex="tabIndex"
  10. @changetab="hanldChangeTab"
  11. >
  12. </immediately-list>
  13. <!-- 单品规格弹窗 -->
  14. <cm-unit-popup v-if="popupShow" :popupShow="popupShow" :product="handleData"></cm-unit-popup>
  15. <!-- 组合加入购物车 -->
  16. <view class="popup spec zuhe" :class="specClasszuhe" @touchmove.stop.prevent="discard" @tap="hideSpecs">
  17. <!-- 遮罩层 -->
  18. <view class="mask"></view>
  19. <view class="layer" @tap.stop="discard" :style="{paddingBottom :isIphoneX ? '68rpx' : '36rpx',bottom:isIphoneX ?'-290rpx' : '-270rpx'}">
  20. <view class="content zuhe-content">
  21. <view class="number-left">
  22. <text>种类:{{productKind}}</text>
  23. <text>数量:{{productTotalNum}}</text>
  24. </view>
  25. <view class="number-right">
  26. <view class="text">
  27. 总额:<text class="number-right-text">¥{{ productTotalAmount | NumFormat }}</text>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="btn">
  32. <view class="button add" @click="getzuheCart">确定</view>
  33. </view>
  34. </view>
  35. </view>
  36. <!-- -->
  37. <view class="popup spec zuhe" :class="specClassjieti" @touchmove.stop.prevent="discard" >
  38. <view class="mask"></view>
  39. <view class="jieti_box " @tap.stop="discard">
  40. <view class="jieti_box_one">
  41. <view class="jieti_left" >
  42. <view>起订量</view>
  43. <view class="ladder-a" v-for="(item,index) in ladderPriceList" :key="index">
  44. {{item.buyNumRangeShow}}
  45. </view>
  46. </view>
  47. <view class="jieti_right" >
  48. <view>价格</view>
  49. <view class="" v-for="(item,index) in ladderPriceList" :key="index">¥ {{item.buyPrice | NumFormat}}</view>
  50. </view>
  51. </view>
  52. <view class="addbtn" @tap="hideSpecjieti">知道了</view>
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import immediatelyList from './components/immediatelyList'
  59. import cmUnitPopup from './components/cm-unit-popup'
  60. export default{
  61. components:{
  62. immediatelyList,
  63. cmUnitPopup
  64. },
  65. data(){
  66. return{
  67. popupShow:false,
  68. clubId:'', //机构ID
  69. serviceProviderId:'',//协销ID
  70. serverUrl: '',
  71. emptyText: '',
  72. lastPageType: '',
  73. lastPageVal: '',
  74. isIphoneX:this.$store.state.isIphoneX,
  75. specClass: '',//规格弹窗css类,控制开关动画
  76. specClasszuhe:'',//组合加购物车弹窗
  77. specClassjieti:'',//阶梯展示弹窗
  78. ladderPriceList:{},
  79. handleData:{},
  80. isQuantity:false,
  81. isStock:false,
  82. minBuyNumber:0,
  83. number:0,
  84. buyRetailPrice:0,
  85. hanldChangeTabIndex:0,
  86. handleDataLadderPriceList:[],
  87. productKind:0,
  88. productTotalNum:0,
  89. productTotalAmount:0,
  90. buyNumRangeShow:'',//起订量范围
  91. buyPrice:'',//起订量范围价格
  92. buyRetailPriceStep:1,
  93. }
  94. },
  95. onLoad() {
  96. },
  97. filters:{
  98. NumFormat(value) {//处理金额
  99. return Number(value).toFixed(2);
  100. },
  101. },
  102. methods:{
  103. getClubProductNum(){// 获取协销下机构购物车数量
  104. this.SellerService.GetSellerProductNum(
  105. {
  106. clubId:this.clubId,
  107. serviceProviderId:this.serviceProviderId,
  108. }
  109. ).then(response =>{
  110. this.$refs.productList.cartQuantity = response.data
  111. })
  112. },
  113. hanldChangeTab(index){
  114. if(index == 1){
  115. this.$refs.productList.getcombinationProduct()
  116. }
  117. },
  118. hanldalertjietiConfim(data){
  119. this.ladderPriceList = data.ladderPriceList
  120. this.specClassjieti='show';
  121. },
  122. hanldOperationConfim(data){//显示选择数量确认弹窗
  123. this.handleData = data
  124. console.log(this.handleData)
  125. if(this.$refs.productList.tabIndex == 1){
  126. if(data.productKind ==0){
  127. this.$util.msg(`请至少选购一种商品`,2000);
  128. }else{
  129. this.specClasszuhe = 'show';
  130. this.productKind= data.productKind;
  131. this.productTotalNum = data.productTotalNum;
  132. this.productTotalAmount = data.productTotalAmount;
  133. }
  134. }else{
  135. this.popupShow = true
  136. }
  137. },
  138. hideSpecs(){
  139. this.specClasszuhe='hide';
  140. setTimeout(() => {
  141. this.specClasszuhe='none';
  142. }, 200);
  143. },
  144. hideSpecjieti(){
  145. this.specClassjieti='hide';
  146. setTimeout(() => {
  147. this.specClassjieti='none';
  148. }, 200);
  149. },
  150. getzuheCart(){//组合商品加入购物车
  151. let productInfo=[];
  152. this.handleData.combinationProductList.forEach(item =>{
  153. if(item.initProductNum >0){
  154. let handObj = {
  155. id : item.productId,
  156. count : item.initProductNum
  157. }
  158. productInfo.push(handObj)
  159. }
  160. })
  161. this.SellerService.ShoppingCartBatchAddCart(
  162. {
  163. clubId:this.clubId,
  164. serviceProviderId:this.serviceProviderId,
  165. productInfo:JSON.stringify(productInfo),
  166. type:2
  167. }
  168. ).then(response => {
  169. this.specClasszuhe = 'hide';
  170. this.$util.msg('加入购物车成功',1500,true,'success');
  171. this.getClubProductNum();
  172. this.clearProduct();//清空
  173. setTimeout(() => {this.specClasszuhe = 'none'}, 200)
  174. }).catch(error =>{
  175. this.$util.msg(error.msg,2000);
  176. })
  177. },
  178. clearProduct(){//成功加入购物车后清空所选值
  179. this.handleData.productKind= 0;
  180. this.handleData.productTotalNum = 0;
  181. this.handleData.productTotalAmount = 0;
  182. this.handleData.combinationProductList.forEach(item =>{
  183. item.initProductNum = 0;
  184. })
  185. },
  186. hanldToCartPage(){
  187. this.$api.navigateTo('/pages/seller/cart/cart')
  188. },
  189. discard(){
  190. //丢弃
  191. }
  192. },
  193. onShow() {
  194. this.$api.getComStorage('orderUserInfo').then((resolve) =>{
  195. this.clubId = resolve.clubId ? resolve.clubId : 0
  196. })
  197. this.$api.getStorage().then((resolve) =>{
  198. this.serviceProviderId = resolve.serviceProviderId
  199. this.getClubProductNum()
  200. })
  201. },
  202. }
  203. </script>
  204. <style lang="scss">
  205. // 阶梯价格弹窗
  206. .jieti_box{
  207. width: 596rpx;
  208. // height: 496rpx;
  209. top: 10%;
  210. right: 50%;
  211. transform: translate(50%,50%);
  212. position: absolute;
  213. background:#FFFFFF;
  214. color: #000;
  215. font-size: 28rpx;
  216. border-radius: 10rpx;
  217. text-align: center;
  218. line-height: 84rpx;
  219. padding: 20rpx;
  220. z-index: 99999;
  221. }
  222. .jieti_box_one{
  223. // width: 548rpx;
  224. overflow: hidden;
  225. border: 2rpx solid #F5F5F5;
  226. border-bottom: 0;
  227. margin: auto;
  228. }
  229. .jieti_left{
  230. width: 298rpx;
  231. float: left;
  232. }
  233. .jieti_left view{
  234. height: 84rpx;
  235. border-bottom:2rpx solid #F5F5F5 ;
  236. border-right:2rpx solid #F5F5F5 ;
  237. }
  238. .ladder-a{
  239. letter-spacing: 4rpx;
  240. }
  241. .jieti_right{
  242. width: 294rpx;
  243. float: right;
  244. }
  245. .jieti_right view{
  246. height: 84rpx;
  247. border-bottom:2rpx solid #F5F5F5;
  248. }
  249. .addbtn{
  250. height: 84rpx;
  251. background: linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  252. text-align: center;
  253. font-size: 28rpx;
  254. color: #fff;
  255. line-height: 84rpx;
  256. border-radius: 42rpx;
  257. margin: 20rpx auto
  258. }
  259. .zuhe-content{
  260. display: inline-block;
  261. }
  262. .number-left{
  263. float: left;
  264. }
  265. .number-right{
  266. margin-left: 30rpx;
  267. float: left;
  268. }
  269. .number-left text{
  270. margin-left: 30rpx;
  271. }
  272. .number-right-text{
  273. color: #FF2A2A;
  274. }
  275. page {
  276. background: $sub-bg-color;
  277. .all-type-list-wrapper {
  278. display: flex;
  279. flex-direction: column;
  280. }
  281. }
  282. /* 加入购物模态层*/
  283. @keyframes showPopup {
  284. 0% {
  285. opacity: 0;
  286. }
  287. 100% {
  288. opacity: 1;
  289. }
  290. }
  291. @keyframes hidePopup {
  292. 0% {
  293. opacity: 1;
  294. }
  295. 100% {
  296. opacity: 0;
  297. }
  298. }
  299. @keyframes showLayer {
  300. 0% {
  301. transform: translateY(0);
  302. }
  303. 100% {
  304. transform: translateY(-100%);
  305. }
  306. }
  307. @keyframes hideLayer {
  308. 0% {
  309. transform: translateY(-100%);
  310. }
  311. 100% {
  312. transform: translateY(0);
  313. }
  314. }
  315. @keyframes showAmnation {
  316. 0% {
  317. top: -12rpx;
  318. opacity: 0;
  319. }
  320. 50% {
  321. top: -60rpx;
  322. opacity: 1;
  323. }
  324. 100% {
  325. top: -100rpx;
  326. opacity: 0;
  327. }
  328. }
  329. @keyframes hideAmnation {
  330. 0% {
  331. top: -100rpx;
  332. opacity: 0;
  333. }
  334. 100% {
  335. top: -12rpx;
  336. opacity: 0;
  337. }
  338. }
  339. .popup {
  340. position: fixed;
  341. top: 0;
  342. width: 100%;
  343. height: 100%;
  344. z-index: 999;
  345. display: none;
  346. .mask{
  347. position: fixed;
  348. top: 0;
  349. width: 100%;
  350. height: 100%;
  351. z-index: 21;
  352. background-color: rgba(0, 0, 0, 0.6);
  353. }
  354. .layer {
  355. position: fixed;
  356. z-index: 22;
  357. bottom: -360rpx;
  358. width: 702rpx;
  359. padding: 24rpx 24rpx 36rpx 24rpx;
  360. // height: 236rpx;
  361. border-radius: 20rpx 20rpx 0 0;
  362. background-color: #fff;
  363. display: flex;
  364. flex-wrap: wrap;
  365. align-content: space-between;
  366. .content {
  367. width: 100%;
  368. margin-top: 20rpx;
  369. }
  370. .btn {
  371. width: 100%;
  372. // height: 88rpx;
  373. display: flex;
  374. .button {
  375. width: 702rpx;
  376. height: 88rpx;
  377. color: #fff;
  378. display: flex;
  379. align-items: center;
  380. justify-content: center;
  381. font-size: $font-size-28;
  382. border-radius: 44rpx;
  383. background: $btn-confirm;
  384. margin-top: 20rpx;
  385. }
  386. }
  387. }
  388. .layer-nunbox-m{
  389. font-size: 28rpx;
  390. }
  391. &.show {
  392. display: block;
  393. .mask{
  394. animation: showPopup 0.2s linear both;
  395. }
  396. .layer {
  397. animation: showLayer 0.2s linear both;
  398. }
  399. }
  400. &.hide {
  401. display: block;
  402. .mask{
  403. animation: hidePopup 0.2s linear both;
  404. }
  405. .layer {
  406. animation: hideLayer 0.2s linear both;
  407. }
  408. }
  409. &.none {
  410. display: none;
  411. }
  412. &.service {
  413. .row {
  414. margin: 30upx 0;
  415. .title {
  416. font-size: 30upx;
  417. margin: 10upx 0;
  418. }
  419. .description {
  420. font-size: 28upx;
  421. color: #999;
  422. }
  423. }
  424. }
  425. .layer-smimg{
  426. width: 158rpx;
  427. height: 158rpx;
  428. float: left;
  429. border-radius: 10rpx;
  430. margin-right: 24rpx;
  431. image{
  432. width: 158rpx;
  433. height: 158rpx;
  434. border-radius: 10rpx;
  435. }
  436. }
  437. .layer-nunbox{
  438. justify-content: space-between;
  439. align-items: center;
  440. width: 510rpx;
  441. height: 88rpx;
  442. padding: 10rpx 0 0 0;
  443. float: left;
  444. .layer-nunbox-t{
  445. width: 100%;
  446. height:44rpx;
  447. position:relative;
  448. display: flex;
  449. margin-top: 10rpx;
  450. .layer-nunbox-text{
  451. line-height: 44rpx;
  452. font-size: $font-size-28;
  453. }
  454. .number-box{
  455. display: flex;
  456. justify-content: center;
  457. align-items: center;
  458. border: 2rpx solid #ffe6dc;
  459. border-radius: 30rpx;
  460. height: 48rpx;
  461. margin-left: 20rpx;
  462. .iconfont{
  463. font-size: $font-size-24;
  464. padding:0 18rpx;
  465. color: #999999;
  466. text-align: center;
  467. line-height: 48rpx;
  468. font-weight: bold;
  469. background: #fef6f3;
  470. &.icon-jianhao{
  471. border-radius: 30rpx 0 0 30rpx;
  472. }
  473. &.icon-jiahao{
  474. border-radius: 0 30rpx 30rpx 0;
  475. }
  476. }
  477. .btn-input{
  478. width: 80rpx;
  479. height: 48rpx;
  480. line-height: 48rpx;
  481. background: #FFFFFF;
  482. border-radius: 4rpx;
  483. text-align: center;
  484. font-size: $font-size-28;
  485. }
  486. }
  487. .product-step{
  488. position: absolute;
  489. left: 45rpx;
  490. bottom: 0;
  491. height: 44rpx;
  492. background: #FFFFFF;
  493. }
  494. }
  495. .layer-nunbox-b{
  496. width: 100%;
  497. height:44rpx;
  498. margin-top: 13rpx;
  499. }
  500. .text{
  501. line-height: 44rpx;
  502. font-size: $font-size-28;
  503. .p{
  504. color: #FF2A2A;
  505. }
  506. .p:first-child{
  507. margin-left: 30rpx;
  508. }
  509. .p.sm{
  510. font-size: $font-size-24;
  511. }
  512. }
  513. }
  514. }
  515. .zuhe .layer{
  516. bottom: -270rpx;
  517. height: 200rpx;
  518. }
  519. </style>