CartFooter.vue 4.1 KB

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