immediately.vue 14 KB

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