instruement.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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/instruelist.html?bigTypeID='+item.bigTypeID+'&typeSort='+this.typeSort+'&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. var data = res.data;
  61. _self.hotlist = data.hotSearchList;
  62. _self.floorList = data.floorList;
  63. _self.typeSort = data.typeSort;
  64. _self.listLoading =false;
  65. _self.floorList.forEach(function(page){
  66. if(page.floorContent) {
  67. if(isPC){
  68. if(page.floorContent.templateType == '1' || page.floorContent.templateType == '3'){
  69. if (page.floorImageList.length>7){
  70. page.isPageMore = true;
  71. }
  72. }else if(page.floorContent.templateType == '2' || page.floorContent.templateType == '4' || page.floorContent.templateType == '7'){
  73. if (page.floorImageList.length>5){
  74. page.isPageMore = true;
  75. }
  76. }else if(page.floorContent.templateType == '5'){
  77. if (page.floorImageList.length>10){
  78. page.isPageMore = true;
  79. }
  80. }
  81. }else {
  82. if(page.floorContent.templateType == '1' || page.floorContent.templateType == '3'){
  83. if (page.floorImageList.length>3){
  84. page.isPageMore = true;
  85. }
  86. }else if(page.floorContent.templateType == '2' || page.floorContent.templateType == '4'){
  87. if (page.floorImageList.length>2){
  88. page.isPageMore = true;
  89. }
  90. }else if(page.floorContent.templateType == '5'){
  91. if (page.floorImageList.length>4){
  92. page.isPageMore = true;
  93. }
  94. }
  95. }
  96. }
  97. });
  98. _self.SwiperNanner();
  99. _self.getClassify();
  100. }else {
  101. CAIMEI.Alert(res.msg, '确定');
  102. }
  103. })
  104. },
  105. getClassify: function() {
  106. var _self = this;
  107. PublicApi.GetProductClassify({typeSort:_self.typeSort, source: 'www'}, function (res) {
  108. if (res.code == 0) {
  109. _self.categorylist = res.data;
  110. } else {
  111. CAIMEI.Alert(res.msg, '确定', false);
  112. }
  113. })
  114. },
  115. SwiperNanner: function(){
  116. setTimeout(function(){
  117. // 图片懒加载
  118. $("img[data-original]").lazyload();
  119. },500);
  120. setTimeout(function(){
  121. if (isPC) {
  122. $('.swiper-container').slide({
  123. mainCell:".swiper-wrapper"
  124. ,titCell:".swiper-pagination span"
  125. ,effect: "leftLoop"
  126. ,interTime: 3000
  127. ,autoPlay: true
  128. ,scroll:5
  129. ,vis:5
  130. });
  131. } else {
  132. var swiper = new Swiper('.swiper-container', {
  133. slidesPerView: 2,
  134. slidesPerColumn: 2,
  135. spaceBetween:0,
  136. slidesPerGroup: 2,
  137. autoplay: {
  138. delay: 3000,
  139. disableOnInteraction: false
  140. },
  141. pagination: {
  142. el: '.swiper-pagination'
  143. }
  144. });
  145. }
  146. },500);
  147. }
  148. },
  149. mounted: function(){
  150. var _self = this;
  151. _self.nav_linkName = decodeURI(CAIMEI.getUrlParam('name'));
  152. console.log(_self.nav_linkName);
  153. var userInfo = localStorage.getItem('userInfo');
  154. if(userInfo){
  155. this.params.userId = JSON.parse(userInfo).userId;
  156. }
  157. this.params.pageId = getUrlParam('id');
  158. this.GetHomeFloorData();
  159. }
  160. })