launch-sales.component.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import { Component, OnInit } from '@angular/core';
  2. import { HyperService } from '../../core/services/http.service';
  3. import { LocalStorage } from "../../core/services/local_storage.service"
  4. import { Router } from "@angular/router";
  5. import {Location} from '@angular/common';
  6. import $ from 'jquery'
  7. declare var $: $
  8. @Component({
  9. selector: 'app-launch-sales',
  10. templateUrl: './launch-sales.component.html',
  11. styleUrls: ['./launch-sales.component.scss']
  12. })
  13. export class LaunchSalesComponent implements OnInit {
  14. salesList:any=[];
  15. imageID:number;
  16. imageUrl:any;
  17. imageHotspot:any=[];
  18. activeClass:boolean=false;
  19. xValue:number;
  20. yValue:number;
  21. loader:boolean=false;
  22. model_name:string;
  23. constructor(private server: HyperService, private router: Router,private loc:Location) { }
  24. ngOnInit() {
  25. this.model_name = LocalStorage.getValue('model_name')
  26. $(".lg-hotspot-label").show("fast");
  27. $(".lg-hotspot-label").hide();
  28. $(".lg-hotspot-button").click(function () {
  29. var thisLabel = $(this).siblings(".lg-hotspot-label");
  30. var thisLabelState = thisLabel.css("display");
  31. // console.log(thisLabel)
  32. $(".lg-hotspot-label").fadeOut(0).parent().css("z-index", "0");
  33. if (thisLabelState == "none") {
  34. thisLabel.fadeIn(0);
  35. $(this).parent().css("z-index", "999");
  36. }
  37. });
  38. this.salesProcess()
  39. }
  40. salesProcess(){
  41. this.loader=true;
  42. this.server.get("explore/salesprocess/"+LocalStorage.getValue('set_model_id'))
  43. .then((data) => {
  44. if (data.status == 200 && data.result.response != 'failed' && data.result.data != null) {
  45. this.loader=false;
  46. // console.log(data.result.data)
  47. this.salesList = data.result.data
  48. this.rotateImage(this.salesList[0])
  49. } else if (data.result.status == 401 && data.result.response == 'failed') {
  50. } else {
  51. this.loader=false;
  52. alert(data.result.message)
  53. }
  54. });
  55. }
  56. rotateImage(item){
  57. var wid = 806/100;
  58. var hei = 520/100;
  59. // console.log(item)
  60. for(let i=0;i<this.salesList.length;i++){
  61. if(this.salesList[i].id == item.id){
  62. this.activeClass = true;
  63. this.imageID =item.id;
  64. this.imageUrl =item.image.image_url;
  65. this.imageHotspot=[]
  66. for(let j=0;j<item.image.hotspot.length;j++){
  67. // this.xValue = item.image.hotspot[j].point_arr.x;
  68. // this.yValue = item.image.hotspot[j].point_arr.x;
  69. let newx = wid*((item.image.hotspot[j].point_arr.x / 1024)*100);
  70. let newY = hei*((item.image.hotspot[j].point_arr.y / 660)*100);
  71. let contentTitle = item.image.hotspot[j].title;
  72. let contentUrl = item.image.hotspot[j].file_url;
  73. let contentDescription = item.image.hotspot[j].description;
  74. let obj:any={
  75. x:newx,y:newY,contentTitle:contentTitle,contentUrl:contentUrl,contentDescription:contentDescription
  76. };
  77. this.imageHotspot.push(obj);
  78. console.log( this.imageHotspot)
  79. $('body').click(function(){
  80. $(".lg-hotspot-label").hide();
  81. })
  82. }
  83. }else{
  84. }
  85. }
  86. }
  87. hotspotPoint(e,index){
  88. e.stopPropagation();
  89. var thisLabel = $(".active-content"+index).siblings(".lg-hotspot-label");
  90. var thisLabelState = thisLabel.css("display");
  91. $(".lg-hotspot-label").fadeOut(0).parent().css("z-index", "0");
  92. $(".active-content"+index).parent().css("z-index", "9999999");
  93. if (thisLabelState == "none") {
  94. thisLabel.fadeIn(0);
  95. $(".active-content").parent().css("z-index", "999");
  96. }
  97. }
  98. goBack(){
  99. this.loc.back();
  100. }
  101. }