|
|
@@ -1,308 +1,332 @@
|
|
|
const _Http = getApp().globalData.http;
|
|
|
const QQMapWX = require('../../utils/qqmap-wx-jssdk.min'),
|
|
|
- qqmapsdk = new QQMapWX({
|
|
|
- key: 'QF6BZ-4IQC5-SN2IH-QL5BW-U4IJO-R3BY4' // 必填
|
|
|
- });
|
|
|
+ qqmapsdk = new QQMapWX({
|
|
|
+ key: 'QF6BZ-4IQC5-SN2IH-QL5BW-U4IJO-R3BY4' // 必填
|
|
|
+ });
|
|
|
import {
|
|
|
- formatTime
|
|
|
+ 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];
|
|
|
+ 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() {
|
|
|
+ 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: function (e) {
|
|
|
+ //这里是获取失败的时候
|
|
|
+ wx.hideLoading();
|
|
|
+ wx.getSetting({
|
|
|
+ success: res => {
|
|
|
+ if (typeof (res.authSetting['scope.userLocation']) != 'undefined' && !res.authSetting['scope.userLocation']) {
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '您拒绝了定位权限,将无法使用签到功能 是否前往开启',
|
|
|
+ success: res => {
|
|
|
+ if (res.confirm) {
|
|
|
+ wx.openSetting({
|
|
|
+ success: res => {
|
|
|
+ if (res.authSetting['scope.userLocation']) {
|
|
|
+ that.getLocation();
|
|
|
+ } else {
|
|
|
+ // 没有允许定位权限
|
|
|
+ wx.showToast({
|
|
|
+ title: '没有允许定位权限',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onUnload() {
|
|
|
+ clearInterval(timing)
|
|
|
+ },
|
|
|
+ onReady() {
|
|
|
|
|
|
- },
|
|
|
+ },
|
|
|
})
|