immediately.vue 11 KB

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