immediately.vue 15 KB

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