immediately.vue 14 KB

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