diff --git a/src/app/admin/cms/content-edit/content-edit.component.html b/src/app/admin/cms/content-edit/content-edit.component.html new file mode 100644 index 0000000..9723747 --- /dev/null +++ b/src/app/admin/cms/content-edit/content-edit.component.html @@ -0,0 +1 @@ +

content-edit works!

diff --git a/src/app/admin/cms/content-edit/content-edit.component.scss b/src/app/admin/cms/content-edit/content-edit.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/admin/cms/content-edit/content-edit.component.ts b/src/app/admin/cms/content-edit/content-edit.component.ts new file mode 100644 index 0000000..f8e4bf2 --- /dev/null +++ b/src/app/admin/cms/content-edit/content-edit.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-content-edit', + templateUrl: './content-edit.component.html', + styleUrls: ['./content-edit.component.scss'] +}) +export class ContentEditComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/app/admin/system/system-msg/system-msg.component.html b/src/app/admin/system/system-msg/system-msg.component.html new file mode 100644 index 0000000..c73d425 --- /dev/null +++ b/src/app/admin/system/system-msg/system-msg.component.html @@ -0,0 +1,178 @@ + + + + 内容管理 + + + 内容发布 + + + + +
+
+
+
+ + 站内信标题 + + + + +
+
+ + 站内信类型 + + + + + + + + + +
+
+ + 跳转类型 + + + + + + + + + + +
+ +
+ +
+
+ + +
+
+
+
+ +
+ 共计 {{total}} 条数据 +
+ +
+ + + + 序号 + 标题 + 类型 + 跳转类型 + 消息类型 + 内容 + 状态 + 创建时间 + 操作 + + + + + {{i+1}} + {{data.title}} + {{data.type | msgType : 1 }} + {{data.jumpType | msgType : 2 }} + {{data.msgType | msgType : 3 }} + {{data.content}} + {{data.status == 1? '编辑中': '已发布'}} + {{data.createTime | date:'yyyy-MM-dd hh:mm:ss' }} + + 更多操作 + + + + + + +
+ + + +
+ + + 内容标题 + + + + + + 类型 + + + + + + + + + + + 跳转类型 + + + + + + + + + + {{validateForm.value['jumpType'] == 4 ? '消息内容':'跳转路径'}} + + + + + + 信息图片 + + + +
上传图片
+
+ + + + + +
+
+
+ + + + +
diff --git a/src/app/admin/system/system-msg/system-msg.component.scss b/src/app/admin/system/system-msg/system-msg.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/admin/system/system-msg/system-msg.component.ts b/src/app/admin/system/system-msg/system-msg.component.ts new file mode 100644 index 0000000..b376b15 --- /dev/null +++ b/src/app/admin/system/system-msg/system-msg.component.ts @@ -0,0 +1,180 @@ +import { Component, OnInit } from '@angular/core'; +import {environment} from '../../../../environments/environment'; +import {FormBuilder, FormGroup, Validators} from '_@angular_forms@9.0.7@@angular/forms'; +import {HttpClient} from '_@angular_common@9.0.7@@angular/common/http'; +import {NzMessageService, NzUploadFile} from '_ng-zorro-antd@9.3.0@ng-zorro-antd'; +import {Router} from '_@angular_router@9.0.7@@angular/router'; +import {CommonsService} from '../../../services/commons.service'; +import {MsgService} from '../../../services/msg.service'; + +function getBase64(file: File): Promise { + return new Promise((resolve, reject) => { + const reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = () => resolve(reader.result); + reader.onerror = error => reject(error); + }); +} + +@Component({ + selector: 'app-system-msg', + templateUrl: './system-msg.component.html', + styleUrls: ['./system-msg.component.scss'] +}) +export class SystemMsgComponent implements OnInit { + + + WEB_SERVE_URL = environment.imageUrl; + POST_URL = environment.baseUrl; + searchForm: FormGroup; // 搜索框 + validateForm: FormGroup; // 添加框 + requestData = []; // 列表数据 + nodes = []; // 类型树 + total: number; // 页码 + pageNum = 1; // 页码 + pageSize = 10; // 条码 + loading = true; + editFlag = false; + isVisible = false; + imgFile = []; + previewImage: string | undefined = ''; + previewVisible = false; + id: number; + constructor( + private fb: FormBuilder, + private http: HttpClient, // http请求 + private message: NzMessageService, // 信息提示 + private router: Router, + private common: CommonsService, + private msg: MsgService + ) { + this.WEB_SERVE_URL = environment.baseUrl; + } + + ngOnInit() { + + this.searchForm = this.fb.group({ + type: [null], + jumpType: [null], + title: [null], + }); + + this.validateForm = this.fb.group({ + type: [null, [Validators.required]], + title: [null, [Validators.required]], + jumpType: [null, [Validators.required]], + content: [null, [Validators.required]], + }); + + this.getRequest(true, this.searchForm.value); + + } + + + // 查询列表 + public getRequest(reset: boolean = false, whereObject: object) { + + if (reset) { + this.pageNum = 1; + } + whereObject['pageNum'] = this.pageNum; + whereObject['pageSize'] = this.pageSize; + this.msg.getMsgByList(whereObject, data => { + console.log(data); + this.loading = false; + if (data['return_code'] === '000000') { + this.requestData = data['return_data'].list; + this.total = data['return_data'].total; + } else { + this.message.error(data['return_msg']); + } + }); + } + + // 重置 + public resetForm(): void { + this.searchForm.reset(); + } + + // 新增 + getAdd() { + this.isVisible = true; + this.editFlag = false; + } + + // 编辑 + getEdit(data: object) { + console.log(data); + if (data['image'] != null && data['image'] !== '') { + const logo = String(data['image']); + const logoArray = []; + logoArray.push( + { + uid: 1, + name: logo, + status: 'done', + url: environment.imageUrl + logo + }); + this.imgFile = logoArray; + } + this.id = data['id']; + this.validateForm.patchValue(data); + this.editFlag = true; + this.isVisible = true; + } + + // 提交内容 + handleOk() { + // tslint:disable-next-line:forin + for (const i in this.validateForm.controls) { + this.validateForm.controls[i].markAsDirty(); + this.validateForm.controls[i].updateValueAndValidity(); + if (this.validateForm.controls[i].errors != null) { + this.message.error('必填项不能为空'); + return; + } + } + if (this.imgFile.length !== 0) { + if (this.imgFile[0]['response'] != null) { + this.validateForm.value.image = this.imgFile[0]['response']['return_data'][0]; + } else { + this.validateForm.value.image = this.imgFile[0].name; + } + } + this.msg.insertMsg(this.validateForm.value , data => { + if (data['return_code'] === '000000') { + this.isVisible = false; + this.getRequest(false, this.searchForm.value); + this.message.success('新增成功'); + } else { + this.message.create('error', '修改失败'); + } + }); + } + + // 图片查看 + handlePreview = async (file: NzUploadFile) => { + if (!file.url && !file.preview) { + // tslint:disable-next-line:no-non-null-assertion + file.preview = await getBase64(file.originFileObj!); + } + this.previewImage = file.url || file.preview; + this.previewVisible = true; + } + + public getForbiddenUser(id): void { + const message = '是否发布'; + this.common.showConfirm(message, data => { + if (data) { + this.msg.pushMsg(id, dataUser => { + if (dataUser['return_code'] === '000000') { + this.message.success(dataUser['return_data']); + } else { + this.message.error(dataUser['return_msg']); + } + this.getRequest(false , this.searchForm.value); + }); + } + }); + } +} diff --git a/src/app/pipes/msg/msg-type.pipe.ts b/src/app/pipes/msg/msg-type.pipe.ts new file mode 100644 index 0000000..8df09ef --- /dev/null +++ b/src/app/pipes/msg/msg-type.pipe.ts @@ -0,0 +1,18 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'msgType' +}) +export class MsgTypePipe implements PipeTransform { + + array = { + 1: ['服务通知', '支付信息', '客服信息'], + 2: ['订单详情' , '外部链接' , '内部链接' , '客服信息'], + 3: ['个人信息' , '全局信息'] + }; + + transform(type: number , product: number): string { + return this.array[product][type - 1]; + } + +} diff --git a/src/app/services/msg.service.ts b/src/app/services/msg.service.ts new file mode 100644 index 0000000..d9a59aa --- /dev/null +++ b/src/app/services/msg.service.ts @@ -0,0 +1,52 @@ +import { Injectable } from '@angular/core'; +import {HttpClient} from '_@angular_common@9.0.7@@angular/common/http'; +import {CommonsService} from './commons.service'; +import {environment} from '../../environments/environment'; + +@Injectable({ + providedIn: 'root' +}) +export class MsgService { + + constructor( + private http: HttpClient, + private common: CommonsService + ) { } + + /** + * 查询站内信消息 + * + * @param paramsObject 对象 + * @param callBack 回调 + */ + public getMsgByList(paramsObject: object, callBack) { + this.http.get(environment.baseUrl + 'bsMsg/getMsgByList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => { + callBack(data); + }); + } + + /** + * 新增站内信内容内容 + * + * @param params 上传对象 + * @param callBack 回调 + * @return data 返回结果 + */ + public insertMsg(params: object, callBack) { + this.http.post(environment.baseUrl + 'bsMsg/insertMsg', params).subscribe(data => { + callBack(data); + }); + } + + /** + * 发布站内信 + * + * @param iId id + * @param callBack 回调 + */ + public pushMsg(id: number, callBack) { + this.http.get(environment.baseUrl + 'bsMsg/pushMsg?id=' + id).subscribe(data => { + callBack(data); + }); + } +}