second.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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.secondProductType == 2){
  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. }else{
  110. this.isStock =true
  111. this.$util.msg(`该商品购买数量只能为1`,2000);
  112. }
  113. },
  114. changeCountSub(){//popup弹窗数量减按钮
  115. if(this.handleData.secondProductType == 2){
  116. if(this.number < 1){
  117. this.number= 1
  118. this.isQuantity =true
  119. this.$util.msg(`购买数量最低为1`,2000);
  120. return
  121. }else{
  122. this.number--
  123. this.isQuantity =false
  124. }
  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. clearProduct(){//成功加入购物车后清空所选值
  145. this.handleData.productKind= 0;
  146. this.handleData.productTotalNum = 0;
  147. this.handleData.productTotalAmount = 0;
  148. this.handleData.combinationProductList.forEach(item =>{
  149. item.initProductNum = 0;
  150. })
  151. },
  152. toConfirmation(){//跳转确认订单页面
  153. this.specClass = 'hide';
  154. let cartPramsData={
  155. clubId:this.clubID,
  156. allPrice:this.number*this.buyRetailPrice,
  157. allCount:this.number,
  158. productID:this.handleData.productID,
  159. productCount:this.number
  160. }
  161. this.$api.navigateTo(`/seller/pages/order/create-order?type=prodcut&data=${JSON.stringify({data:cartPramsData})}`)
  162. setTimeout(() => {
  163. this.specClass = 'none';
  164. }, 200);
  165. },
  166. hanldToCartPage(){
  167. this.$api.navigateTo('/seller/pages/cart/cart')
  168. },
  169. discard(){
  170. //丢弃
  171. }
  172. },
  173. onShow() {
  174. this.$api.getComStorage('orderUserInfo').then((resolve) =>{
  175. this.clubID = resolve.clubID
  176. })
  177. this.$api.getStorage().then((resolve) =>{
  178. this.serviceProviderId = resolve.serviceProviderID
  179. this.getClubProductNum()
  180. })
  181. },
  182. }
  183. </script>
  184. <style lang="scss">
  185. // 阶梯价格弹窗
  186. .jieti_box{
  187. width: 596rpx;
  188. // height: 496rpx;
  189. top: 10%;
  190. right: 50%;
  191. transform: translate(50%,50%);
  192. position: absolute;
  193. background:#FFFFFF;
  194. color: #000;
  195. font-size: 28rpx;
  196. border-radius: 10rpx;
  197. text-align: center;
  198. line-height: 84rpx;
  199. padding: 20rpx;
  200. z-index: 99999;
  201. }
  202. .jieti_box_one{
  203. // width: 548rpx;
  204. overflow: hidden;
  205. border: 2rpx solid #F5F5F5;
  206. border-bottom: 0;
  207. margin: auto;
  208. }
  209. .jieti_left{
  210. width: 298rpx;
  211. float: left;
  212. }
  213. .jieti_left view{
  214. height: 84rpx;
  215. border-bottom:2rpx solid #F5F5F5 ;
  216. border-right:2rpx solid #F5F5F5 ;
  217. }
  218. .ladder-a{
  219. letter-spacing: 4rpx;
  220. }
  221. .jieti_right{
  222. width: 294rpx;
  223. float: right;
  224. }
  225. .jieti_right view{
  226. height: 84rpx;
  227. border-bottom:2rpx solid #F5F5F5;
  228. }
  229. .addbtn{
  230. height: 84rpx;
  231. background: linear-gradient(135deg,rgba(242,143,49,1) 0%,rgba(225,86,22,1) 100%);
  232. text-align: center;
  233. font-size: 28rpx;
  234. color: #fff;
  235. line-height: 84rpx;
  236. border-radius: 10rpx;
  237. margin: 20rpx auto
  238. }
  239. .zuhe-content{
  240. display: inline-block;
  241. }
  242. .number-left{
  243. float: left;
  244. }
  245. .number-right{
  246. margin-left: 30rpx;
  247. float: left;
  248. }
  249. .number-left text{
  250. margin-left: 30rpx;
  251. }
  252. .number-right-text{
  253. color: #FF2A2A;
  254. }
  255. page {
  256. background: $sub-bg-color;
  257. .all-type-list-wrapper {
  258. display: flex;
  259. flex-direction: column;
  260. }
  261. }
  262. /* 加入购物模态层*/
  263. @keyframes showPopup {
  264. 0% {
  265. opacity: 0;
  266. }
  267. 100% {
  268. opacity: 1;
  269. }
  270. }
  271. @keyframes hidePopup {
  272. 0% {
  273. opacity: 1;
  274. }
  275. 100% {
  276. opacity: 0;
  277. }
  278. }
  279. @keyframes showLayer {
  280. 0% {
  281. transform: translateY(0);
  282. }
  283. 100% {
  284. transform: translateY(-100%);
  285. }
  286. }
  287. @keyframes hideLayer {
  288. 0% {
  289. transform: translateY(-100%);
  290. }
  291. 100% {
  292. transform: translateY(0);
  293. }
  294. }
  295. @keyframes showAmnation {
  296. 0% {
  297. top: -12rpx;
  298. opacity: 0;
  299. }
  300. 50% {
  301. top: -60rpx;
  302. opacity: 1;
  303. }
  304. 100% {
  305. top: -100rpx;
  306. opacity: 0;
  307. }
  308. }
  309. @keyframes hideAmnation {
  310. 0% {
  311. top: -100rpx;
  312. opacity: 0;
  313. }
  314. 100% {
  315. top: -12rpx;
  316. opacity: 0;
  317. }
  318. }
  319. .popup {
  320. position: fixed;
  321. top: 0;
  322. width: 100%;
  323. height: 100%;
  324. z-index: 999;
  325. display: none;
  326. .mask{
  327. position: fixed;
  328. top: 0;
  329. width: 100%;
  330. height: 100%;
  331. z-index: 21;
  332. background-color: rgba(0, 0, 0, 0.6);
  333. }
  334. .layer {
  335. position: fixed;
  336. z-index: 22;
  337. bottom: -360rpx;
  338. width: 702rpx;
  339. padding: 24rpx 24rpx 36rpx 24rpx;
  340. // height: 236rpx;
  341. border-radius: 20rpx 20rpx 0 0;
  342. background-color: #fff;
  343. display: flex;
  344. flex-wrap: wrap;
  345. align-content: space-between;
  346. .content {
  347. width: 100%;
  348. margin-top: 20rpx;
  349. }
  350. .btn {
  351. width: 100%;
  352. // height: 88rpx;
  353. display: flex;
  354. .button {
  355. width: 702rpx;
  356. height: 88rpx;
  357. color: #fff;
  358. display: flex;
  359. align-items: center;
  360. justify-content: center;
  361. font-size: $font-size-28;
  362. border-radius: 14rpx;
  363. background: $btn-confirm;
  364. margin-top: 20rpx;
  365. }
  366. }
  367. }
  368. .layer-nunbox-m{
  369. font-size: 28rpx;
  370. }
  371. &.show {
  372. display: block;
  373. .mask{
  374. animation: showPopup 0.2s linear both;
  375. }
  376. .layer {
  377. animation: showLayer 0.2s linear both;
  378. }
  379. }
  380. &.hide {
  381. display: block;
  382. .mask{
  383. animation: hidePopup 0.2s linear both;
  384. }
  385. .layer {
  386. animation: hideLayer 0.2s linear both;
  387. }
  388. }
  389. &.none {
  390. display: none;
  391. }
  392. &.service {
  393. .row {
  394. margin: 30upx 0;
  395. .title {
  396. font-size: 30upx;
  397. margin: 10upx 0;
  398. }
  399. .description {
  400. font-size: 28upx;
  401. color: #999;
  402. }
  403. }
  404. }
  405. .layer-smimg{
  406. width: 158rpx;
  407. height: 158rpx;
  408. float: left;
  409. border-radius: 10rpx;
  410. margin-right: 24rpx;
  411. image{
  412. width: 158rpx;
  413. height: 158rpx;
  414. border-radius: 10rpx;
  415. }
  416. }
  417. .layer-nunbox{
  418. justify-content: space-between;
  419. align-items: center;
  420. width: 510rpx;
  421. height: 88rpx;
  422. padding: 10rpx 0 0 0;
  423. float: left;
  424. .layer-nunbox-t{
  425. width: 100%;
  426. height:44rpx;
  427. position:relative;
  428. display: flex;
  429. margin-top: 10rpx;
  430. .layer-nunbox-text{
  431. line-height: 44rpx;
  432. font-size: $font-size-28;
  433. }
  434. .number-box{
  435. display: flex;
  436. justify-content: center;
  437. align-items: center;
  438. .iconfont{
  439. font-size: $font-size-32;
  440. padding:0 20rpx;
  441. font-size: $text-color;
  442. }
  443. .btn-input{
  444. width: 100rpx;
  445. height: 48rpx;
  446. line-height: 48rpx;
  447. background: #F8F8F8;
  448. border-radius: 4rpx;
  449. text-align: center;
  450. font-size: $font-size-28;
  451. }
  452. }
  453. .product-step{
  454. position: absolute;
  455. left: 45rpx;
  456. bottom: 0;
  457. height: 44rpx;
  458. background: #FFFFFF;
  459. }
  460. }
  461. .layer-nunbox-b{
  462. width: 100%;
  463. height:44rpx;
  464. margin-top: 13rpx;
  465. }
  466. .text{
  467. line-height: 44rpx;
  468. font-size: $font-size-28;
  469. .p{
  470. color: #FF2A2A;
  471. }
  472. .p:first-child{
  473. margin-left: 30rpx;
  474. }
  475. .p.sm{
  476. font-size: $font-size-24;
  477. }
  478. }
  479. }
  480. }
  481. .zuhe .layer{
  482. bottom: -270rpx;
  483. height: 200rpx;
  484. }
  485. </style>