immediately.vue 11 KB

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