| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- const _Http = getApp().globalData.http;
- const QQMapWX = require('../../utils/qqmap-wx-jssdk.min'),
- qqmapsdk = new QQMapWX({
- key: 'QF6BZ-4IQC5-SN2IH-QL5BW-U4IJO-R3BY4' // 必填
- });
- import {
- formatTime
- } from "../../utils/getTime";
- let timing = null;
- Page({
- data: {
- markers: [],
- content: {},
- time: formatTime(new Date(), '-'),
- form: null,
- continue1: null,
- },
- onLoad(options) {
- this.getLocation();
- timing = setInterval(() => {
- this.setData({
- time: formatTime(new Date(), '-')
- })
- }, 1000);
- this.rander();
- },
- submit() {
- let data = this.selectComponent("#Form").submit(),
- content = this.data.content,
- continue1 = this.data.continue1,
- that = this;
- content.remarks = data.remarks;
- if (continue1 == null) {
- wx.showModal({
- title: '提示',
- content: '是否确认本次签到',
- complete: (res) => {
- if (res.confirm) that.onConfirm(content);
- }
- })
- } else {
- content.ownertable = data[continue1] == '' ? continue1 == 'sa_project' ? 'sys_enterprise' : 'sa_project' : continue1;
- content.ownerid = data[content.ownertable][1][0];
- wx.showModal({
- title: '提示',
- content: `本次签到将跟进${content.ownertable=='sa_project'?'项目':'客户'}“${data[content.ownertable][0]}”`,
- complete: (res) => {
- if (res.confirm) that.onConfirm(content);
- }
- })
- }
- },
- onConfirm(content) {
- _Http.basic({
- id: 20221229145901,
- content
- }).then(res => {
- console.log("签到", res)
- wx.showToast({
- title: res.msg == '成功' ? '签到成功' : res.msg,
- icon: "none"
- })
- if (res.msg == '成功') setTimeout(() => {
- getCurrentPages()[getCurrentPages().length - 2].toDate(this.data.time.split(" ")[0]);
- wx.navigateBack();
- }, 500)
- })
- },
- rander() {
- this.setData({
- form: [{
- label: "客户",
- error: false,
- errMsg: "",
- type: "route",
- url: "/packageA/select/setclient/select",
- radio: true,
- value: "",
- params: {
- "id": 20221012164402,
- content: {
- nocache: true,
- "type": 0,
- "pageNumber": 1,
- "pageSize": 20,
- "isExport": 0,
- "where": {
- "condition": "",
- },
- "sort": [{
- sortname: "默认",
- sorted: 1,
- sortid: 67,
- reversed: 0
- }]
- },
- },
- placeholder: "选择客户",
- valueName: "sys_enterprise",
- checking: "base",
- required: false
- }, {
- label: "项目",
- error: false,
- errMsg: "",
- type: "route",
- url: "/packageA/select/project/select",
- radio: true,
- value: "",
- params: {
- "id": 20221020143502,
- content: {
- nocache: true,
- "type": 0,
- "pageNumber": 1,
- "pageSize": 20,
- "where": {
- "condition": "", //模糊搜索
- },
- },
- },
- placeholder: "选择项目",
- valueName: "sa_project",
- checking: "base",
- required: false
- }, {
- label: "说明",
- error: false,
- errMsg: "",
- type: "textarea",
- value: "",
- placeholder: "请填写",
- valueName: "remarks",
- required: false, //必填
- }],
- continue1: null
- })
- },
- /* 打断处理form */
- interrupt(e) {
- let {
- data,
- form
- } = e.detail,
- that = this;
- console.log("处理", data, form)
- if (this.data.continue1 == null) {
- wx.showModal({
- title: '提示',
- cancelText: "继续选择",
- confirmText: `跟进${data.label}`,
- content: `继续选择"${data.value[0]}"相关${data.label=='客户'?"项目":"客户"},还是跟进当前选择${data.label}?`,
- complete: (res) => {
- if (data.label == '客户') {
- if (res.confirm) {
- form.splice(1, 1);
- that.setData({
- form,
- continue1: "sys_enterprise"
- })
- }
- if (res.cancel) {
- form[1].label = '客户关联项目'
- form[1].params = {
- "id": "20221018102003",
- "content": {
- "nocache": true,
- "pageNumber": 1,
- "pageTotal": 1,
- sys_enterpriseid: data.value[1][0],
- "total": null,
- "type": 1,
- "where": {
- "condition": ""
- }
- }
- }
- that.setData({
- form,
- continue1: "sa_project"
- })
- }
- } else {
- if (res.confirm) {
- form.splice(0, 1);
- that.setData({
- form,
- continue1: "sa_project"
- })
- }
- if (res.cancel) {
- form.splice(0, 1);
- form.splice(1, 0, {
- label: "项目关联客户",
- error: false,
- errMsg: "",
- type: "route",
- url: "/packageA/select/setclient/select",
- radio: true,
- value: "",
- params: {
- "id": "20221027143702",
- content: {
- nocache: true,
- sa_projectid: data.value[1][0],
- pageNumber: 1,
- pageTotal: 1,
- pageSize: 10,
- total: null,
- where: {
- condition: "",
- }
- },
- },
- placeholder: "选择客户",
- valueName: "sys_enterprise",
- checking: "base",
- required: false
- });
- that.setData({
- form,
- continue1: "sys_enterprise"
- })
- }
- }
- }
- })
- } else {
- if (data.valueName != this.data.continue1 && form.length == 3) {
- form[1].params.sa_projectid = data.value[1][0];
- form[1].params.sys_enterpriseid = data.value[1][0];
- form[1].value = "";
- }
- this.setData({
- form
- })
- }
- },
- /* 获取定位 */
- getLocation() {
- let that = this;
- wx.showLoading({
- title: '定位中...',
- });
- wx.getLocation({
- type: 'gcj02',
- isHighAccuracy: true,
- highAccuracyExpireTime: 8000,
- success({
- latitude,
- longitude
- }) {
- wx.hideLoading();
- that.setData({
- 'markers[0]': {
- id: 1,
- latitude,
- longitude,
- }
- });
- qqmapsdk.reverseGeocoder({
- location: {
- latitude,
- longitude
- },
- success(s) {
- console.log("逆解析", s)
- that.setData({
- content: {
- province: s.result.address_component.province,
- city: s.result.address_component.city,
- county: s.result.address_component.district,
- address: s.result.address,
- longitude,
- latitude,
- remarks: "",
- ownertable: "",
- ownerid: ""
- }
- })
- },
- fail(err) {
- console.log(err)
- wx.showToast({
- title: '定位失败',
- icon: "none"
- })
- }
- })
- },
- fail(err) {
- console.log(err)
- wx.showToast({
- title: '定位失败',
- icon: "none"
- })
- }
- })
- },
- onUnload() {
- clearInterval(timing)
- },
- onReady() {
- },
- })
|