app-add-subtract.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <view class="app-add-subtract dir-left-nowrap main-right cross-center">
  3. <image src="/static/image/quick-shop/subtract.png" class="app-icon" v-if="total_num > 0 " @click="subtract"></image>
  4. <input class="app-input" v-if="total_num >= 0 " :value="total_num === 0 ? '' : total_num" @input="changeNum" type="number">
  5. <image class="app-icon" v-show="loading" @load="imgLoad" src="/static/image/quick-shop/add.png" :style="{'background-color': theme.background}" @click="add"></image>
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. name: 'app-add-subtract',
  11. props: {
  12. total_num: {
  13. type: Number,
  14. default: function() {
  15. return 0;
  16. }
  17. },
  18. item: {
  19. type: Object,
  20. default: function() {
  21. return {}
  22. }
  23. },
  24. theme: Object
  25. },
  26. data() {
  27. return {
  28. loading: false
  29. }
  30. },
  31. methods: {
  32. add() {
  33. this.$emit('add', this.item);
  34. },
  35. subtract() {
  36. this.$emit('subtract', this.item);
  37. },
  38. changeNum(e) {
  39. this.$emit('changeNum', this.item, Number(e.detail.value));
  40. },
  41. imgLoad() {
  42. this.loading = true;
  43. }
  44. }
  45. }
  46. </script>
  47. <style scoped lang="scss">
  48. .app-add-subtract {
  49. width: #{152rpx};
  50. height: #{44rpx};
  51. .app-icon {
  52. width: #{44rpx};
  53. height: #{44rpx};
  54. }
  55. .app-input {
  56. width: #{64rpx};
  57. height: #{44rpx};
  58. font-size: #{28rpx};
  59. color: #353535;
  60. text-align: center;
  61. background-color: #ffffff;
  62. }
  63. }
  64. </style>