app-cart-image.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <view class="bd-image" :style="cartStyle" :class="cartClass"></view>
  3. </template>
  4. <script>
  5. import {mapGetters} from "vuex";
  6. export default {
  7. name: "app-cart-image",
  8. data() {
  9. return {
  10. is_loading: false,
  11. disable: 'disable'
  12. }
  13. },
  14. props: {
  15. imageWidth: {
  16. type: String,
  17. default: '36rpx'
  18. },
  19. imageHeight: {
  20. type: String,
  21. default: '36rpx'
  22. },
  23. src: {
  24. type: String,
  25. default: '/static/image/icon/goods-cart.png'
  26. },
  27. sign: String,
  28. theme: String,
  29. goods: {
  30. type: Object|null,
  31. default: null,
  32. }
  33. },
  34. computed: {
  35. ...mapGetters('mallConfig', {
  36. getTheme: 'getTheme',
  37. }),
  38. cartStyle() {
  39. let style = `width: ${this.imageWidth};height: ${this.imageHeight};`;
  40. if((!this.goods || this.goods.buy_goods_auth) && this.sign !== 'gift') {
  41. style += `background-color : ${this.getTheme.background}`
  42. }
  43. return style;
  44. },
  45. cartClass() {
  46. if (!this.goods || this.goods.buy_goods_auth) {
  47. return this.sign !== 'gift' ? '' : this.theme + '-background';
  48. } else {
  49. return this.disable + '-m-back ' + this.disable;
  50. }
  51. }
  52. },
  53. methods: {
  54. imgLoad() {
  55. this.is_loading = true;
  56. }
  57. }
  58. }
  59. </script>
  60. <style scoped>
  61. .bd-image {
  62. background-repeat: no-repeat;
  63. background-size: 101% 101%;
  64. background-image:url("../../../static/image/icon/goods-cart.png");
  65. }
  66. </style>