secondDetail.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /**
  2. * Created by xw on 2020/7/22.
  3. */
  4. var fleaMarket = new Vue({
  5. el:"#fleaMarket",
  6. data: {
  7. tabIndex:0,
  8. userId:'',
  9. shopId:'',
  10. id: $("#productId").val(),
  11. isShow:false,
  12. isRequest:false,
  13. Showlogo:false,
  14. detail:{},
  15. previewBigimage:'',
  16. previewThumb:[],
  17. previewParams:[],
  18. recommdeImage:[],
  19. userID: GLOBAL_USER_ID,
  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. setTimeout(function(){
  39. if (isPC) {
  40. var magnifier = new ImageMagnifier(
  41. '#imgShown #CM____pic_thumb li'
  42. ,'#imgShown .bigImage'
  43. ,'#imgShown .preview-box'
  44. ,'#imgShown .mask'
  45. ,'#imgShown .bigitem'
  46. ,"on"
  47. ).init();
  48. } else {
  49. var swiper = new Swiper('#swiperImage', {
  50. loop : true,
  51. autoplay: {
  52. delay: 2000,
  53. disableOnInteraction: false
  54. },
  55. pagination: {
  56. el: '.swiper-pagination',
  57. type: 'fraction'
  58. }
  59. });
  60. }
  61. },500);
  62. }else {
  63. _this.isRequest =false;
  64. }
  65. _this.detail = res.data;
  66. _this.previewThumb = res.data.imageList;
  67. _this.previewBigimage =res.data.imageList[0];
  68. setTimeout(function(){ // 图片懒加载
  69. $("img[data-original]").lazyload();
  70. },500);
  71. if(_this.userID!=null){
  72. if(res.data.secondHandType ==2){ //临期产品显示
  73. _this.HandType =true;
  74. }else {
  75. _this.HandType =false;
  76. }
  77. }
  78. if(res.data.showContactFlag!=2){
  79. _this.ShowImage=true;
  80. }else {
  81. _this.ShowImage=false;
  82. }
  83. if(res.data.sold == 1){//sold是否出售 0未出售,1已出售
  84. _this.soldImage = true;
  85. }else {
  86. _this.soldImage = false;
  87. }
  88. if(res.data.brandName !=''&& res.data.brandName!=null){
  89. _this.bnameShow = true;
  90. if(res.data.brandID ==161){
  91. _this.vShow_brand = true;
  92. }else {
  93. _this.vShow_brand = false;
  94. }
  95. }else {
  96. _this.bnameShow = false;
  97. }
  98. if (res.data.detailTalkFlag ==1){ //是否详聊 1不开启,2开启
  99. _this.FlagTwo==true;
  100. }else {
  101. _this.FlagTwo==false;
  102. }
  103. if(res.data.brandInfo==null||res.data.brandInfo==""){
  104. _this.Showlogo = false;
  105. }else {
  106. _this.Showlogo = true;
  107. }
  108. })
  109. },
  110. changeActive:function(){
  111. var _this = this;
  112. _this.isShow = true;
  113. },
  114. removeActive:function(){
  115. var _this = this;
  116. _this.isShow = false;
  117. },
  118. ImgList:function(item,index){
  119. var _this = this;
  120. _this.current = index;
  121. _this.previewBigimage = item;
  122. },
  123. },
  124. created: function () {
  125. this.id = $("#productId").val();
  126. },
  127. mounted: function () {
  128. var _self = this;
  129. _self.InfoData();
  130. SecondApi.ProductRecommend({productId:_self.id},function (res) {
  131. if(res.code==0){
  132. console.log(res)
  133. if(res.data.length > 0){
  134. _self.recommdeImage = res.data;
  135. _self.recommde =true;
  136. }else {
  137. _self.recommde =false;
  138. }
  139. if(res.data.length<7){
  140. var length = 7-res.data.length;
  141. _self.recommdeindex = length;
  142. }else {
  143. var remainderres=res.data.length%7;
  144. _self.recommdeindex= 7-remainderres;
  145. console.log(_self.recommdeindex)
  146. }
  147. self.recommendPage = isPC ? Math.ceil(res.data.length / 7) : Math.ceil(res.data.length / 3);
  148. setTimeout(function(){
  149. if (isPC) {
  150. $('#productRecommend').slide({
  151. mainCell:".swiper-wrapper"
  152. ,titCell:".swiper-pagination span"
  153. ,effect: "leftLoop"
  154. ,interTime: 3000
  155. ,autoPlay: true
  156. ,scroll:7
  157. ,vis:7
  158. ,trigger: "mouseover"
  159. });
  160. } else {
  161. var swiper = new Swiper('#productRecommend', {
  162. slidesPerView: 3,
  163. spaceBetween: 0,
  164. autoplay: {
  165. delay: 3000,
  166. disableOnInteraction: false
  167. },
  168. pagination: {
  169. el: '.swiper-pagination'
  170. }
  171. });
  172. }
  173. },500);
  174. }
  175. });
  176. SecondApi.ProductCount({productId: _self.id},function (res) {
  177. if(res.code==0){
  178. console.log(res)
  179. }else {
  180. console.log(res)
  181. }
  182. });
  183. //相關推薦輪播
  184. // var mySwiper = new Swiper('#productRecommend',{
  185. // slidesPerView: 7,
  186. // spaceBetween: 12,
  187. // slidesPerGroup: 7,
  188. // autoplay: {
  189. // delay:10000,
  190. // disableOnInteraction: false,//是否禁止autoplay。默认为true:停止。
  191. // },
  192. // loop: false,
  193. // observer: true, //修改swiper自己或子元素时,自动初始化swiper
  194. // observeParents: true, //修改swiper的父元素时,自动初始化swiper
  195. // pagination: {
  196. // el: '.swiper-pagination',
  197. // clickable: true,
  198. // },
  199. // on:{
  200. // init:function() {
  201. // var length = this.slides.length;
  202. // if(length < 8) {
  203. // this.autoplay.stop();
  204. // }
  205. // }
  206. // }
  207. // })
  208. }
  209. });