immediately.vue 15 KB

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