temporary.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. var instrueMent = new Vue({
  2. el:'#instrueMent',
  3. data:{
  4. listLoading:true,
  5. categorylist:[],
  6. hotlist:[],
  7. recommendPage: 1,
  8. floorList: [],
  9. userId:0,
  10. typeSort:'',
  11. showflag:false,
  12. params:{
  13. pageId:'',
  14. userId:'',
  15. source:1
  16. },
  17. nav_linkName:''
  18. },
  19. filters:{
  20. NumFormat:function(value) {//处理金额
  21. return Number(value).toFixed(2);
  22. },
  23. },
  24. created: function() {
  25. },
  26. methods:{
  27. PromotionsFormat:function(promo){//促销活动类型数据处理
  28. if(promo!=null){
  29. if(promo.type == 1 && promo.mode == 1){
  30. return true
  31. }else{
  32. return false
  33. }
  34. }
  35. return false
  36. },
  37. closeup:function(){
  38. this.showflag = false;
  39. document.body.style.overflow='';
  40. },
  41. showNav:function(){
  42. var _this = this;
  43. _this.showflag = !_this.showflag;
  44. if (_this.showflag){
  45. document.body.style.overflow='hidden';
  46. }else {
  47. document.body.style.overflow='';
  48. }
  49. },
  50. toserch:function(item){
  51. window.location.href='/product/classify-'+this.typeSort+'-'+item.bigTypeID+'.html?name='+this.nav_linkName
  52. },
  53. seeMore:function(page){
  54. page.isPageMore = !page.isPageMore;
  55. },
  56. GetHomeFloorData: function(){
  57. var _self = this;
  58. ProductApi.GethomeData(_self.params,function (res) {
  59. if (res.code == 0 ) {
  60. _self.hotlist = res.data.hotSearchList;
  61. _self.floorList = res.data.floorList;
  62. _self.typeSort = res.data.page.typeSort;
  63. _self.listLoading =false;
  64. _self.floorList.forEach(function(page){
  65. if(page.floorContent) {
  66. if(isPC){
  67. if(page.floorContent.templateType == '1' || page.floorContent.templateType == '3'){
  68. if (page.floorImageList.length>7){
  69. page.isPageMore = true;
  70. }
  71. }else if(page.floorContent.templateType == '2' || page.floorContent.templateType == '4' || page.floorContent.templateType == '7'){
  72. if (page.floorImageList.length>5){
  73. page.isPageMore = true;
  74. }
  75. }else if(page.floorContent.templateType == '5'){
  76. if (page.floorImageList.length>10){
  77. page.isPageMore = true;
  78. }
  79. }
  80. }else {
  81. if(page.floorContent.templateType == '1' || page.floorContent.templateType == '3'){
  82. if (page.floorImageList.length>3){
  83. page.isPageMore = true;
  84. }
  85. }else if(page.floorContent.templateType == '2' || page.floorContent.templateType == '4'){
  86. if (page.floorImageList.length>2){
  87. page.isPageMore = true;
  88. }
  89. }else if(page.floorContent.templateType == '5'){
  90. if (page.floorImageList.length>4){
  91. page.isPageMore = true;
  92. }
  93. }
  94. }
  95. }
  96. });
  97. _self.SwiperNanner();
  98. _self.getClassify();
  99. }else {
  100. CAIMEI.Alert(res.msg, '确定');
  101. }
  102. })
  103. },
  104. getClassify: function() {
  105. var _self = this;
  106. PublicApi.GetProductClassify({typeSort:_self.typeSort, source: 'www'}, function (res) {
  107. if (res.code == 0) {
  108. _self.categorylist = res.data;
  109. } else {
  110. CAIMEI.Alert(res.msg, '确定', false);
  111. }
  112. })
  113. },
  114. SwiperNanner: function(){
  115. setTimeout(function(){
  116. // 图片懒加载
  117. $("img[data-original]").lazyload();
  118. },500);
  119. setTimeout(function(){
  120. if (isPC) {
  121. $('.swiper-container').slide({
  122. mainCell:".swiper-wrapper"
  123. ,titCell:".swiper-pagination span"
  124. ,effect: "leftLoop"
  125. ,interTime: 3000
  126. ,autoPlay: true
  127. ,scroll:5
  128. ,vis:5
  129. });
  130. } else {
  131. var swiper = new Swiper('.swiper-container', {
  132. slidesPerView: 2,
  133. slidesPerColumn: 2,
  134. spaceBetween:0,
  135. slidesPerGroup: 2,
  136. autoplay: {
  137. delay: 3000,
  138. disableOnInteraction: false
  139. },
  140. pagination: {
  141. el: '.swiper-pagination'
  142. }
  143. });
  144. }
  145. },500);
  146. }
  147. },
  148. mounted: function(){
  149. var _self = this;
  150. _self.nav_linkName = decodeURI(CAIMEI.getUrlParam('name'));
  151. console.log(_self.nav_linkName);
  152. var userInfo = localStorage.getItem('userInfo');
  153. if(userInfo){
  154. this.params.userId = JSON.parse(userInfo).userId;
  155. }
  156. this.params.pageId = getUrlParam('id');
  157. this.GetHomeFloorData();
  158. }
  159. })