second.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. <template>
  2. <view class="container all-type-list-wrapper">
  3. <second-hand ref="productList"
  4. :search-status="true"
  5. @operationConfim="hanldOperationConfim"
  6. >
  7. </second-hand>
  8. <!--底部选择模态层弹窗组件 -->
  9. <view class="popup spec" :class="specClass" @touchmove.stop.prevent="discard" @tap="hideSpec" >
  10. <!-- 遮罩层 -->
  11. <view class="mask"></view>
  12. <view class="layer" @tap.stop="discard" :style="{paddingBottom :isIphoneX ? '68rpx' : '36rpx',bottom:isIphoneX ?'-370rpx' : '-360rpx'}">
  13. <view class="content">
  14. <view class="layer-smimg">
  15. <image :src="handleData.mainImage" mode=""></image>
  16. </view>
  17. <view class="layer-nunbox">
  18. <view class="layer-nunbox-t">
  19. <view class="layer-nunbox-text">数量:</view>
  20. <view class="number-box">
  21. <view class="iconfont icon-jianhao" :class="[isQuantity?'disabled':'']" @click="changeCountSub()"></view>
  22. <input class="btn-input" type="number" v-model="number" maxlength='6' @blur="changeNumber($event)">
  23. <view class="iconfont icon-jiahao" :class="[isStock?'disabled':'']" @click="changeCountAdd()"></view>
  24. </view>
  25. </view>
  26. <view class="layer-nunbox-b">
  27. <view class="text">单价:
  28. <text class="p sm">¥</text>
  29. <text class="p bg">{{buyRetailPrice.toFixed(2)}}</text>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="btn">
  35. <view class="button add" @click="toConfirmation">立即购买</view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import secondHand from '@/components/cm-module/listTemplate/secondHand'
  43. export default{
  44. components:{
  45. secondHand
  46. },
  47. data(){
  48. return{
  49. clubID:'', //机构ID
  50. serviceProviderId:'',//协销ID
  51. serverUrl: '',
  52. emptyText: '',
  53. lastPageType: '',
  54. lastPageVal: '',
  55. isIphoneX:this.$store.state.isIphoneX,
  56. specClass: '',//规格弹窗css类,控制开关动画
  57. specClasszuhe:'',//组合加购物车弹窗
  58. specClassjieti:'',//阶梯展示弹窗
  59. ladderPriceList:{},
  60. handleData:{},
  61. isQuantity:false,
  62. isStock:false,
  63. number:1,
  64. buyRetailPrice:0,
  65. productKind:0,
  66. productTotalNum:0,
  67. productTotalAmount:0,
  68. buyNumRangeShow:'',//起订量范围
  69. buyPrice:'',//起订量范围价格
  70. buyRetailPriceStep:1,
  71. secondProductType:'',
  72. }
  73. },
  74. onLoad() {
  75. },
  76. methods:{
  77. getClubProductNum(){
  78. this.SellerService.GetSellerProductNum({clubId:this.clubID,serviceProviderId:this.serviceProviderId}).then(response =>{
  79. this.$refs.productList.cartQuantity = response.data
  80. })
  81. },
  82. hanldOperationConfim(data){//显示选择数量确认弹窗
  83. console.log(this.handleData)
  84. this.handleData = data
  85. this.number = 1
  86. this.buyRetailPrice = Number(data.price1);
  87. this.secondProductType = data.secondProductType
  88. this.specClass = 'show';
  89. },
  90. hideSpec() {//关闭选择数量确认弹窗
  91. this.specClass = 'hide';
  92. setTimeout(() => {
  93. this.specClass = 'none';
  94. }, 200);
  95. },
  96. changeCountAdd(){//popup弹窗数量增加按钮
  97. if(this.handleData.secondHandType == 2||this.handleData.secondHandType == 3){
  98. // if(this.number >= this.handleData.stock){
  99. // this.number= this.handleData.stock
  100. // this.isStock =true
  101. // this.$util.msg(`购买数量最高为${this.handleData.stock}`,2000);
  102. // return
  103. // }else{
  104. this.number++
  105. this.isQuantity =false
  106. // }
  107. this.buyRetailPrice = this.number*this.handleData.price1
  108. }else{
  109. this.isStock =true
  110. this.$util.msg(`该商品购买数量只能为1`,2000);
  111. }
  112. },
  113. changeCountSub(){//popup弹窗数量减按钮
  114. if(this.handleData.secondHandType == 2||this.handleData.secondHandType == 3){
  115. // if(this.number <= 1){
  116. // this.number= 1
  117. // this.isQuantity =true
  118. // this.$util.msg(`购买数量最低为1`,2000);
  119. // return
  120. // }else{
  121. this.number--
  122. this.isQuantity =false
  123. // }
  124. this.buyRetailPrice = this.number*this.handleData.price1
  125. }else{
  126. this.isQuantity =true
  127. this.$util.msg(`该商品购买数量只能为1`,2000);
  128. }
  129. },
  130. // changeNumber(e){
  131. // let _value = e.detail.value;
  132. // if(!this.$api.isNumber(_value)){
  133. // this.number = this.minBuyNumber
  134. // }else if(_value < this.minBuyNumber){
  135. // this.$util.msg(`该商品最小起订量为${this.minBuyNumber}`,2000);
  136. // this.number = this.minBuyNumber
  137. // }else if( _value % this.minBuyNumber !=0 ){
  138. // this.$util.msg(`购买量必须为起订量的整数倍`,2000);
  139. // this.number = this.minBuyNumber
  140. // }else{
  141. // this.number = e.detail.value
  142. // }
  143. // },
  144. changeNumber(e){
  145. let _value = e.detail.value;
  146. if(!this.$api.isNumber(_value)){
  147. this.number = 1
  148. }else if(_value <= 1){
  149. this.$util.msg(`该商品最小起订量为1`,2000);
  150. this.number = 1
  151. }else{
  152. this.number = e.detail.value
  153. }
  154. this.buyRetailPrice = this.number*this.handleData.price1
  155. },
  156. clearProduct(){//成功加入购物车后清空所选值
  157. this.handleData.productKind= 0;
  158. this.handleData.productTotalNum = 0;
  159. this.handleData.productTotalAmount = 0;
  160. this.handleData.combinationProductList.forEach(item =>{
  161. item.initProductNum = 0;
  162. })
  163. },
  164. toConfirmation(){//跳转确认订单页面
  165. this.specClass = 'hide';
  166. let cartPramsData={
  167. clubId:this.clubID,
  168. allPrice:this.buyRetailPrice,
  169. allCount:this.number,
  170. productID:this.handleData.productID,
  171. productCount:this.number
  172. }
  173. this.$api.navigateTo(`/seller/pages/order/create-order?type=prodcut&data=${JSON.stringify({data:cartPramsData})}`)
  174. setTimeout(() => {
  175. this.specClass = 'none';
  176. }, 200);
  177. },
  178. hanldToCartPage(){
  179. this.$api.navigateTo('/seller/pages/cart/cart')
  180. },
  181. discard(){
  182. //丢弃
  183. }
  184. },
  185. onShow() {
  186. this.$api.getComStorage('orderUserInfo').then((resolve) =>{
  187. this.clubID = resolve.clubID
  188. })
  189. this.$api.getStorage().then((resolve) =>{
  190. this.serviceProviderId = resolve.serviceProviderID
  191. this.getClubProductNum()
  192. })
  193. },
  194. }
  195. </script>
  196. <style lang="scss">
  197. // 阶梯价格弹窗
  198. .jieti_box{
  199. width: 596rpx;
  200. // height: 496rpx;
  201. top: 10%;
  202. right: 50%;
  203. transform: translate(50%,50%);
  204. position: absolute;
  205. background:#FFFFFF;
  206. color: #000;
  207. font-size: 28rpx;
  208. border-radius: 10rpx;
  209. text-align: center;
  210. line-height: 84rpx;
  211. padding: 20rpx;
  212. z-index: 99999;
  213. }
  214. .jieti_box_one{
  215. // width: 548rpx;
  216. overflow: hidden;
  217. border: 2rpx solid #F5F5F5;
  218. border-bottom: 0;
  219. margin: auto;
  220. }
  221. .jieti_left{
  222. width: 298rpx;
  223. float: left;
  224. }
  225. .jieti_left view{
  226. height: 84rpx;
  227. border-bottom:2rpx solid #F5F5F5 ;
  228. border-right:2rpx solid #F5F5F5 ;
  229. }
  230. .ladder-a{
  231. letter-spacing: 4rpx;
  232. }
  233. .jieti_right{
  234. width: 294rpx;
  235. float: right;
  236. }
  237. .jieti_right view{
  238. height: 84rpx;
  239. border-bottom:2rpx solid #F5F5F5;
  240. }
  241. .addbtn{
  242. height: 84rpx;
  243. background: linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  244. text-align: center;
  245. font-size: 28rpx;
  246. color: #fff;
  247. line-height: 84rpx;
  248. border-radius: 10rpx;
  249. margin: 20rpx auto
  250. }
  251. .zuhe-content{
  252. display: inline-block;
  253. }
  254. .number-left{
  255. float: left;
  256. }
  257. .number-right{
  258. margin-left: 30rpx;
  259. float: left;
  260. }
  261. .number-left text{
  262. margin-left: 30rpx;
  263. }
  264. .number-right-text{
  265. color: #FF2A2A;
  266. }
  267. page {
  268. background: $sub-bg-color;
  269. .all-type-list-wrapper {
  270. display: flex;
  271. flex-direction: column;
  272. }
  273. }
  274. /* 加入购物模态层*/
  275. @keyframes showPopup {
  276. 0% {
  277. opacity: 0;
  278. }
  279. 100% {
  280. opacity: 1;
  281. }
  282. }
  283. @keyframes hidePopup {
  284. 0% {
  285. opacity: 1;
  286. }
  287. 100% {
  288. opacity: 0;
  289. }
  290. }
  291. @keyframes showLayer {
  292. 0% {
  293. transform: translateY(0);
  294. }
  295. 100% {
  296. transform: translateY(-100%);
  297. }
  298. }
  299. @keyframes hideLayer {
  300. 0% {
  301. transform: translateY(-100%);
  302. }
  303. 100% {
  304. transform: translateY(0);
  305. }
  306. }
  307. @keyframes showAmnation {
  308. 0% {
  309. top: -12rpx;
  310. opacity: 0;
  311. }
  312. 50% {
  313. top: -60rpx;
  314. opacity: 1;
  315. }
  316. 100% {
  317. top: -100rpx;
  318. opacity: 0;
  319. }
  320. }
  321. @keyframes hideAmnation {
  322. 0% {
  323. top: -100rpx;
  324. opacity: 0;
  325. }
  326. 100% {
  327. top: -12rpx;
  328. opacity: 0;
  329. }
  330. }
  331. .popup {
  332. position: fixed;
  333. top: 0;
  334. width: 100%;
  335. height: 100%;
  336. z-index: 999;
  337. display: none;
  338. .mask{
  339. position: fixed;
  340. top: 0;
  341. width: 100%;
  342. height: 100%;
  343. z-index: 21;
  344. background-color: rgba(0, 0, 0, 0.6);
  345. }
  346. .layer {
  347. position: fixed;
  348. z-index: 22;
  349. bottom: -360rpx;
  350. width: 702rpx;
  351. padding: 24rpx 24rpx 36rpx 24rpx;
  352. // height: 236rpx;
  353. border-radius: 20rpx 20rpx 0 0;
  354. background-color: #fff;
  355. display: flex;
  356. flex-wrap: wrap;
  357. align-content: space-between;
  358. .content {
  359. width: 100%;
  360. margin-top: 20rpx;
  361. }
  362. .btn {
  363. width: 100%;
  364. // height: 88rpx;
  365. display: flex;
  366. .button {
  367. width: 702rpx;
  368. height: 88rpx;
  369. color: #fff;
  370. display: flex;
  371. align-items: center;
  372. justify-content: center;
  373. font-size: $font-size-28;
  374. border-radius: 44rpx;
  375. background: $btn-confirm;
  376. margin-top: 20rpx;
  377. }
  378. }
  379. }
  380. .layer-nunbox-m{
  381. font-size: 28rpx;
  382. }
  383. &.show {
  384. display: block;
  385. .mask{
  386. animation: showPopup 0.2s linear both;
  387. }
  388. .layer {
  389. animation: showLayer 0.2s linear both;
  390. }
  391. }
  392. &.hide {
  393. display: block;
  394. .mask{
  395. animation: hidePopup 0.2s linear both;
  396. }
  397. .layer {
  398. animation: hideLayer 0.2s linear both;
  399. }
  400. }
  401. &.none {
  402. display: none;
  403. }
  404. &.service {
  405. .row {
  406. margin: 30upx 0;
  407. .title {
  408. font-size: 30upx;
  409. margin: 10upx 0;
  410. }
  411. .description {
  412. font-size: 28upx;
  413. color: #999;
  414. }
  415. }
  416. }
  417. .layer-smimg{
  418. width: 158rpx;
  419. height: 158rpx;
  420. float: left;
  421. border-radius: 10rpx;
  422. margin-right: 24rpx;
  423. image{
  424. width: 158rpx;
  425. height: 158rpx;
  426. border-radius: 10rpx;
  427. }
  428. }
  429. .layer-nunbox{
  430. justify-content: space-between;
  431. align-items: center;
  432. width: 510rpx;
  433. height: 88rpx;
  434. padding: 10rpx 0 0 0;
  435. float: left;
  436. .layer-nunbox-t{
  437. width: 100%;
  438. height:44rpx;
  439. position:relative;
  440. display: flex;
  441. margin-top: 10rpx;
  442. .layer-nunbox-text{
  443. line-height: 44rpx;
  444. font-size: $font-size-28;
  445. }
  446. .number-box{
  447. display: flex;
  448. justify-content: center;
  449. align-items: center;
  450. border: 2rpx solid #ffe6dc;
  451. border-radius: 30rpx;
  452. height: 48rpx;
  453. margin-left: 20rpx;
  454. .iconfont{
  455. font-size: $font-size-24;
  456. padding:0 18rpx;
  457. color: #999999;
  458. text-align: center;
  459. line-height: 48rpx;
  460. font-weight: bold;
  461. background: #fef6f3;
  462. &.icon-jianhao{
  463. border-radius: 30rpx 0 0 30rpx;
  464. }
  465. &.icon-jiahao{
  466. border-radius: 0 30rpx 30rpx 0;
  467. }
  468. }
  469. .btn-input{
  470. width: 80rpx;
  471. height: 48rpx;
  472. line-height: 48rpx;
  473. background: #FFFFFF;
  474. border-radius: 4rpx;
  475. text-align: center;
  476. font-size: $font-size-28;
  477. }
  478. }
  479. .product-step{
  480. position: absolute;
  481. left: 45rpx;
  482. bottom: 0;
  483. height: 44rpx;
  484. background: #FFFFFF;
  485. }
  486. }
  487. .layer-nunbox-b{
  488. width: 100%;
  489. height:44rpx;
  490. margin-top: 13rpx;
  491. }
  492. .text{
  493. line-height: 44rpx;
  494. font-size: $font-size-28;
  495. .p{
  496. color: #FF2A2A;
  497. }
  498. .p:first-child{
  499. margin-left: 30rpx;
  500. }
  501. .p.sm{
  502. font-size: $font-size-24;
  503. }
  504. }
  505. }
  506. }
  507. .zuhe .layer{
  508. bottom: -270rpx;
  509. height: 200rpx;
  510. }
  511. </style>