immediately.vue 14 KB

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