immediately.vue 14 KB

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