immediately.vue 13 KB

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