second.vue 11 KB

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