mixin.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import { directive, Swiper, SwiperSlide } from 'vue-awesome-swiper'
  2. import 'swiper/css/swiper.css'
  3. import api from '../../config/api'
  4. import {funMixin} from '../../config/mixin'
  5. export const commonMixin = {
  6. name: 'price',
  7. mixins: [funMixin],
  8. props: {
  9. terminal: {
  10. type: Number,
  11. default: 4
  12. },
  13. typeId: {
  14. type: Number,
  15. default: 1
  16. },
  17. shopId: {
  18. type: Number,
  19. default: 0
  20. },
  21. componentContent: {
  22. type: Object
  23. }
  24. },
  25. components: {
  26. Swiper,
  27. SwiperSlide
  28. },
  29. directives: {
  30. swiper: directive
  31. },
  32. data () {
  33. return {
  34. productData: {
  35. composeProducts: [],
  36. rules: []
  37. }
  38. }
  39. },
  40. watch: {
  41. 'componentContent': {
  42. handler(newVal, oldVal) {
  43. this.getData()
  44. },
  45. deep: true
  46. }
  47. },
  48. created() {
  49. this.getData()
  50. },
  51. methods: {
  52. getData() {
  53. const _ = this
  54. if(_.componentContent.priceId){
  55. const params = {
  56. method: 'GET',
  57. url: `${api.getPrices}?shopId=${_.shopId}&ids=${_.componentContent.priceId}&page=1&pageSize=10`,
  58. }
  59. this.sendReq(params, (res) => {
  60. if( res.data.length > 0){
  61. _.productData = res.data[0]
  62. }
  63. })
  64. } else {
  65. _.productData = {
  66. composeProducts: [],
  67. rules: []
  68. }
  69. }
  70. },
  71. }
  72. }