|
@@ -1,5 +1,6 @@
|
|
const app = require('../../utils/util.js');
|
|
const app = require('../../utils/util.js');
|
|
var util = require('../../utils/md5.js')
|
|
var util = require('../../utils/md5.js')
|
|
|
|
+import WxValidate from '../../utils/WxValidate';
|
|
var QQMapWX = require('../../libs/qqmap-wx-jssdk.min.js');
|
|
var QQMapWX = require('../../libs/qqmap-wx-jssdk.min.js');
|
|
Page({
|
|
Page({
|
|
data: {
|
|
data: {
|
|
@@ -8,6 +9,11 @@ Page({
|
|
lat: '', // 纬度
|
|
lat: '', // 纬度
|
|
visitLocation: '',
|
|
visitLocation: '',
|
|
info: '', //老人锕
|
|
info: '', //老人锕
|
|
|
|
+ imgPath: [],
|
|
|
|
+ isTrue: true,
|
|
|
|
+ index: 0,
|
|
|
|
+ visitPhoto: '',
|
|
|
|
+ infoId: '',
|
|
},
|
|
},
|
|
oldClick(e) {
|
|
oldClick(e) {
|
|
let fid = e.currentTarget.dataset.infos.fid;
|
|
let fid = e.currentTarget.dataset.infos.fid;
|
|
@@ -37,6 +43,160 @@ Page({
|
|
time: Y + '-' + M + '-' + D
|
|
time: Y + '-' + M + '-' + D
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ submitInfo(params) {
|
|
|
|
+ wx.request({
|
|
|
|
+ url: app.globalData.publicUrl + '/applet/suppleUserInfo',
|
|
|
|
+ method: "POST",
|
|
|
|
+ data: params,
|
|
|
|
+ header: {
|
|
|
|
+ appletsId: wx.getStorageSync('openId')
|
|
|
|
+ },
|
|
|
|
+ success: (res) => {
|
|
|
|
+ if (res.data.code == 0) {
|
|
|
|
+ console.log(res, "0000");
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ zhaopian() {
|
|
|
|
+ var that = this;
|
|
|
|
+ wx.chooseImage({
|
|
|
|
+ count: 1,
|
|
|
|
+ sizeType: ['compressed'],
|
|
|
|
+ sourceType: ['camera'],
|
|
|
|
+ success: function (res) {
|
|
|
|
+ var tempFilePaths = res.tempFilePaths
|
|
|
|
+ wx.uploadFile({
|
|
|
|
+ url: app.globalData.publicUrl + '/sys/user/upload',
|
|
|
|
+ filePath: tempFilePaths[0],
|
|
|
|
+ name: 'uploadFile',
|
|
|
|
+ formData: {
|
|
|
|
+ "user": "test",
|
|
|
|
+ },
|
|
|
|
+ header: {
|
|
|
|
+ appletsId: wx.getStorageSync('openId'),
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ success: function (res) {
|
|
|
|
+ console.log(JSON.parse(res.data), "45454545");
|
|
|
|
+ let datas = JSON.parse(res.data)
|
|
|
|
+ if (datas.code == 0) {
|
|
|
|
+ if (that.data.imgPath.length < 3) {
|
|
|
|
+ that.data.imgPath.push(datas.data)
|
|
|
|
+ that.setData({
|
|
|
|
+ imgPath: that.data.imgPath
|
|
|
|
+ })
|
|
|
|
+ that.data.visitPhoto = that.data.imgPath.join(',')
|
|
|
|
+ if (that.data.imgPath.length == 2) {
|
|
|
|
+ that.setData({
|
|
|
|
+ isTrue: false
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ closeImage(e) {
|
|
|
|
+ console.log(e.currentTarget.dataset.index, "00");
|
|
|
|
+ this.data.imgPath.splice(e.currentTarget.dataset.index, 1);
|
|
|
|
+ this.setData({
|
|
|
|
+ imgPath: this.data.imgPath,
|
|
|
|
+ })
|
|
|
|
+ let aa = this.data.imgPath.join(',')
|
|
|
|
+ this.setData({
|
|
|
|
+ visitPhoto: aa,
|
|
|
|
+ })
|
|
|
|
+ if (this.data.imgPath.length == 0) {
|
|
|
|
+ this.setData({
|
|
|
|
+ isTrue: true
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ console.log(this.data.imgPath, "00000000000");
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ formSubmit(e) {
|
|
|
|
+ console.log(e.detail, "daying");
|
|
|
|
+ /***4-3(表单提交校验)*/
|
|
|
|
+ const params = e.detail.value
|
|
|
|
+ if (!this.WxValidate.checkForm(params)) {
|
|
|
|
+ const error = this.WxValidate.errorList[0]
|
|
|
|
+ this.showModal(error)
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ /*** 这里添写验证成功以后的逻辑**/
|
|
|
|
+ //验证通过以后->
|
|
|
|
+ this.submitInfo(params);
|
|
|
|
+ },
|
|
|
|
+ submitInfo(params) {
|
|
|
|
+ console.log(params);
|
|
|
|
+ console.log(this.data.visitPhoto, "照片");
|
|
|
|
+ console.log(this.data.infoId);
|
|
|
|
+
|
|
|
|
+ if (this.data.visitPhoto.length > 0) {
|
|
|
|
+ let obj = {};
|
|
|
|
+ obj = {
|
|
|
|
+ ...params,
|
|
|
|
+ infoId: this.data.infoId,
|
|
|
|
+ visitPhoto: this.data.visitPhoto,
|
|
|
|
+ lat: this.data.lat,
|
|
|
|
+ lng: this.data.lng,
|
|
|
|
+ visitLocation:this.data.visitLocation
|
|
|
|
+ }
|
|
|
|
+ wx.request({
|
|
|
|
+ url: app.globalData.publicUrl + '/visit/add',
|
|
|
|
+ method: "POST",
|
|
|
|
+ header: {
|
|
|
|
+ appletsId: wx.getStorageSync('openId')
|
|
|
|
+ },
|
|
|
|
+ data: obj,
|
|
|
|
+ success: (res) => {
|
|
|
|
+ console.log(res, "打印锕");
|
|
|
|
+ console.log(res.data.code, "打印锕000000");
|
|
|
|
+ if (res.data.code == 0) {
|
|
|
|
+ wx.showModal({
|
|
|
|
+ showCancel: false,
|
|
|
|
+ content: '提交成功',
|
|
|
|
+ success() {
|
|
|
|
+ wx.switchTab({
|
|
|
|
+ url: '/pages/index/index',
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ } else if (res.data.code == 1) {
|
|
|
|
+ console.log("进来了啊");
|
|
|
|
+
|
|
|
|
+ wx.showModal({
|
|
|
|
+ showCancel: false,
|
|
|
|
+ content: res.data.message,
|
|
|
|
+ success() {
|
|
|
|
+ wx.switchTab({
|
|
|
|
+ url: '/pages/index/index',
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: '请上传现场照片',
|
|
|
|
+ icon: 'none',
|
|
|
|
+ duration: 2000,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ showModal(error) {
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: error.msg,
|
|
|
|
+ icon: 'none',
|
|
|
|
+ duration: 2000,
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
//获取位置
|
|
//获取位置
|
|
getSelfLocation: function (varSendOrgId) {
|
|
getSelfLocation: function (varSendOrgId) {
|
|
|
|
|
|
@@ -112,9 +272,68 @@ Page({
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ initValidate() {
|
|
|
|
+ const rules = {
|
|
|
|
+ health: {
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ mind: {
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ security: {
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ hygiene: {
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ live: {
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ demand: {
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ visitMessage: {
|
|
|
|
+ required: true,
|
|
|
|
+ },
|
|
|
|
+ };
|
|
|
|
+ const messages = {
|
|
|
|
+ health: {
|
|
|
|
+ required: '请选择健康状况',
|
|
|
|
+ },
|
|
|
|
+ mind: {
|
|
|
|
+ required: '请选择精神状态',
|
|
|
|
+ },
|
|
|
|
+ security: {
|
|
|
|
+ required: '请选择安全情况',
|
|
|
|
+ },
|
|
|
|
+ hygiene: {
|
|
|
|
+ required: '请选择卫生环境',
|
|
|
|
+ },
|
|
|
|
+ live: {
|
|
|
|
+ required: '请选择居住环境',
|
|
|
|
+ },
|
|
|
|
+ visitMessage: {
|
|
|
|
+ required: '请输入备注说明',
|
|
|
|
+ },
|
|
|
|
+ demand: {
|
|
|
|
+ required: '请输入老人需求',
|
|
|
|
+ },
|
|
|
|
+ };
|
|
|
|
+ // 创建实例对象
|
|
|
|
+ this.WxValidate = new WxValidate(rules, messages)
|
|
|
|
+ },
|
|
|
|
+
|
|
onLoad: function (opotions) {
|
|
onLoad: function (opotions) {
|
|
|
|
+ console.log(opotions,"dayin");
|
|
|
|
+
|
|
this.time();
|
|
this.time();
|
|
this.getSelfLocation();
|
|
this.getSelfLocation();
|
|
this.oldsInfo(opotions.id);
|
|
this.oldsInfo(opotions.id);
|
|
|
|
+ this.setData({
|
|
|
|
+ imgPath: [],
|
|
|
|
+ infoId: opotions.id
|
|
|
|
+ })
|
|
|
|
+ console.log(this.data.imgPath, "照片啊锕 锕啊 ");
|
|
|
|
+ this.initValidate();
|
|
},
|
|
},
|
|
})
|
|
})
|