detail.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. var productDetail = new Vue({
  2. el: "#productDetail",
  3. mixins: [beautyArchiveDetailMixin,cmSysVitaMixins,productMixins,supportMixins],
  4. data: {
  5. showProduct: false,
  6. productId: 0,
  7. typeId:0,
  8. userId: 0,
  9. identity:0,
  10. number: 0,
  11. productStock: 0,
  12. pcActType: 0,
  13. images: [],
  14. priceObj: {
  15. actStatus: 0,
  16. ladderPriceFlag: 0,
  17. minBuyNumber: 1,
  18. price: 0,
  19. costPrice: 0,
  20. priceFlag: 3,
  21. productId: 0,
  22. promotions: '',
  23. step: 1,
  24. supplierId: 0,
  25. userIdentity: 0 //2-会员机构;3-供应商;4-普通机构
  26. },
  27. product:{},// 商品信息
  28. promotions: {},//促销活动信息
  29. promotionsId: 0,//活动id
  30. addStatus: true,
  31. recommendType: 0,//相关推荐类型 0自动选择; 1手动推荐
  32. recommendPage: 1,
  33. recommends: [],
  34. parameters: [],
  35. tabsIndex: 0,
  36. disabledText: '',
  37. isNoneDisabled: false,
  38. isServiceInfo: false,
  39. isTrainingMethod: false,
  40. isQualificationImg: false,
  41. productTypeName: "",
  42. beautyActFlag: '',
  43. trainingMethodText: '',
  44. trainingType: '',
  45. isShowPopup: false,
  46. currentTab: 1,
  47. listQuery:{
  48. source:1,
  49. userId:0,
  50. productId:0,
  51. pageNum:1,
  52. pageSize:30,
  53. },
  54. couponParam: {// 获取弹窗优惠券领取参数
  55. userId: 0,
  56. productId: 0,
  57. status: 1,
  58. source: 1
  59. },
  60. isCouponEmpty: false,
  61. isProductChecked:false,
  62. productCoupon: [], // 优惠券
  63. productCouponList: [], // 优惠券弹窗列表
  64. collectionType:false, // 商品收藏状态
  65. supportingList:[],
  66. productDetailChose:2,
  67. defaultSupportingList:[],
  68. isShowSupportingList:false,
  69. isShowMoreButton:false,
  70. totalPrice:0, // 勾选配套商品总价格
  71. totalNumber:0, // 勾选配套商品总数量
  72. isShowCaimeiShop:false,
  73. isHideButton:false
  74. },
  75. filters: {
  76. TypeFormat: function (value) {
  77. switch (value) {
  78. case 0:
  79. return '活动券';
  80. break;
  81. case 1:
  82. return '品类券';
  83. break;
  84. case 2:
  85. return '用户专享券';
  86. break;
  87. case 3:
  88. return '店铺券';
  89. break;
  90. case 4:
  91. return '新用户券';
  92. break;
  93. }
  94. },
  95. NumFormat:function(value) {
  96. return Number(value).toFixed(2);
  97. }
  98. },
  99. methods: {
  100. // 是否显示vip标签价格
  101. showVipPriceTag: function(product){
  102. return (product.priceFlag !== 1 && product.svipProductFlag === 1 && ((GLOBAL_USER_IDENTITY === 4 && GLOBAL_VIP_FLAG === 1) || GLOBAL_USER_IDENTITY === 2));
  103. },
  104. PromotionsFormat:function(promo){//促销活动类型数据处理
  105. if(promo!=null){
  106. if(promo.type == 1 && promo.mode == 1){
  107. return true
  108. }else{
  109. return false
  110. }
  111. }
  112. return false
  113. },
  114. getCommodityCombinationList: function () {// 获取收藏商品列表
  115. var _self = this;
  116. ProductApi.getCommodityCombinationList(_self.listQuery,function (response) {
  117. if (response.code === 0 ) {
  118. var data = response.data;
  119. if(data.results.length > 0 ){
  120. var list = data.results.map((el,index)=>{
  121. el.isChecked = false;
  122. el.isSkuPopup = false;
  123. el.number = el.minBuyNumber;
  124. return el;
  125. });
  126. _self.supportingList = list;
  127. _self.defaultSupportingList = _self.supportingList.slice(0,5);
  128. if(_self.supportingList.length > 5 ){
  129. _self.isShowMoreButton = true;
  130. }
  131. }else{
  132. _self.supportingList = [];
  133. }
  134. }else {
  135. CAIMEI.Alert(response.msg, '确定');
  136. }
  137. });
  138. },
  139. // getImages: function () {
  140. // var _self = this;
  141. // if (!this.productId) {
  142. // return;
  143. // }
  144. // ProductApi.GetProductDdtailsImages({productId: _self.productId}, function (response) {
  145. // if (response.code === 0 && response.data) {
  146. // _self.images = response.data;
  147. // setTimeout(function () {
  148. // if (isPC) {
  149. // var magnifier = new ImageMagnifier(
  150. // '#imgShown .smallImage li',
  151. // '#imgShown .bigImage',
  152. // '#imgShown .zoomImage',
  153. // '#imgShown .mask',
  154. // '#imgShown .zoom',
  155. // "on"
  156. // ).init();
  157. // } else {
  158. // var swiper = new Swiper('#swiperImage', {
  159. // loop: true,
  160. // autoplay: {
  161. // delay: 2000,
  162. // disableOnInteraction: false
  163. // },
  164. // pagination: {
  165. // el: '.swiper-pagination',
  166. // type: 'fraction'
  167. // }
  168. // });
  169. // }
  170. // }, 500);
  171. // }
  172. // });
  173. // },
  174. getProductDetails: function () {
  175. var _self = this;
  176. ProductApi.GetProductDdtails({userId: GLOBAL_USER_ID, productId: _self.productId,typeId:_self.typeId}, function (response) {
  177. if (response.code == 0) {
  178. var product = response.data;
  179. var $pageLabel = '';
  180. _self.product = response.data;
  181. _self.pcActType = product.pcActType;
  182. _self.productStock = product.stock;
  183. _self.addParams.skuId = product.skus[0].skuId;
  184. _self.isDetailsBtnDisable = product.skus[0].stock === 0;
  185. _self.ladderList = product.skus[0].ladderPriceList ? product.skus[0].ladderPriceList : [];
  186. _self.beautyActFlag = product.beautyActFlag;
  187. _self.productTypeName = product.typeName;
  188. _self.recommendType = product.recommendType ? product.recommendType : 0;
  189. _self.archiveId = product.archiveId; // 保存资料列表id
  190. _self.productDetailChose = product.productDetailChose; // 同资质机构显示商品详情
  191. if(product.tinyTypeName){
  192. $pageLabel = product.tinyTypeName
  193. }else if(!product.tinyTypeName && product.smallTypeName){
  194. $pageLabel = product.smallTypeName
  195. }else{
  196. $pageLabel = product.bigTypeName
  197. }
  198. _self.cmSysParams.pageLabel = `${$pageLabel}-${product.brandName?product.brandName:''}`;//设置统计数据标签
  199. if(product.shopType == 2){
  200. _self.isShowCaimeiShop = true
  201. }
  202. if (product.userLike && product.userLike == 1) {// 商品收藏
  203. _self.collectionType = true
  204. } else {
  205. _self.collectionType = false
  206. }
  207. if (product.productDetail.orderInfo != '' && product.productDetail.serviceInfo != '') {
  208. _self.isServiceInfo = true;
  209. }
  210. if(product.qualificationImg){//商品资质
  211. _self.isQualificationImg = true
  212. }else{
  213. _self.isQualificationImg = false
  214. }
  215. if (product.commodityType === 2 && product.trainingMethod) {
  216. _self.isTrainingMethod = true;
  217. _self.trainingMethodText = product.trainingMethod === 1 ? '线上培训' : '线下培训';
  218. _self.trainingType = product.trainingType === 1 ? '¥' + product.trainingFee : '售价已包含';
  219. }
  220. if (product.saleOutFlag === 1 || product.validFlag === 3 || product.validFlag === 9 || product.validFlag === 0 || product.validFlag === 10 || product.stock === 0) {
  221. _self.isNoneDisabled = true;
  222. } else {
  223. _self.isNoneDisabled = false;
  224. }
  225. if (product.validFlag === 3) {
  226. _self.disabledText = '下架'
  227. }
  228. if (product.validFlag === 10) {
  229. _self.disabledText = '停售'
  230. }
  231. if (product.validFlag === 9 || product.validFlag === 0) {
  232. _self.disabledText = '失效'
  233. }
  234. if (product.saleOutFlag === 1 || product.validFlag !== 3 ) {
  235. _self.disabledText = '售罄'
  236. }
  237. _self.handleShowProductType(product.commodityDetailsFlag);
  238. _self.getRecommends();
  239. _self.getProdcutArchiveDetails(); //获取资料列表
  240. // 获取路由hash标识,设置默认展开tab
  241. var str = CAIMEI.getUrlParam('open');
  242. if (str === 'caimei365' && _self.archiveId > 0) {
  243. _self.tabsIndex = 4;
  244. $('body').css({height: '100vh', overflow: 'hidden'})
  245. setTimeout(()=>{
  246. $('body').css({height: '', overflow: ''})
  247. $('html, body').animate({ scrollTop: $('.tabTit').offset().top - $('#globalHead').height() - 50 });
  248. }, 1000);
  249. }
  250. } else {
  251. console.log('<===Error===>',response.msg)
  252. }
  253. })
  254. },
  255. handleShowProductType: function (flag = ''){
  256. // 根据商品详情可见度显示弹窗 flag 1.所有人可见 2.所有机构可见 3.仅会员机构可见 4.仅医美机构可见
  257. let showModal = false;
  258. const flagMap = {
  259. '2': true,
  260. '3': true,
  261. '4': true
  262. }
  263. const textMap = {
  264. '2': '该商品仅限已注册机构查看,请注册机构账户后继续查看。有采美账号的,请直接登录',
  265. '3': '该商品仅限资质机构查看,请注册资质机构后继续查看。有采美账号的,请直接登录。',
  266. '4': '该商品仅限医美类机构查看,请注册医美机构后继续查看。有采美账号的,请直接登录。',
  267. '34': '该商品仅限资质机构查看,请升级为资质机构后继续查看。',
  268. '44': '该商品仅限医美类机构查看,请升级为医美机构后继续查看。',
  269. '42': '该商品仅限医美类机构查看,您暂无权限。您可去机构资料页面查看机构类型。'
  270. }
  271. const code = flag === 4 && GLOBAL_USER_IDENTITY === 2 && GLOBAL_CLUB_TYPE !== 1 ? '42' : `${flag}${GLOBAL_USER_IDENTITY}`
  272. if (GLOBAL_USER_ID === 0) {
  273. showModal = flagMap[flag];
  274. this.showProsPopup(showModal,textMap[flag],'去注册/登录','/login.html')
  275. return
  276. }
  277. if(GLOBAL_VIP_FLAG === 1){ return; }
  278. if (flag === 3 && GLOBAL_USER_IDENTITY === 4) {
  279. showModal = true
  280. this.showProsPopup(showModal,textMap[code],'去升级','/user/setting/upgrade.html')
  281. return
  282. }
  283. if (flag === 4 && GLOBAL_USER_IDENTITY === 4) {
  284. showModal = true
  285. this.showProsPopup(showModal,textMap[code],'去升级','/user/setting/upgrade.html')
  286. return
  287. }
  288. if (flag === 4 && GLOBAL_USER_IDENTITY=== 2 && GLOBAL_CLUB_TYPE !== 1) {
  289. showModal = true
  290. this.showProsPopup(showModal,textMap[code],'去查看资料','/user/setting/information.html')
  291. return
  292. }
  293. },
  294. showProsPopup:function (showFlag,content,confitmBtnText,href) {// 商品详情限制弹窗
  295. if(showFlag){
  296. CAIMEI.Popup({
  297. content: `<div class="payAlert"><p>${content}</p></div>`,
  298. confitmBtnText: confitmBtnText,
  299. cancelBtnText: '关闭',
  300. closeIcon:false
  301. },function(){
  302. // 确定
  303. window.location.href = href;
  304. },function(){
  305. // 关闭
  306. if(window.history.length === 1){
  307. window.location.href="/index.html";
  308. window.close();
  309. }else{
  310. window.history.go(-1);
  311. }
  312. });
  313. }
  314. },
  315. getProductPrice: function () {//获取商品价格
  316. var _self = this;
  317. if (this.productId === 0) {return;}
  318. ProductApi.GetProductDdtailsPrice({ userId: GLOBAL_USER_ID,productId: this.productId }, function (response) {
  319. if (response.code === 0 && response.data) {
  320. _self.priceObj = response.data;
  321. _self.number = response.data.minBuyNumber;
  322. _self.addParams.skuId = response.data.skuId;
  323. if (response.data.actStatus == 1) {
  324. _self.promotions = response.data.promotions;
  325. _self.promotionsId = response.data.promotions.id;
  326. }
  327. console.log('priceObj',_self.priceObj)
  328. if(_self.userId === 0 || GLOBAL_USER_IDENTITY === 2 || GLOBAL_USER_IDENTITY === 4){
  329. _self.isShowSupportingList = true;
  330. }
  331. }
  332. });
  333. },
  334. ladderPrice: function () {//获取商品阶梯价格
  335. var _self = this;
  336. if (!this.productId) {
  337. return;
  338. }
  339. ProductApi.GetProductDdtailsLadderPrice({productId: _self.productId}, function (response) {
  340. if (response.code === 0 && response.data) {
  341. _self.ladderList = response.data;
  342. _self.numberResize();
  343. }
  344. });
  345. },
  346. // getParameters: function () {//获取商品参数
  347. // var _self = this;
  348. // if (!this.productId) {
  349. // return;
  350. // }
  351. // ProductApi.GetProductDdtailsParameter({productId: _self.productId}, function (response) {
  352. // if (response.code === 0 && response.data) {
  353. // _self.parameters = response.data;
  354. // console.log(_self.parameters)
  355. // }
  356. // });
  357. // },
  358. toggleThisLadder: function (event) {
  359. var el = event.currentTarget;
  360. if ($(el).hasClass("on")) {
  361. $(el).removeClass("on").siblings('.mFixed').hide();
  362. if (!isPC) {
  363. looseBody();
  364. }
  365. } else {
  366. $(el).addClass("on").siblings('.mFixed').show();
  367. if (!isPC) {
  368. fixedBody();
  369. }
  370. }
  371. },
  372. hideThisLadder: function (event) {
  373. var el = event.currentTarget;
  374. $(el).parents('.priceTag').find('.tag').removeClass("on").siblings('.mFixed').hide();
  375. if (!isPC) {
  376. looseBody();
  377. }
  378. },
  379. numberSub: function () {
  380. this.number -= this.priceObj.step;
  381. console.log('number', this.number)
  382. this.numberResize();
  383. },
  384. numberAdd: function () {
  385. this.number += this.priceObj.step;
  386. console.log('number', this.number)
  387. this.numberResize();
  388. },
  389. numberChange: function () {
  390. this.number = Math.ceil(this.number / this.priceObj.step) * this.priceObj.step;
  391. this.numberResize();
  392. },
  393. numberResize: function () {
  394. var _self = this;
  395. if (this.number < this.priceObj.minBuyNumber) {
  396. this.number = this.priceObj.minBuyNumber;
  397. }
  398. if (this.number > this.productStock) {
  399. this.number = this.productStock;
  400. }
  401. // if (this.priceObj.ladderPriceFlag) {
  402. // this.ladderList.forEach(function (ladder) {
  403. // if (_self.number >= ladder.buyNum) {
  404. // _self.priceObj.price = ladder.buyPrice;
  405. // }
  406. // });
  407. // }
  408. console.log('number', this.number)
  409. },
  410. handleCollection:function (){// 收藏操作
  411. var _self = this;
  412. console.log('_self.userId',_self.userId)
  413. if (_self.userId > 0) {
  414. ProductApi.getProductUserLike({userId: _self.userId, productId: _self.productId}, function (response) {
  415. if (response.code === 0 && response.data) {
  416. _self.collectionType = !_self.collectionType
  417. CAIMEI.dialog(response.data,false);
  418. } else {
  419. CAIMEI.Alert(response.msg, '确定', false);
  420. }
  421. });
  422. }else{
  423. _self.toLogin();
  424. }
  425. },
  426. toLogin: function () {
  427. setBeforeUrl();
  428. window.location.href = '/login.html';
  429. },
  430. toUpgrade: function () {
  431. setBeforeUrl();
  432. window.location.href = '/user/setting/upgrade.html';
  433. },
  434. getRecommends: function () {
  435. var _self = this;
  436. if (!this.productId) {
  437. return;
  438. }
  439. ProductApi.GetProductDdtailsRecommend(
  440. {
  441. productId: _self.productId,
  442. recommendType: _self.recommendType,
  443. userId: _self.userId
  444. },
  445. function (response) {
  446. if (response.code === 0 && response.data) {
  447. if (response.data.length > 0) {
  448. _self.recommends = response.data;
  449. _self.recommendPage = isPC ? Math.ceil(response.data.length / 7) : Math.ceil(response.data.length / 3);
  450. setTimeout(function () {
  451. if (isPC) {
  452. $('#productRecommend').slide({
  453. mainCell: ".swiper-wrapper",
  454. titCell: ".swiper-pagination span",
  455. effect: "leftLoop",
  456. interTime: 3000,
  457. autoPlay: true,
  458. scroll: 7,
  459. vis: 7,
  460. trigger: "mouseover"
  461. });
  462. } else {
  463. var swiper = new Swiper('#productRecommend', {
  464. slidesPerView: 3,
  465. spaceBetween: 0,
  466. autoplay: {
  467. delay: 3000,
  468. disableOnInteraction: false
  469. },
  470. pagination: {
  471. el: '.swiper-pagination'
  472. }
  473. });
  474. }
  475. }, 500);
  476. }
  477. }
  478. });
  479. },
  480. queryProductDetilsCoupons: function() {// 初始化商品详情优惠券信息
  481. var _self = this;
  482. ProductApi.QueryProductDetilsCoupons(_self.couponParam, function (response) {
  483. if (response.code == 0) {
  484. var data = response.data;
  485. if (isPC) {
  486. _self.productCoupon = response.data.list.splice(0, 3);
  487. } else {
  488. _self.productCoupon = response.data.list.splice(0, 2);
  489. }
  490. } else {
  491. console.log('获取优惠券列表失败');
  492. }
  493. })
  494. },
  495. queryPopupCoupons: function () {// 获取弹窗优惠券列表
  496. var _self = this;
  497. ProductApi.QueryProductDetilsCoupons(_self.couponParam, function (response) {
  498. if (response.code == 0) {
  499. var data = response.data;
  500. if (data.couponList && data.couponList.length > 0) {
  501. _self.productCouponList = data.couponList;
  502. _self.isCouponEmpty = false;
  503. console.log('有优惠券')
  504. console.log(_self.productCouponList)
  505. } else {
  506. console.log('没有优惠券')
  507. _self.isCouponEmpty = true;
  508. }
  509. } else {
  510. console.log('获取优惠券列表失败')
  511. }
  512. })
  513. },
  514. toDeductCoupon:function (coupon) {// 点击购买按钮事件处理
  515. var _self = this;
  516. console.log(coupon)
  517. if(_self.listQuery.userId == 0){
  518. window.location.href='/login.html';
  519. }else{
  520. ProductApi.CreatePayCouponBeans({userId:_self.couponParam.userId, couponId:coupon.couponId, source:2}, function (response) {
  521. if(response.code == 0){
  522. CAIMEI.dialog('抵扣成功',true,function () {
  523. setTimeout(function(){
  524. _self.currentTab = 2;
  525. _self.couponParam.status = 2;
  526. _self.queryPopupCoupons();
  527. },200)
  528. });
  529. }else{
  530. CAIMEI.Alert(response.msg, '确定', false);
  531. }
  532. })
  533. }
  534. },
  535. receiveCoupon: function (coupon) {// 点击领取优惠券
  536. var _self = this;
  537. ProductApi.ReceiveCoupon({
  538. userId: _self.couponParam.userId,
  539. couponId: coupon.couponId,
  540. source: 2
  541. }, function (response) {
  542. if (response.code == 0) {
  543. _self.currentTab = 2;
  544. _self.couponParam.status = 2;
  545. _self.queryPopupCoupons();
  546. } else {
  547. CAIMEI.Alert(response.msg, '确定', false);
  548. }
  549. })
  550. },
  551. queryCouponTabs: function (value) {// 切换优惠券
  552. var _self = this;
  553. _self.currentTab = _self.couponParam.status = value;
  554. _self.queryPopupCoupons();
  555. },
  556. showPopup: function () {// 显示优惠券弹窗
  557. var _self = this;
  558. if (_self.userId > 0) {
  559. _self.productCouponList = [];
  560. _self.currentTab = 1;
  561. _self.couponParam.status = 1;
  562. _self.queryPopupCoupons();
  563. _self.isShowPopup = true;
  564. } else {
  565. window.location.href = '/login.html';
  566. }
  567. },
  568. hidePopup: function () {// 隐藏优惠券弹窗
  569. var _self = this;
  570. _self.isShowPopup = false;
  571. },
  572. detailsClicktab: function (index) {
  573. var _self = this;
  574. _self.tabsIndex = index;
  575. if (index !== 4) return;
  576. // 只有当前用户权限为0,并且未初始化时初始化图片预览
  577. if (_self.permission === 0) {
  578. setTimeout(function () {
  579. _self.initPreviewImage()
  580. })
  581. }
  582. },
  583. supportingNumberSub: function(pros){// 配套商品数量减减
  584. var _self = this;
  585. if (pros.number <= pros.minBuyNumber) {
  586. pros.number = pros.minBuyNumber
  587. return
  588. } else {
  589. if (pros.step === 2) {
  590. pros.number -= pros.minBuyNumber
  591. } else {
  592. pros.number--
  593. }
  594. }
  595. _self.numberChange(pros);
  596. },
  597. supportingNumberAdd: function(pros){ // 配套商品数量加加
  598. var _self = this;
  599. if (pros.step === 2) {
  600. pros.number += pros.minBuyNumber
  601. } else {
  602. pros.number++
  603. }
  604. _self.numberChange(pros);
  605. },
  606. supportingNumberChange: function(pros){ // 配套商品数量输入
  607. var _self = this;
  608. pros.number = Math.ceil(pros.number/pros.step)*pros.step;
  609. _self.numberChange(pros);
  610. },
  611. numberChange: function(pros){
  612. var _self = this;
  613. if(pros.ladderPriceFlag){
  614. pros.ladderPrices.forEach(function(ladder){
  615. if(pros.number>=ladder.buyNum){
  616. pros.price = ladder.buyPrice;
  617. pros.originalPrice = ladder.buyPrice;
  618. }
  619. });
  620. }
  621. // 计算价格
  622. _self.calculatetTtalPrice();
  623. },
  624. calculatetTtalPrice: function () { // 计算配套商品总价格
  625. var _self = this;
  626. var totalPrice = 0;
  627. var totalNumber = 0;
  628. _self.supportingList.forEach(function (pros) {
  629. if(pros.isChecked){
  630. pros.totalPrice = pros.number*pros.price;
  631. totalNumber+= pros.number
  632. }else{
  633. pros.totalPrice = 0;
  634. }
  635. totalPrice += pros.totalPrice;
  636. })
  637. _self.totalPrice = totalPrice;
  638. _self.totalNumber = totalNumber;
  639. },
  640. checkedSoperv:function (pros) {// 勾选配套商品
  641. console.log(pros)
  642. var _self = this;
  643. var goodsCheckedLength = 0;
  644. pros.isChecked = !pros.isChecked
  645. _self.supportingList.forEach(el => {
  646. if(el.isChecked) {
  647. goodsCheckedLength++;
  648. }
  649. })
  650. if(goodsCheckedLength>0){
  651. _self.isProductChecked = true
  652. }else{
  653. _self.isProductChecked = false
  654. }
  655. _self.calculatetTtalPrice();
  656. },
  657. toBuyCoupon:function (coupon) {// 点击购买按钮事件处理
  658. var _self = this;
  659. ProductApi.createCouponRecord({userId:_self.listQuery.userId, couponId:coupon.couponId}, function (response) {
  660. if(response.code == 0){
  661. let couponRecordId = response.data.couponRecordId
  662. window.location.href = '/pay/caimei-hlbpay.html?pageType=3&couponId='+coupon.couponId+'&couponRecordId='+couponRecordId;
  663. }else{
  664. if(response.code == -1){//个人机构不能购买
  665. CAIMEI.Alert('该优惠券仅限医美机构购买,请升级为医美机构后再次购买。', '去升级', true, function(){
  666. window.location.href = "/user/setting/upgrade.html";
  667. });
  668. }else if(response.code == -2){//会员机构不是医美机构不能购买
  669. CAIMEI.dialog('该优惠券仅限医美机构购买',false,function () {});
  670. }else{
  671. CAIMEI.Alert(response.msg, '确定', false);
  672. }
  673. }
  674. })
  675. },
  676. showSupportingMore:function () {
  677. var _self = this;
  678. _self.isShowMoreButton = false;
  679. _self.defaultSupportingList = _self.supportingList;
  680. },
  681. // 是否显示vip标签价格
  682. showVipPriceTag: function(pros){
  683. //非会员
  684. if(!GLOBAL_VIP_FLAG === 1) return false;
  685. // 商品所有机构可见
  686. if(pros.priceFlag === 0 && pros.svipProductFlag === 1 ) return true;
  687. // 商品价格仅资质机构可见
  688. if(pros.priceFlag === 2 && pros.svipProductFlag === 1 && GLOBAL_USER_IDENTITY === 2) return true;
  689. // 商品价格仅医美机构可见
  690. if(pros.priceFlag === 3 && pros.svipProductFlag === 1 && GLOBAL_USER_IDENTITY === 2 && GLOBAL_CLUB_TYPE == 1) return true;
  691. // 其它
  692. return false;
  693. },
  694. },
  695. created: function () {
  696. this.productId = this.couponParam.productId = this.addParams.productId = this.listQuery.productId = this.handleProsId = $("#productId").val();
  697. this.cmSysParams.pageType = 6;
  698. this.cmSysParams.productId = this.productId;
  699. this.typeId = $("#typeId").val();
  700. console.log('typeId', this.typeId)
  701. this.userId = this.couponParam.userId = this.listQuery.userId = GLOBAL_USER_ID;
  702. // this.getImages();
  703. // identity: 0个人,1协销,2会员机构,3供应商,4普通机构
  704. // visibility:3:所有人可见,2:普通机构可见,1:会员机构可见 4:仅医美机构可见
  705. // var visible = $("#productVisibility").val() * 1;
  706. // console.log('visible',visible)
  707. // var identity = GLOBAL_USER_IDENTITY;
  708. // console.log('identity',identity)
  709. // this.showProduct = visible === 3 || visible == 4 || identity === 1 || identity === 2 || (identity === 4 && visible === 2);
  710. // if (!this.showProduct) {
  711. // window.location.href = "/404.html?error=未查询到该商品";
  712. // }
  713. },
  714. mounted: function () {
  715. this.userId = this.couponParam.userId = this.addParams.userId = GLOBAL_USER_ID;
  716. this.getProductDetails();
  717. this.getProductPrice();
  718. // this.getParameters();
  719. this.queryProductDetilsCoupons();
  720. this.getCommodityCombinationList();
  721. console.log('GLOBAL_CLUB_TYPE',GLOBAL_CLUB_TYPE)
  722. // $('.productInfo').slide({
  723. // mainCell:".tabCon"
  724. // ,titCell:".tabTit span"
  725. // ,trigger: "click"
  726. // });
  727. setTimeout(function () {
  728. if (isPC) {
  729. var magnifier = new ImageMagnifier(
  730. '#imgShown .smallImage li',
  731. '#imgShown .bigImage',
  732. '#imgShown .zoomImage',
  733. '#imgShown .mask',
  734. '#imgShown .zoom',
  735. "on"
  736. ).init();
  737. } else {
  738. var swiper = new Swiper('#swiperImage', {
  739. loop: true,
  740. autoplay: {
  741. delay: 2000,
  742. disableOnInteraction: false
  743. },
  744. pagination: {
  745. el: '.swiper-pagination',
  746. type: 'fraction'
  747. }
  748. });
  749. }
  750. }, 500);
  751. setTimeout(function () {
  752. if (isPC) {
  753. $('#productRecommend').slide({
  754. mainCell: ".swiper-wrapper",
  755. titCell: ".swiper-pagination span",
  756. effect: "leftLoop",
  757. interTime: 3000,
  758. autoPlay: true,
  759. scroll: 7,
  760. vis: 7,
  761. trigger: "mouseover"
  762. });
  763. } else {
  764. var swiper = new Swiper('#productRecommend', {
  765. slidesPerView: 3,
  766. spaceBetween: 0,
  767. autoplay: {
  768. delay: 3000,
  769. disableOnInteraction: false
  770. },
  771. pagination: {
  772. el: '.swiper-pagination'
  773. }
  774. });
  775. }
  776. }, 500);
  777. }
  778. });