CartFooter.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <!-- CartFooter.vue -->
  2. <template>
  3. <view class="div ui-cart-footer" v-bind:class="{ 'has-bottom': issShowTabbar }">
  4. <checkbox-group @change="selectedAll" class="div list-checkbox">
  5. <checkbox
  6. class="checkbox"
  7. id="checkbox-all"
  8. value="1"
  9. :checked="isSelected"
  10. />
  11. <label class="label" :class="{'checked':isSelected}" for="checkbox-all"><text class="span iconfont">&#xe69b;</text></label>
  12. <text class="i" v-if="isCheckedAll">全选</text>
  13. <text v-if="!isCheckedAll" class="i total-price"
  14. >合计<text class="span"> {{ totalPrice }} </text></text
  15. >
  16. </checkbox-group>
  17. <text
  18. class="span cart-footer-btn remove"
  19. v-if="isCheckedAll"
  20. @click="deleteSelected()"
  21. >删除</text
  22. >
  23. <text
  24. class="span cart-footer-btn checkout"
  25. v-if="!isCheckedAll"
  26. @click="checkout"
  27. >结算({{ totalAmount }})</text
  28. >
  29. </view>
  30. </template>
  31. <script>
  32. import { urlencode } from '@/util/common'
  33. import { mapState, mapMutations } from 'vuex'
  34. export default {
  35. data () {
  36. return {
  37. isSelected: true,
  38. deleteGoods: []
  39. }
  40. },
  41. computed: mapState({
  42. }),
  43. props: {
  44. totalPrice: {},
  45. totalAmount: {},
  46. cartId: {},
  47. isCheckedAll: {
  48. type: Boolean,
  49. default: false
  50. },
  51. issShowTabbar: {
  52. type: Number,
  53. default: 0
  54. },
  55. isStatus: {
  56. type: Boolean,
  57. default: true
  58. }
  59. },
  60. watch: {
  61. isCheckedAll: function (value) {
  62. this.isSelected = !value
  63. },
  64. isStatus: function (value) {
  65. this.isSelected = value
  66. }
  67. },
  68. methods: {
  69. /*
  70. * selectedAll: 底部全选按钮的状态
  71. * @param: value 底部全选按钮的值
  72. */
  73. selectedAll (e) {
  74. var value=e.detail.value
  75. this.isSelected=value.length>0
  76. uni.$emit('cart-bottom-status', { isCheckAll: this.isSelected })
  77. },
  78. /*
  79. * deleteSelected: 删除购物车商品
  80. */
  81. deleteSelected () {
  82. uni.$emit('update-cart-list', { isdelete: true })
  83. },
  84. /*
  85. * checkout: 结算
  86. */
  87. checkout () {
  88. if (!this.isCheckedAll && this.totalAmount != 0) {
  89. uni.navigateTo({ url: '/pages/member/pointsbuy/step1'+'?'+urlencode( { 'cart_id': this.cartId } )})
  90. }
  91. }
  92. }
  93. }
  94. </script>
  95. <style lang="scss" scoped>
  96. .ui-cart-footer {
  97. position: relative;
  98. display: flex;
  99. justify-content: space-between;
  100. align-content: center;
  101. align-items: center;
  102. height:$footerHeight;
  103. padding-bottom: constant(safe-area-inset-bottom);/*兼容 IOS<11.2*/padding-bottom: env(safe-area-inset-bottom);/*兼容 IOS>11.2*/box-sizing: content-box;
  104. background: rgba(255, 255, 255, 1);
  105. padding-left:0.6rem;
  106. bottom: 0;
  107. position: fixed;
  108. width: -webkit-fill-available;
  109. box-shadow: 0px 4px 4px #f7f7f7;
  110. margin-bottom:1px;
  111. .list-checkbox {
  112. display: flex;
  113. align-items: center;
  114. flex-shrink: 0;
  115. position: relative;
  116. margin-right:0.25rem;
  117. height:$footerHeight;
  118. line-height: $footerHeight;
  119. .label {
  120. padding:0;
  121. position: absolute;
  122. top: 50%;
  123. margin-top:-.5rem;
  124. left: 0;
  125. width:1rem;
  126. height:1rem;
  127. display: inline-block;
  128. border-radius:50%;
  129. border:1px solid #333;
  130. box-sizing:border-box;
  131. .iconfont{display: none;line-height:1rem;text-align: center;}
  132. &.checked {
  133. border-color:$primaryColor;
  134. background-color:$primaryColor;
  135. .iconfont{display: block;color:#fff}
  136. }
  137. }
  138. .checkbox {
  139. position: relative;
  140. width: 1rem;
  141. height: 1rem;
  142. margin: 0;
  143. z-index: -999;
  144. background-color: #fff;
  145. opacity: 0;
  146. }
  147. .i {
  148. padding-left:0.6rem;
  149. font-style: normal;
  150. font-size:$subFontSize;
  151. &.total-price .span {
  152. color: $primaryColor;
  153. }
  154. }
  155. }
  156. .span.cart-footer-btn {
  157. width: 7.5rem;
  158. height:$footerHeight;
  159. display: inline-block;
  160. font-size:$subFontSize;
  161. color: rgba(255, 255, 255, 1);
  162. line-height:$footerHeight;
  163. text-align: center;
  164. cursor: pointer;
  165. font-weight: normal;
  166. }
  167. .checkout {
  168. background: $primaryColor;
  169. }
  170. .disable {
  171. background: #c3c3c3;
  172. }
  173. .remove {
  174. background: #f23030;
  175. }
  176. }
  177. .has-bottom {
  178. bottom:2.5rem;
  179. }
  180. </style>