Commit 7625427c by sweet

产品海报对接

parent 7ee1de0b
......@@ -15,9 +15,11 @@ import * as uuid from 'uuid';
})
export class MkMaterialDetailComponent implements OnInit {
@ViewChild('canvas') canvas: ElementRef<any>;
// 区分险种 1.产险-健康险
productType: number;
materialItemId: string;
// 1是指itemId 是productID 2是指planid
materialItemType: string;
// 海报图
productPosterPath: string;
lifeCustomerInfo: any;
shareInfo: any;
// 自定义内容部分高度
......@@ -36,26 +38,9 @@ export class MkMaterialDetailComponent implements OnInit {
ngOnInit() {
this.materialItemId = this.activateRoute.snapshot.paramMap.get('itemId');
if (this.materialItemId.substr(0, 2) === 'ph') {
this.productType = 1;
}
this.materialItemType = this.activateRoute.snapshot.queryParams['itemType'];
this.lifeCustomerInfo = localStorage.getItem('lifeCustomerInfo') ? JSON.parse(localStorage.getItem('lifeCustomerInfo')) : null;
// 分享信息
const shareCodeUuid = uuid.v4();
this.shareInfo = {
...this.lifeCommonService.generateShareCode(),
shareCode: shareCodeUuid,
customerId: this.lifeCustomerInfo.customerId,
productId: this.materialItemId,
url: `${environment.ORIGINNAME}/life/${this.materialItemId}?shareCode=${shareCodeUuid}`
};
if (this.productType === 1) {
this.shareInfo.productId = null;
this.shareInfo.planId = this.materialItemId.substr(2);
this.shareInfo.url = `${environment.ORIGINNAME}/hProductDetail/${this.materialItemId.substr(2)}?shareCode=${shareCodeUuid}&type=9`;
}
// 发送请求保存分享码
this.shareCallBack();
this.posterQuery(this.materialItemId, this.materialItemType);
}
async canvasPic() {
......@@ -78,14 +63,13 @@ export class MkMaterialDetailComponent implements OnInit {
const avatarurlY = this.canvas.nativeElement.height - (this.contentHeight + 50) / 2 * ratio; // 绘制的头像在画布上的位置
const avatarImg = new Image();
avatarImg.setAttribute('crossOrigin', 'anonymous');
// avatarImg.src = `${environment.ORIGINNAME}/assets/img/meng.png`;
if (this.lifeCustomerInfo.practitionerBasicInfo.headImagePath) {
avatarImg.src = this.lifeCustomerInfo.practitionerBasicInfo.headImagePath + '?v=' + new Date().getTime();
} else {
avatarImg.src = `${environment.ORIGINNAME}/assets/img/meng.png?v=${new Date().getTime()}`;
}
// 这里的第一张图片就是可以是你们的海报 这里注意绘制的顺序 我们要手动控制
img.src = `${environment.ORIGINNAME}/ydLife/assets/images/mk-material/${this.materialItemId}.jpg?v=${new Date().getTime()}`;
img.src = this.productPosterPath;
img.onload = () => {
// 加载海报图
ctx.drawImage(img, 0, 0, this.canvas.nativeElement.width, this.canvas.nativeElement.height);
......@@ -202,4 +186,41 @@ export class MkMaterialDetailComponent implements OnInit {
}, 100)
});
}
// 获取大图
posterQuery(itemId, itemType) {
this.myService.posterQuery({
paginationInfo: {
noLimitFlag: 'CONFIRM'
}
}).subscribe(res => {
if (res['success']) {
const posterInfos = res['data']['posterInfos'];
const posterInfo = posterInfos.filter(item => item.itemId == itemId && item.itemType == itemType).pop();
this.productPosterPath = posterInfo.productPosterPath + '?v=' + new Date().getTime();
// 分享信息
const shareCodeUuid = uuid.v4();
this.shareInfo = {
...this.lifeCommonService.generateShareCode(),
shareCode: shareCodeUuid,
customerId: this.lifeCustomerInfo.customerId,
productId: this.materialItemId,
url: `${environment.ORIGINNAME}/life/${this.materialItemId}?shareCode=${shareCodeUuid}`
};
if (itemType == '2') {
this.shareInfo.productId = null;
this.shareInfo.planId = this.materialItemId;
}
if (!posterInfo.noPlanProduct) {
if (posterInfo.productCategoryId == '2') {
this.shareInfo.url = `${environment.ORIGINNAME}/hProductDetail/${this.materialItemId}?shareCode=${shareCodeUuid}&type=7`;
} else if (posterInfo.productCategoryId == '5') {
this.shareInfo.url = `${environment.ORIGINNAME}/hProductDetail/${this.materialItemId}?shareCode=${shareCodeUuid}&type=9`;
}
}
// 发送请求保存分享码
this.shareCallBack();
}
});
}
}
<div class="materialContainer">
<div class="materialItem" *ngFor="let materialItem of materialLists;index as i"
[routerLink]="['/material',materialItem.itemId]">
<div class="materialItem" *ngFor="let posterInfo of posterInfos;index as i"
[routerLink]="['/material',posterInfo.itemId]" [queryParams]="{itemType:posterInfo.itemType}">
<div>
<img src="{{'./assets/images/mk-material/'+materialItem.itemId+'thumb.jpg'}}" alt="" class="img-responsive">
<img src="{{posterInfo.thumbnailPath}}" alt="" class="img-responsive">
</div>
<div class="title">{{materialItem.title}}</div>
<div class="title">{{posterInfo.title}}</div>
</div>
</div>
import {Component, OnInit} from '@angular/core';
import {Router} from "@angular/router";
import {MyService} from "../my.service";
@Component({
selector: 'ydlife-mk-material',
templateUrl: './mk-material.component.html',
......@@ -7,8 +9,9 @@ import {Router} from "@angular/router";
})
export class MkMaterialComponent implements OnInit {
materialLists: Array<any>;
posterInfos: Array<any>;
constructor(private router: Router) {
constructor(private router: Router, private myService: MyService) {
}
ngOnInit() {
......@@ -24,6 +27,19 @@ export class MkMaterialComponent implements OnInit {
{id: 7, itemId: '138', title: '中信保诚祯爱减额定期寿险'},
{id: 8, itemId: '139', title: '中信保诚祯爱增额定期寿险'}
];
this.posterQuery();
}
posterQuery() {
this.myService.posterQuery({
paginationInfo: {
noLimitFlag: 'CONFIRM'
}
}).subscribe(res => {
if (res['success']) {
this.posterInfos = res['data']['posterInfos'];
}
});
}
}
......@@ -10,6 +10,7 @@ export class MyService {
}
private API = environment.BACKEND_URL_CONFIG_VALUE;
// 保存分享码
shareCallBack(shareInfo) {
const url = this.API + '/shareCallBack';
......@@ -30,4 +31,11 @@ export class MyService {
return this.http
.post(url, JSON.stringify({id: id, announcementTypeId: announcementTypeId}));
}
// 产品海报
posterQuery(paginationInfo) {
const url = this.API + '/posterQuery';
return this.http
.post(url, JSON.stringify(paginationInfo));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment