123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- /**
- * Created by xw on 2020/7/22.
- */
- var fleaMarket = new Vue({
- el:"#fleaMarket",
- data: {
- tabIndex:0,
- userId:'',
- shopId:'',
- id: $("#productId").val(),
- isShow:false,
- isRequest:false,
- Showlogo:false,
- detail:{},
- previewBigimage:'',
- previewThumb:[],
- previewParams:[],
- recommdeImage:[],
- userID: GLOBAL_USER_ID,
- HandType:false,
- ShowImage:false,
- recommde:false,
- soldImage:false,
- vShow_brand:false,
- bnameShow:false,
- FlagTwo:false,
- recommdeindex:0,
- current:0,
- },
- computed: {
- },
- methods: {
- InfoData: function(){
- var _this = this;
- SecondApi.ProductDetail({productId:_this.id},function (res) {
- if(res.code==0){
- _this.isRequest =true;
- setTimeout(function(){
- if (isPC) {
- var magnifier = new ImageMagnifier(
- '#imgShown #CM____pic_thumb li'
- ,'#imgShown .bigImage'
- ,'#imgShown .preview-box'
- ,'#imgShown .mask'
- ,'#imgShown .bigitem'
- ,"on"
- ).init();
- } else {
- var swiper = new Swiper('#swiperImage', {
- loop : true,
- autoplay: {
- delay: 2000,
- disableOnInteraction: false
- },
- pagination: {
- el: '.swiper-pagination',
- type: 'fraction'
- }
- });
- }
- },500);
- }else {
- _this.isRequest =false;
- }
- _this.detail = res.data;
- _this.previewThumb = res.data.imageList;
- _this.previewBigimage =res.data.imageList[0];
- setTimeout(function(){ // 图片懒加载
- $("img[data-original]").lazyload();
- },500);
- if(_this.userID!=null){
- if(res.data.secondHandType ==2){ //临期产品显示
- _this.HandType =true;
- }else {
- _this.HandType =false;
- }
- }
- if(res.data.showContactFlag!=2){
- _this.ShowImage=true;
- }else {
- _this.ShowImage=false;
- }
- if(res.data.sold == 1){//sold是否出售 0未出售,1已出售
- _this.soldImage = true;
- }else {
- _this.soldImage = false;
- }
- if(res.data.brandName !=''&& res.data.brandName!=null){
- _this.bnameShow = true;
- if(res.data.brandID ==161){
- _this.vShow_brand = true;
- }else {
- _this.vShow_brand = false;
- }
- }else {
- _this.bnameShow = false;
- }
- if (res.data.detailTalkFlag ==1){ //是否详聊 1不开启,2开启
- _this.FlagTwo==true;
- }else {
- _this.FlagTwo==false;
- }
- if(res.data.brandInfo==null||res.data.brandInfo==""){
- _this.Showlogo = false;
- }else {
- _this.Showlogo = true;
- }
- })
- },
- changeActive:function(){
- var _this = this;
- _this.isShow = true;
- },
- removeActive:function(){
- var _this = this;
- _this.isShow = false;
- },
- ImgList:function(item,index){
- var _this = this;
- _this.current = index;
- _this.previewBigimage = item;
- },
- },
- created: function () {
- this.id = $("#productId").val();
- },
- mounted: function () {
- var _self = this;
- _self.InfoData();
- SecondApi.ProductRecommend({productId:_self.id},function (res) {
- if(res.code==0){
- console.log(res)
- if(res.data.length > 0){
- _self.recommdeImage = res.data;
- _self.recommde =true;
- }else {
- _self.recommde =false;
- }
- if(res.data.length<7){
- var length = 7-res.data.length;
- _self.recommdeindex = length;
- }else {
- var remainderres=res.data.length%7;
- _self.recommdeindex= 7-remainderres;
- console.log(_self.recommdeindex)
- }
- self.recommendPage = isPC ? Math.ceil(res.data.length / 7) : Math.ceil(res.data.length / 3);
- setTimeout(function(){
- if (isPC) {
- $('#productRecommend').slide({
- mainCell:".swiper-wrapper"
- ,titCell:".swiper-pagination span"
- ,effect: "leftLoop"
- ,interTime: 3000
- ,autoPlay: true
- ,scroll:7
- ,vis:7
- ,trigger: "mouseover"
- });
- } else {
- var swiper = new Swiper('#productRecommend', {
- slidesPerView: 3,
- spaceBetween: 0,
- autoplay: {
- delay: 3000,
- disableOnInteraction: false
- },
- pagination: {
- el: '.swiper-pagination'
- }
- });
- }
- },500);
- }
- });
- SecondApi.ProductCount({productId: _self.id},function (res) {
- if(res.code==0){
- console.log(res)
- }else {
- console.log(res)
- }
- });
- //相關推薦輪播
- // var mySwiper = new Swiper('#productRecommend',{
- // slidesPerView: 7,
- // spaceBetween: 12,
- // slidesPerGroup: 7,
- // autoplay: {
- // delay:10000,
- // disableOnInteraction: false,//是否禁止autoplay。默认为true:停止。
- // },
- // loop: false,
- // observer: true, //修改swiper自己或子元素时,自动初始化swiper
- // observeParents: true, //修改swiper的父元素时,自动初始化swiper
- // pagination: {
- // el: '.swiper-pagination',
- // clickable: true,
- // },
- // on:{
- // init:function() {
- // var length = this.slides.length;
- // if(length < 8) {
- // this.autoplay.stop();
- // }
- // }
- // }
- // })
- }
- });
|