const _Http = getApp().globalData.http, { formatTime } = require("../../../../utils/getTime"); import { tianditu } from "../../../../utils/tianditu.js"; const api = new tianditu(); Page({ data: { disabled: true, loading: false, form: [], "content": { sat_orderclueid: null, sat_ordercluefollowuplogid: 0, "logtype": "跟进", "competitor": "", latitude: "", //经度 longitude: "", //纬度 address: "", //逆解析位置 } }, changeState({ detail }) { this.setData({ loading: detail }) }, async onLoad(options) { getApp().globalData.Language.getLanguagePackage(this, '跟进'); let date = formatTime(new Date(), '-').split(' '), time = date[1].split(":"), that = this; time.pop() let form = [{ label: "跟进日期", error: false, errMsg: "", type: "date", value: date[0], placeholder: "跟进日期", valueName: "createdate", checking: "base", required: true }, { label: "跟进时间", error: false, errMsg: "", type: "time", value: time.join(":"), placeholder: "跟进时间", valueName: "time", checking: "base", required: true }, { label: "跟进类型", error: false, errMsg: "", type: "option", optionNmae: "followupmode", optionType: "radio", //复选 radio 单选 value: "", placeholder: "选择跟进方式", valueName: "followupmode", checking: "base", required: true }, { label: "跟进内容", error: false, errMsg: "", type: "textarea", value: "", placeholder: "跟进内容", valueName: "content", checking: "base", required: false }] if (options.sat_orderclueid) { this.data.content.sat_orderclueid = options.sat_orderclueid; wx.getLocation({ type: 'wgs84', altitude: true, isHighAccuracy: true, highAccuracyExpireTime: 5000, success({ latitude, longitude }) { api.getPlace(longitude, latitude).then((place) => { console.log("获取逆解析地址", place) that.setData({ "content.address": place.result.formatted_address, "content.latitude": latitude, "content.longitude": longitude }) }) }, fail(err) { console.log(err) } }) } else if (options.data) { let data = JSON.parse(options.data); date = data.createdate.split(' '); time = date[1].split(":"); time.pop() form[0].value = date[0]; form[1].value = time.join(":"); form[2].value = data.followupmode; form[3].value = data.content; this.data.content = data; if (data.attinfo.length) this.selectComponent("#Yl_files").handleFiles(data.attinfo) } this.selectComponent("#Form").confirm() this.setData({ form }) }, /* 绑定媒体 */ insertImgEdit({ detail }) { this.handleFileLink(detail) }, handleFileLink(attachmentids, ownertable = "temporary", ownerid = 1, data) { _Http.basic({ "classname": "system.attachment.Attachment", "method": "createFileLink", "content": { ownertable, ownerid, usetype: 'default', attachmentids } }).then(res => { console.log('跟进记录绑定附件', res) if (res.code != '1') return wx.showToast({ title: res.msg, icon: "none" }) if (ownertable == 'temporary') { this.selectComponent("#Yl_files").handleFiles(res.data) } else { if (res.data.length) data.attinfos = res.data; this.changeItem(data) setTimeout(() => { wx.navigateBack() }, 500) } }) }, changeItem(data) { this.setData({ loading: false }) if (_Http.changeItem) _Http.changeItem(data) }, submit() { this.setData({ loading: true }) let content = Object.assign(this.data.content, this.selectComponent("#Form").submit()) content.createdate = content.createdate + ' ' + content.time + ':00'; delete(content.time) _Http.basic({ "id": 20221208100602, content }).then(res => { console.log("保存跟进内容", res) wx.showToast({ title: res.code != '1' ? res.msg : content.sat_ordercluefollowuplogid == 0 ? getApp().globalData.Language.getMapText('保存成功') : getApp().globalData.Language.getMapText('修改成功'), icon: "none", mask: res.code == '1' }); if (res.code != '1') return; let attachmentids = this.selectComponent("#Yl_files").getFiles().attachmentids; if (attachmentids.length) return this.handleFileLink(attachmentids, 'sat_ordercluefollowuplog', res.data.sat_ordercluefollowuplogid, res.data); this.changeItem() setTimeout(() => { wx.navigateBack() }, 500) }) }, onConfirm({ detail }) { this.setData({ disabled: detail }) }, onUnload() { if (this.data.content.sat_ordercluefollowuplogid == 0) this.selectComponent("#Yl_files").deleteAll() } })