immediately.vue 15 KB

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