const _Http = getApp().globalData.http; Page({ data: { contacts: [], form1: [], form2: [], show: false, actions: [{ name: "呼叫" }, { name: "复制" }] }, onLoad(options) { this.handleData(JSON.parse(options.item)) }, handleData(item) { const form1 = [{ label: "性别", content: item.sex }, { label: "生日", content: item.birthday }, { label: "家庭住址", content: item.homeaddress }, { label: "邮箱", content: item.email }], form2 = [{ label: "单位", content: item.company }, { label: "部门", content: item.depname }, { label: "职位", content: item.position }] this.setData({ contacts: item, form1, form2 }) }, changeShow() { this.setData({ show: !this.data.show }) }, /* 处理选择 */ handleSelect(e) { let phone = this.data.contacts.phonenumber; if (e.detail.name == '复制') { wx.setClipboardData({ data: phone }); } else { wx.makePhoneCall({ phoneNumber: phone, }) }; this.changeShow() }, /* 拷贝内容 */ copyContents(e) { const { data } = e.currentTarget.dataset; if (data) wx.setClipboardData({ data, }); }, /* 去编辑 */ toEdit() { let data = JSON.stringify(this.data.contacts); wx.navigateTo({ url: '../contacts/edit?data=' + data, }) }, /* 删除 */ deleteData() { const that = this; wx.showModal({ title: "提示", content: `是否确认删除${this.data.contacts.name}`, success({ confirm }) { if (confirm) _Http.basic({ "id": "20220831164703", "version": 1, "content": { "sys_phonebookid": that.data.contacts.sys_phonebookid } }).then(res => { if (res.msg != '成功') return wx.showToast({ title: res.data, icon: "none" }) getCurrentPages().forEach(v => { if (v.route === 'packageA/contacts/index') { v.getGroup(); } else if (v.route === 'packageA/contacts/list') { let arr = v.data.phonebook.filter(v => v.sys_phonebookid != that.data.contacts.sys_phonebookid); v.setData({ phonebook: arr }) } }); wx.showToast({ title: '删除成功', icon: 'none' }) setTimeout(() => { wx.navigateBack({ delta: 0, }) }, 500); }) } }) }, onShareAppMessage() {} })