mixin.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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: 'productList',
  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. products: []
  36. }
  37. }
  38. },
  39. watch: {
  40. 'componentContent': {
  41. handler(newVal, oldVal) {
  42. this.getData()
  43. },
  44. deep: true
  45. }
  46. },
  47. created() {
  48. this.getData()
  49. },
  50. methods: {
  51. getData() {
  52. const _ = this
  53. let _url = ''
  54. if(_.typeId === 1){
  55. const params = {
  56. method: 'GET',
  57. url: `${api.getAdminGroupWorks}`,
  58. }
  59. this.sendReq(params, (res) => {
  60. _.productData.products = res.data
  61. if (_.productData.products.length > 2) {
  62. _.productData.show = true
  63. } else {
  64. _.productData.show = false
  65. }
  66. })
  67. } else if(_.typeId === 3) {
  68. if(_.componentContent.shopGroupWorkId){
  69. const params = {
  70. method: 'GET',
  71. url: `${api.getGroupWorks}?shopId=${_.shopId}&ids=${_.componentContent.shopGroupWorkId}`,
  72. }
  73. this.sendReq(params, (res) => {
  74. _.productData = res.data[0]
  75. })
  76. } else {
  77. _.productData = {
  78. products:[]
  79. }
  80. }
  81. }
  82. },
  83. }
  84. }