Newer
Older
import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {Response} from '@angular/http';
import {AppService} from '../../../service/appHttpService';
selector: 'page-contract-personinfo',
templateUrl: 'contract-personinfo.html',
contactPersonInfo = {
gender: '',
telephone: '',
email: '',
abbreviation: ''
constructor(public navCtrl: NavController,
public navParams: NavParams,
public appService: AppService) {
ionViewDidLoad() {
this.id = this.navParams.get("id");
this.getPersonInfo();
this.getRole();
}
//获取权限
getRole(){
this.appService.ObserverHttpGet("/wisdomgroup/app/getRoles", null).subscribe((res: Response) => {
this.role = res.json();
}, error => {
this.appService.alert('系统错误!');
});
this.appService.ObserverHttpGet("/wisdomgroup/modules/telpBookPerson", data)
this.email = this.contactPersonInfo.email;
this.abbreviation = this.contactPersonInfo.abbreviation;
this.telephone = this.contactPersonInfo.telephone;
//添加常用联系人
addcontactPersons() {
const data = {
'relUserId': this.id,
'moduleName': 'appcontact'
}
this.appService.ObserverHttpPostOption("/wisdomgroup/app/contact/addGeneralContactPersons", data)
if (data["result"] == '2') {
this.appService.popToastView('该联系人已在常用联系人中!', 'top', 2000);
} else if (data["result"] == '3') {
this.appService.popToastView('添加常用联系人失败!', 'top', 2000);
} else {
this.appService.popToastView('添加常用联系人成功!','middle',2000);
this.getPersonInfo();
// this.navCtrl.push("ContactListPage");
const data = {
relUserId: this.id,
moduleName: 'appcontact',
};
this.appService.ObserverHttpPost("/wisdomgroup/app/contact/deleteGeneralContactPersons", data)
this.getPersonInfo();
this.appService.popToastView('移除常用联系人成功!', 'middle', 2000);
}
call(number) {
console.log("拨打:" + number);
window.location.href = "tel:" + number;
}
editFun() {
this.edit = true;
}
//跳转设置分组
usualContactSet() {
this.navCtrl.push('MyBlockPage', {'item': this.contactPersonInfo});
}
//取消编辑
editCancel() {
this.getPersonInfo();
this.edit = false;
}
//完成
editDone() {
const data = {
email: this.email,
telephone: this.telephone,
abbreviation: this.abbreviation
this.appService.ObserverHttpPut("/wisdomgroup/modules/telpBookPerson/", this.id, data)
.subscribe((res: Response) => {
let data = res.json();
}, error => {
this.appService.alert('网络异常!');
}
);
this.edit = false;