多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
4.4 KiB

2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
  1. // import { directive, Swiper, SwiperSlide } from 'vue-awesome-swiper'
  2. // import 'swiper/css/swiper.css'
  3. import {funMixin} from '../../config/mixin'
  4. import api from '../../config/api'
  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: [1,2,3,4],
  35. loading:true,
  36. isFirst:true
  37. }
  38. },
  39. watch: {
  40. 'componentContent': {
  41. handler(newVal, oldVal) {
  42. this.getData()
  43. },
  44. deep: true
  45. }
  46. },
  47. created() {
  48. this.getData(true)
  49. },
  50. computed: {
  51. swiper() {
  52. if(this.$refs.mySwiper){
  53. return this.$refs.mySwiper.$swiper
  54. }
  55. }
  56. },
  57. methods: {
  58. getData() {
  59. const _ = this
  60. // 纵向
  61. _.loading=true
  62. if (_.componentContent.productData.sourceType === '1') {
  63. if(_.componentContent.productData.productIdList && _.componentContent.productData.productIdList.length>0){
  64. _.sendReq({
  65. url: `${api.getProductsV2}?page=1&pageSize=99&ids=${_.componentContent.productData.productIdList}`,
  66. method: 'GET'
  67. }, (proRes) => {
  68. _.productData = proRes.data.list
  69. if(_.isFirst){
  70. _.componentContent.productData.imgTextData = _.productData
  71. }
  72. _.isFirst = false
  73. _.loading = false
  74. })
  75. } else {
  76. _.productData = []
  77. _.isFirst = false
  78. _.loading = false
  79. }
  80. } else if(_.componentContent.productData.sourceType === '2'){
  81. if(_.componentContent.productData.categoryId) {
  82. _.sendReq({
  83. url: `${api.getProductsV2}?page=1&pageSize=99&classifyId=${_.componentContent.productData.categoryId}`,
  84. method: 'GET'
  85. }, (proRes) => {
  86. _.productData = proRes.data.list
  87. _.productData = _.productData.filter(item=>JSON.stringify(item) !== '{}')
  88. if(_.isFirst){
  89. _.componentContent.productData.imgTextData = _.productData
  90. }
  91. // _.swiper.update()
  92. })
  93. } else {
  94. _.productData = {
  95. products:[]
  96. }
  97. }
  98. }else if(_.componentContent.productData.sourceType === '3'){
  99. _.sendReq({
  100. url: `${api.getProductsV2}?page=1&pageSize=20&type=4`,
  101. method: 'GET'
  102. }, (proRes) => {
  103. _.productData = proRes.data.list
  104. _.productData = _.productData.filter(item=>JSON.stringify(item) !== '{}')
  105. if(_.isFirst){
  106. _.componentContent.productData.imgTextData = _.productData
  107. }
  108. _.isFirst = false
  109. _.loading = false
  110. })
  111. }else if(_.componentContent.productData.sourceType === '4'){
  112. _.sendReq({
  113. url: `${api.getProductsV2}?page=1&pageSize=20&type=5`,
  114. method: 'GET'
  115. }, (proRes) => {
  116. _.productData = proRes.data.list
  117. _.productData = _.productData.filter(item=>JSON.stringify(item) !== '{}')
  118. if(_.isFirst){
  119. _.componentContent.productData.imgTextData = _.productData
  120. }
  121. _.isFirst = false
  122. _.loading = false
  123. })
  124. }else if(_.componentContent.productData.sourceType === '5'){
  125. _.sendReq({
  126. url: `${api.getProductsV2}?page=1&pageSize=20&type=6`,
  127. method: 'GET'
  128. }, (proRes) => {
  129. _.productData = proRes.data.list
  130. _.productData = _.productData.filter(item=>JSON.stringify(item) !== '{}')
  131. if(_.isFirst){
  132. _.componentContent.productData.imgTextData = _.productData
  133. }
  134. _.isFirst = false
  135. _.loading = false
  136. })
  137. }else if(_.componentContent.productData.sourceType === '6'){
  138. _.sendReq({
  139. url: `${api.getProductsV2}?page=1&pageSize=6&type=7`,
  140. method: 'GET'
  141. }, (proRes) => {
  142. _.productData = proRes.data.list
  143. _.productData = _.productData.filter(item=>JSON.stringify(item) !== '{}')
  144. if(_.isFirst){
  145. _.componentContent.productData.imgTextData = _.productData
  146. }
  147. _.isFirst = false
  148. _.loading = false
  149. })
  150. }
  151. },
  152. }
  153. }