instruement.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. var instrueMent = new Vue({
  2. el:'#instrueMent',
  3. mixins: [cmSysVitaMixins],
  4. data:{
  5. listLoading:true,
  6. categorylist:[],
  7. hotlist:[],
  8. recommendPage: 1,
  9. floorList: [],
  10. userId:0,
  11. typeSort:'',
  12. showflag:false,
  13. params:{
  14. pageId:0,
  15. userId:0,
  16. source:1
  17. },
  18. isPC:window.isPC
  19. },
  20. filters: {
  21. NumFormat:function(value) {
  22. return Number(value).toFixed(2);
  23. }
  24. },
  25. methods:{
  26. // 是否显示vip标签价格
  27. showVipPriceTag: function(pros){
  28. //非会员
  29. // if(!GLOBAL_VIP_FLAG === 1) return false;
  30. // 商品所有机构可见
  31. if(pros.priceFlag === 0 && pros.svipProductFlag === 1 ) return true;
  32. // 商品价格仅资质机构可见
  33. if(pros.priceFlag === 2 && pros.svipProductFlag === 1 && GLOBAL_USER_IDENTITY === 2) return true;
  34. // 商品价格仅医美机构可见
  35. if(pros.priceFlag === 3 && pros.svipProductFlag === 1 && GLOBAL_USER_IDENTITY === 2 && GLOBAL_CLUB_TYPE === 1) return true;
  36. // 其它
  37. return false;
  38. },
  39. closeup:function(){
  40. this.showflag = false;
  41. document.body.style.overflow='';
  42. },
  43. showNav:function(){
  44. var _this = this;
  45. _this.showflag = !_this.showflag;
  46. if (_this.showflag){
  47. document.body.style.overflow='hidden';
  48. }else {
  49. document.body.style.overflow='';
  50. }
  51. },
  52. // 商品楼层轮播
  53. swiperFloor: function(){
  54. setTimeout(function(){
  55. // 商品轮播
  56. if (isPC) {
  57. var cell = $(".swiper-pagination-floor");
  58. var size = Math.ceil(cell.attr("data-id")/5);
  59. var span = '';
  60. for (var i = 0; i < size; i++) {
  61. span += '<span></span>';
  62. }
  63. cell.html(span);
  64. $('.mySwiperSlide').slide({
  65. mainCell:".recommendBox-wrapper",
  66. titCell:".swiper-pagination-floor span",
  67. effect: "leftLoop",
  68. autoPlay: false,
  69. scroll:5,
  70. vis:5
  71. });
  72. } else {
  73. var swiper = new Swiper('.mySwiperSlide', {
  74. slidesPerView: 2,
  75. slidesPerColumn: 2,
  76. spaceBetween:0,
  77. slidesPerGroup: 2,
  78. autoplay: {
  79. delay: 3000,
  80. disableOnInteraction: false
  81. },
  82. pagination: {
  83. el: '.swiper-pagination'
  84. }
  85. });
  86. }
  87. // 图片懒加载
  88. setTimeout(function(){
  89. $("#recommendBox img[data-original]").lazyload();
  90. },0)
  91. },500);
  92. },
  93. GetHomeData: function(){//获取楼层
  94. var _self = this;
  95. ProductApi.GethomeData(_self.params,function(response){
  96. if(response.code == 0){
  97. var data = response.data;
  98. _self.floorList = data.floorList;
  99. _self.cmSysParams.pageLabel = data.contentLabel;
  100. setTimeout(function(){
  101. // 图片懒加载
  102. $("img[data-original]").lazyload();
  103. _self.swiperFloor();
  104. // 设置页面查看更多
  105. _self.setReadeMore();
  106. },500);
  107. }else{
  108. CAIMEI.Alert(response.msg, '确定');
  109. }
  110. });
  111. },
  112. PromotionsFormat:function(promo){//促销活动类型数据处理
  113. if(promo!=null){
  114. if(promo.type == 1 && promo.mode == 1){
  115. return true
  116. }else{
  117. return false
  118. }
  119. }
  120. return false
  121. },
  122. // 设置页面查看更多按钮显示
  123. setReadeMore: function(){
  124. $(".section_page_more").each(function(){
  125. var id = $(this).attr('data-id')*1;
  126. var size = $(this).attr('data-size')*1;
  127. var el = $(this);
  128. var readMore = false;
  129. if (isPC) {
  130. if([1,3].indexOf(id) !== -1 && size>7) {
  131. readMore = true;
  132. }
  133. if([2,4].indexOf(id) !== -1 && size>5) {
  134. readMore = true;
  135. }
  136. if([5,6,7].indexOf(id) !== -1 && size>10) {
  137. readMore = true;
  138. }
  139. } else {
  140. if([1,3].indexOf(id) !== -1 && size>3) {
  141. readMore = true;
  142. }
  143. if([2,4].indexOf(id) !== -1 && size>2) {
  144. readMore = true;
  145. }
  146. if([5,6,7].indexOf(id) !== -1 && size>4) {
  147. readMore = true;
  148. }
  149. }
  150. if (readMore) {
  151. el.addClass("show");
  152. } else {
  153. el.parents(".section_page").find(".section_page_main").addClass("max");
  154. }
  155. });
  156. },
  157. // 点击查看更多
  158. showMoreItem: function(e){
  159. var el = e.currentTarget;
  160. $(el).parents(".section_page").find(".section_page_main").addClass("max");
  161. $(el).parents(".section_page_more").hide();
  162. },
  163. // 设置页面商品价格
  164. setPriceShown: function(){
  165. var productIds = [];
  166. var userId = GLOBAL_USER_ID;
  167. var shopId = GLOBAL_SHOP_ID;
  168. var userIdentity = GLOBAL_USER_IDENTITY;
  169. $(".main_price_text").each(function(){
  170. var id = $(this).attr('data-id');
  171. if (productIds.indexOf(id) === -1) {
  172. productIds .push(id);
  173. }
  174. });
  175. // 获取商品价格列表
  176. $.getJSON(coreServer+"/commodity/price/list",{
  177. userId: GLOBAL_USER_ID,
  178. productIds: productIds.join(',')
  179. }).done(function (res) {
  180. if (res.code === 0 && res.data) {
  181. var priceList = res.data;
  182. $(".main_price_none").hide();
  183. $(".price_grade_club").hide();
  184. $(".price_grade_shop").hide();
  185. $(".main_price_login").show();
  186. priceList.map(function(price){
  187. // userIdentity用户身份: 0、个人 1、协销 2、会员机构 3、供应商 4,普通机构
  188. // priceFlag: 0公开价格 1不公开价格 2仅对会员机构公开
  189. var parent = $(".main_price_text.product_"+ price.productId);
  190. var priceFlag = parent.find(".main_price_login").attr('data-id')*1;
  191. if (priceFlag===3 || userIdentity===2 || (priceFlag === 0 && userIdentity===4 ) || (userIdentity===3 && shopId === price.shopId*1)) {
  192. parent.find(".price_o_num").text(Number(price.originalPrice).toFixed(2));
  193. parent.find(".price_num").text(Number(price.price).toFixed(2));
  194. if(price.promotions && price.promotions.type*1===1 && price.promotions.mode*1===1){
  195. parent.find(".main_price_show").hide();
  196. parent.find(".main_price_show.none").show();
  197. parent.find(".price_unit").show();
  198. }
  199. } else if (userIdentity===4 && priceFlag === 2){
  200. parent.find(".main_price_show").hide();
  201. parent.find(".price_grade_club").show();
  202. } else {
  203. parent.find(".main_price_show").hide();
  204. parent.find(".price_grade_shop").show();
  205. }
  206. });
  207. }
  208. });
  209. }
  210. },
  211. created: function () {
  212. this.cmSysParams.pageType = 13;
  213. },
  214. mounted: function(){
  215. var _self = this;
  216. var userInfo = localStorage.getItem('userInfo');
  217. if(userInfo){
  218. _self.userId = _self.params.userId = JSON.parse(userInfo).userId;
  219. }
  220. //this.params.pageId = getUrlParam('id');
  221. var paramsArr = window.location.pathname.split(".")[0].split("-");
  222. this.params.pageId = paramsArr.length>=1 ? paramsArr[1] : '';
  223. // 获取设置商品价格
  224. if (GLOBAL_USER_ID) {
  225. this.GetHomeData();
  226. }else {
  227. //获取页面标签名称
  228. this.cmSysParams.pageLabel = $('#contentLabel').val();
  229. // 设置页面查看更多
  230. this.setReadeMore();
  231. // 推荐专区商品轮播
  232. this.swiperFloor();
  233. }
  234. // Dom加载后
  235. this.$nextTick(function(){
  236. // 图片懒加载
  237. $("img[data-original]").lazyload();
  238. });
  239. }
  240. })