settleBottomBtn.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view class="container">
  3. <view class="item-box">
  4. <view class="item-left">
  5. <image class="img" src="@/static/images/shopCarts.png"></image>
  6. <view class="edge-box">
  7. <u-badge class="edge" type="warning" max="99" :value="allNumb"></u-badge>
  8. </view>
  9. <view class="left-price">
  10. <p class="price">
  11. <span class="price-symbal">¥</span><span class="price-text1">{{ allPrice }}</span>
  12. <span class="price-text2">¥219</span>
  13. </p>
  14. </view>
  15. </view>
  16. <view class="item-right" @click="handlerSettleBtn"> 去结算 </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import {
  22. addShoppingCart
  23. } from '@/api/client/business.js';
  24. export default {
  25. data() {
  26. return {}
  27. },
  28. props: {
  29. goodsCateList: {
  30. type: Array,
  31. default: []
  32. },
  33. ids:{
  34. type:String,
  35. default:''
  36. }
  37. },
  38. computed: {
  39. allPrice() {
  40. let sum = 0
  41. this.goodsCateList.map(rs => {
  42. sum += Number((rs.price).toFixed(2))
  43. })
  44. console.log('@@@@sum', sum);
  45. return sum
  46. },
  47. allNumb() {
  48. return this.goodsCateList.length
  49. }
  50. },
  51. methods: {
  52. // 结算按钮
  53. handlerSettleBtn() {
  54. this.goodsCateList.map(rs => {
  55. addShoppingCart(rs).then(res => {
  56. if (res.code == 200) {
  57. wx.showLoading({
  58. title: '结算中',
  59. })
  60. } else {
  61. uni.showToast({
  62. title: res.message,
  63. icon: 'none'
  64. })
  65. return
  66. }
  67. })
  68. })
  69. setTimeout(()=>{
  70. wx.hideLoading()
  71. this.goodsCateList = []
  72. uni.navigateTo({
  73. url:`/pages/client/clientPackage/uptickOrder?ids=${this.ids}`
  74. })
  75. },1500)
  76. }
  77. }
  78. }
  79. </script>
  80. <style lang="scss" scoped>
  81. .container {
  82. .item-box {
  83. width: 90%;
  84. height: 80rpx;
  85. margin: 0 auto;
  86. display: flex;
  87. .item-left {
  88. background-color: #222426;
  89. width: 80%;
  90. border-radius: 40rpx 0 0 40rpx;
  91. display: flex;
  92. align-items: center;
  93. position: relative;
  94. .img {
  95. position: absolute;
  96. width: 130rpx;
  97. height: 130rpx;
  98. left: 9%;
  99. top: -70%;
  100. }
  101. .edge-box {
  102. position: absolute;
  103. left: 25%;
  104. top: -55%;
  105. }
  106. .left-price {
  107. margin-left: 30%;
  108. .price {
  109. color: #fff;
  110. font-size: 28rpx;
  111. font-weight: bold;
  112. .price-symbal {
  113. font-size: 28rpx;
  114. }
  115. .price-text1 {
  116. font-size: 34rpx;
  117. }
  118. .price-text2 {
  119. font-size: 24rpx;
  120. color: #999999;
  121. font-style: italic;
  122. text-decoration: line-through;
  123. }
  124. }
  125. }
  126. }
  127. .item-right {
  128. background-color: #FFE339;
  129. width: 20%;
  130. border-radius: 0 40rpx 40rpx 0;
  131. color: #000;
  132. font-size: 30rpx;
  133. font-weight: bold;
  134. display: flex;
  135. align-items: center;
  136. justify-content: center;
  137. }
  138. }
  139. }
  140. </style>