secondDetail.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /**
  2. * Created by xw on 2020/7/22.
  3. */
  4. var previewContainer = new Vue({
  5. el:"#fleaMarket",
  6. data: {
  7. tabIndex:0,
  8. userId:'',
  9. shopId:'',
  10. id:window.location.href.split('=')[1],
  11. isShow:false,
  12. isRequest:false,
  13. Showlogo:false,
  14. detail:{},
  15. previewBigimage:'',
  16. previewThumb:[],
  17. previewParams:[],
  18. recommdeImage:[],
  19. userID:JSON.parse(localStorage.getItem('userInfo')),
  20. HandType:false,
  21. ShowImage:false,
  22. recommde:false,
  23. soldImage:false,
  24. vShow_brand:false,
  25. bnameShow:false,
  26. FlagTwo:false,
  27. recommdeindex:0,
  28. current:0,
  29. },
  30. computed: {
  31. },
  32. methods: {
  33. InfoData: function(){
  34. var _this = this;
  35. SecondApi.ProductDetail({productId:_this.id},function (res) {
  36. if(res.code==0){
  37. _this.isRequest =true;
  38. }else {
  39. _this.isRequest =false;
  40. }
  41. _this.detail = res.data;
  42. _this.previewThumb = res.data.imageList;
  43. _this.previewBigimage =res.data.imageList[0];
  44. if(_this.userID!=null){
  45. if(res.data.secondHandType ==2){ //临期产品显示
  46. _this.HandType =true;
  47. }else {
  48. _this.HandType =false;
  49. }
  50. }
  51. if(res.data.showContactFlag!=2){
  52. _this.ShowImage=true;
  53. }else {
  54. _this.ShowImage=false;
  55. }
  56. if(res.data.sold == 1){//sold是否出售 0未出售,1已出售
  57. _this.soldImage = true;
  58. }else {
  59. _this.soldImage = false;
  60. }
  61. if(res.data.brandName !=''&& res.data.brandName!=null){
  62. _this.bnameShow = true;
  63. if(res.data.brandID ==161){
  64. _this.vShow_brand = true;
  65. }else {
  66. _this.vShow_brand = false;
  67. }
  68. }else {
  69. _this.bnameShow = false;
  70. }
  71. if (res.data.detailTalkFlag ==1){ //是否详聊 1不开启,2开启
  72. _this.FlagTwo==true;
  73. }else {
  74. _this.FlagTwo==false;
  75. }
  76. if(res.data.brandInfo==null||res.data.brandInfo==""){
  77. _this.Showlogo = false;
  78. }else {
  79. _this.Showlogo = true;
  80. }
  81. })
  82. },
  83. changeActive:function(){
  84. var _this = this;
  85. _this.isShow = true;
  86. },
  87. removeActive:function(){
  88. var _this = this;
  89. _this.isShow = false;
  90. },
  91. ImgList:function(item,index){
  92. var _this = this;
  93. _this.current = index;
  94. _this.previewBigimage = item;
  95. },
  96. },
  97. mounted: function () {
  98. var _this = this;
  99. _this.InfoData();
  100. SecondApi.ProductRecommend({productId:_this.id},function (res) {
  101. if(res.code==0){
  102. console.log(res)
  103. if(res.data.length > 0){
  104. _this.recommdeImage = res.data;
  105. _this.recommde =true;
  106. }else {
  107. _this.recommde =false;
  108. }
  109. if(res.data.length<7){
  110. var length = 7-res.data.length;
  111. _this.recommdeindex = length;
  112. }else {
  113. var remainderres=res.data.length%7;
  114. _this.recommdeindex= 7-remainderres;
  115. console.log(_this.recommdeindex)
  116. }
  117. }
  118. });
  119. SecondApi.ProductCount({productId: _this.id},function (res) {
  120. if(res.code==0){
  121. console.log(res)
  122. }else {
  123. console.log(res)
  124. }
  125. });
  126. //相關推薦輪播
  127. var mySwiper = new Swiper('.swiper-container',{
  128. slidesPerView: 7,
  129. spaceBetween: 18,
  130. slidesPerGroup: 7,
  131. autoplay: {
  132. delay:10000,
  133. disableOnInteraction: false,//是否禁止autoplay。默认为true:停止。
  134. },
  135. loop: false,
  136. observer: true, //修改swiper自己或子元素时,自动初始化swiper
  137. observeParents: true, //修改swiper的父元素时,自动初始化swiper
  138. pagination: {
  139. el: '.swiper-pagination',
  140. clickable: true,
  141. },
  142. on:{
  143. init:function() {
  144. var length = this.slides.length;
  145. if(length < 8) {
  146. this.autoplay.stop();
  147. }
  148. }
  149. }
  150. })
  151. }
  152. });