roose 4 лет назад
Родитель
Сommit
ce94537631

+ 1 - 3
app.json

@@ -2,9 +2,8 @@
   "pages": [
     "pages/index/index",
     "pages/love/love",
-   
+    "pages/finishInfo/finishInfo",
     "pages/login/login",
-
     "pages/updatepassword/updatepassword",
     "pages/visitandinfo/visitandinfo",
     "pages/idCard/idCard",
@@ -12,7 +11,6 @@
     "pages/card/card",
     "pages/paiming/paiming",
     "pages/personInfo/personInfo",
-    "pages/finishInfo/finishInfo",
     "pages/collectInfo/collectInfo"
   ],
   "window": {

+ 44 - 10
pages/finishInfo/finishInfo.js

@@ -9,7 +9,14 @@ Page({
     posttext: '请选择',
     incometext: '请选择',
     educationtext: '请选择',
-
+    userName: '', //姓名
+    idCardNumber: '', //身份证号码
+    age: '', //年龄
+    parameter: [{
+      name: '男'
+    }, {
+      name: '女',
+    }],
     postList: [{
         name: '在职人员'
       },
@@ -31,7 +38,7 @@ Page({
     ],
 
     incomeList: [{
-        name: '没有收入'
+        name: '暂无'
       },
       {
         name: '500元以下'
@@ -171,20 +178,20 @@ Page({
 
   initValidate() {
     const rules = {
-      name: {
+      userName: {
         required: true,
       },
       sex: {
         required: true,
       },
-      card: {
+      idCardNumber: {
         required: true,
         idcard: true,
       },
       age: {
         required: true,
       },
-      post: {
+      job: {
         required: true,
       },
       income: {
@@ -197,20 +204,20 @@ Page({
 
     };
     const messages = {
-      name: {
+      userName: {
         required: '姓名不能为空',
       },
       sex: {
         required: '性别不能为空',
       },
-      card: {
+      idCardNumber: {
         required: '身份证号不能为空',
         idcard: '身份证号格式错误 ',
       },
       age: {
         required: '年龄不能为空',
       },
-      post: {
+      job: {
         required: '职务不能为空',
       },
       income: {
@@ -245,8 +252,8 @@ Page({
   },
   submitInfo(params) {
     wx.request({
-      url: app.globalData.publicUrl + '/wxinfo/listByOpenid',
-      method: "GET",
+      url: app.globalData.publicUrl + '/applet/suppleUserInfo',
+      method: "POST",
       data: params,
       header: {
         appletsId: wx.getStorageSync('openId')
@@ -259,7 +266,34 @@ Page({
       }
     })
   },
+  userInfo() {
+    wx.request({
+      url: app.globalData.publicUrl + '/sys/login/session',
+      method: "GET",
+      header: {
+        appletsId: wx.getStorageSync('openId')
+      },
+      success: (res) => {
+        console.log(res.data.data, "000");
+        this.data.parameter.forEach(item => {
+          if (item.name == res.data.data.sex) {
+            item.checked = true;
+          }
+        })
+        this.setData({
+          userName: res.data.data.userName,
+          parameter: this.data.parameter,
+          idCardNumber: res.data.data.idCardNumber,
+          age: res.data.data.age,
+          posttext: res.data.data.job,
+          incometext: res.data.data.income,
+          educationtext: res.data.data.education,
+        })
+      }
+    })
+  },
   onLoad: function () {
     this.initValidate();
+    this.userInfo();
   },
 })

+ 7 - 10
pages/finishInfo/finishInfo.wxml

@@ -9,30 +9,27 @@
 		<view class="box">
 			<view class="flex-box">
 				<view class="small-box">姓名</view>
-				<input name='name' class="weui-input" placeholder="请输入" />
+				<input name='userName' value="{{userName}}" class="weui-input" placeholder="请输入" />
 			</view>
 			<view class="flex-box">
 				<view class="small-box">性别</view>
-				<!-- <van-radio-group name="sex">
-					<van-radio >男</van-radio>
-					<van-radio value="女">女</van-radio>
-				</van-radio-group> -->
 				<radio-group name="sex">
-					<radio color='#009FE9' value='男'>男</radio>
-					<radio color='#009FE9' value='女'>女</radio>
+					<label wx:for="{{parameter}}">
+						<radio checked="{{item.checked}}" color='#009FE9' value="{{ item.name }}">{{item.name}}</radio>
+					</label>
 				</radio-group>
 			</view>
 			<view class="flex-box">
 				<view class="small-box">身份证号</view>
-				<input name='card' class="weui-input" placeholder="请输入" />
+				<input name='idCardNumber' value="{{idCardNumber}}" class="weui-input" placeholder="请输入" />
 			</view>
 			<view class="flex-box">
 				<view class="small-box">年龄</view>
-				<input name='age' class="weui-input" placeholder="请输入" />
+				<input name='age' value="{{age}}" class="weui-input" placeholder="请输入" />
 			</view>
 			<view class="flex-box">
 				<view class="small-box">职务</view>
-				<picker bindchange="postListChange" name="post" value="{{postList[postindex].name}}" range-key="{{'name'}}" range="{{postList}}">
+				<picker bindchange="postListChange" name="job" value="{{postList[postindex].name}}" range-key="{{'name'}}" range="{{postList}}">
 					<view class="picker">
 						{{postList[postindex].name}} <text class="wenzi">{{posttext}}</text>
 					</view>

+ 4 - 0
pages/finishInfo/finishInfo.wxss

@@ -46,6 +46,7 @@ button:not([size='mini']) {
   color: white;
   background: #1989FA;
   font-size: 28rpx;
+ 
 }
 
 .register {
@@ -67,3 +68,6 @@ radio:last-child {
 .home {
   font-size: 28rpx;
 }
+.image {
+  
+}

+ 22 - 14
pages/index/index.js

@@ -32,7 +32,7 @@ Page({
       url: '/pages/visitandinfo/visitandinfo',
     })
   },
-  goTongzhi(){
+  goTongzhi() {
     wx.navigateTo({
       url: '/pages/notice/notice',
     })
@@ -43,19 +43,27 @@ Page({
     })
   },
   goSaoMa() {
-     console.log("扫阿");
-     var _this = this;
-     // 允许从相机和相册扫码
-     wx.scanCode({
-       success: (res) => {
-         console.log(res,"打印锕");
-         let length = res.result.substring(res.result.lastIndexOf('/')+1,res.result.length)
-      
-         wx.navigateTo({
-           url: '/pages/love/love?id='+length,
-         })
-       }
-     })
+    console.log("扫阿");
+    var _this = this;
+    // 允许从相机和相册扫码
+    wx.scanCode({
+      onlyFromCamera: true,
+      success: (res) => {
+        console.log(res, "打印锕");
+        let length = res.result.substring(res.result.lastIndexOf('/') + 1, res.result.length)
+        wx.navigateTo({
+          url: '/pages/love/love?id=' + length,
+        })
+      },
+      fail: (res) => {
+        console.log(res, "假的");
+        wx.showToast({
+          title: '当前不是二维码,请扫二维码',
+          icon: 'none',
+          duration: 2000,
+        })
+      }
+    })
   },
 
   onLoad() {

+ 219 - 0
pages/love/love.js

@@ -1,5 +1,6 @@
 const app = require('../../utils/util.js');
 var util = require('../../utils/md5.js')
+import WxValidate from '../../utils/WxValidate';
 var QQMapWX = require('../../libs/qqmap-wx-jssdk.min.js');
 Page({
   data: {
@@ -8,6 +9,11 @@ Page({
     lat: '', // 纬度
     visitLocation: '',
     info: '', //老人锕
+    imgPath: [],
+    isTrue: true,
+    index: 0,
+    visitPhoto: '',
+    infoId: '',
   },
   oldClick(e) {
     let fid = e.currentTarget.dataset.infos.fid;
@@ -37,6 +43,160 @@ Page({
       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) {
 
@@ -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) {
+    console.log(opotions,"dayin");
+    
     this.time();
     this.getSelfLocation();
     this.oldsInfo(opotions.id);
+    this.setData({
+      imgPath: [],
+      infoId: opotions.id
+    })
+    console.log(this.data.imgPath, "照片啊锕  锕啊 ");
+    this.initValidate();
   },
 })

+ 47 - 34
pages/love/love.wxml

@@ -18,39 +18,52 @@
 		<view class="old-btn" bindtap="oldClick" data-infos='{{info}}'>老人详情</view>
 	</view>
 	<view class="title">探访情况</view>
-	<view class="title">健康状况</view>
-	<radio-group name="health">
-		<radio color='#009FE9' value='健康'>健康</radio>
-		<radio color='#009FE9' value='一般'>一般</radio>
-		<radio color='#009FE9' value='较差'>较差</radio>
-	</radio-group>
-	<view class="title">精神状态</view>
-	<radio-group name="mind">
-		<radio color='#009FE9' value='良好'>良好</radio>
-		<radio color='#009FE9' value='一般'>一般</radio>
-		<radio color='#009FE9' value='较差'>较差</radio>
-	</radio-group>
-	<view class="title">安全情况</view>
-	<radio-group name="security">
-		<radio color='#009FE9' value='安全'>安全</radio>
-		<radio color='#009FE9' value='一般'>一般</radio>
-		<radio color='#009FE9' value='较差'>较差</radio>
-	</radio-group>
-	<view class="title">卫生环境</view>
-	<radio-group name="hygiene">
-		<radio color='#009FE9' value='安全'>良好</radio>
-		<radio color='#009FE9' value='一般'>一般</radio>
-		<radio color='#009FE9' value='较差'>较差</radio>
-	</radio-group>
-	<view class="title">居中环境</view>
-	<radio-group name="live">
-		<radio color='#009FE9' value='安全'>良好</radio>
-		<radio color='#009FE9' value='一般'>一般</radio>
-		<radio color='#009FE9' value='较差'>较差</radio>
-	</radio-group>
-	<view class="title">老人需求说明</view>
-	<textarea class="view_textarea" name="demand" bindblur="bindTextAreaBlur" placeholder="请填写一下老人需求" />
-	<view class="title">探访备注说明</view>
+	<form bindsubmit="formSubmit">
+		<view class="title">健康状况</view>
+		<radio-group name="health">
+			<radio color='#009FE9' value='健康'>健康</radio>
+			<radio color='#009FE9' value='一般'>一般</radio>
+			<radio color='#009FE9' value='较差'>较差</radio>
+		</radio-group>
+		<view class="title">精神状态</view>
+		<radio-group name="mind">
+			<radio color='#009FE9' value='良好'>良好</radio>
+			<radio color='#009FE9' value='一般'>一般</radio>
+			<radio color='#009FE9' value='较差'>较差</radio>
+		</radio-group>
+		<view class="title">安全情况</view>
+		<radio-group name="security">
+			<radio color='#009FE9' value='安全'>安全</radio>
+			<radio color='#009FE9' value='一般'>一般</radio>
+			<radio color='#009FE9' value='较差'>较差</radio>
+		</radio-group>
+		<view class="title">卫生环境</view>
+		<radio-group name="hygiene">
+			<radio color='#009FE9' value='安全'>良好</radio>
+			<radio color='#009FE9' value='一般'>一般</radio>
+			<radio color='#009FE9' value='较差'>较差</radio>
+		</radio-group>
+		<view class="title">居中环境</view>
+		<radio-group name="live">
+			<radio color='#009FE9' value='安全'>良好</radio>
+			<radio color='#009FE9' value='一般'>一般</radio>
+			<radio color='#009FE9' value='较差'>较差</radio>
+		</radio-group>
+		<view class="title">老人需求说明</view>
+		<textarea class="view_textarea" name="demand" bindblur="bindTextAreaBlur" placeholder="请填写一下老人需求" />
+		<view class="title">探访备注说明</view>
 	<textarea class="view_textarea"  name="visitMessage" bindblur="bindTextAreaBlur" placeholder="请填写一下探访备注说明" />
-	<view class=" old-btn  " style=" width: 255rpx;   margin-top: 40rpx; margin-bottom: 40rpx;">现场含面部照片(正面照)</view>
+	<view  class="title">现场含面部照片(正面照)</view>
+		<view  style=" border: 1rpx solid #5398C8; color: #fff;  padding-left: 10rpx;background-color: #429EFF; font-size: 26rpx;width: 220rpx;margin-top: 40rpx; margin-bottom: 40rpx;" bindtap="zhaopian" wx:if='{{isTrue}}'>请上传含面部照片</view>
+		<view style="  display: flex;">
+			<view wx:for='{{imgPath}}' class="img-box">
+			<image class="image"  src="http://info.windd.cn:8080/test{{item}}"  mode='scaleToFill' bindtap="previewImg"></image>
+			<van-icon size='23' name="clear" class="close" data-index="{{index}}" bindtap="closeImage"/>
+		</view>
+		</view>
+	
+			<view class="register">
+				<button formType="submit">提交</button>
+			</view>
+				</form>
 </view>

+ 30 - 0
pages/love/love.wxss

@@ -28,6 +28,7 @@
   font-size: 24rpx;
   padding: 5rpx 10rpx;
   border-radius: 10rpx;
+
 }
 
 .view_textarea {
@@ -55,4 +56,33 @@ radio:nth-child(3) {
   text-align: center;
   font-size: 26rpx;
 
+}
+
+button:not([size='mini']) {
+  width: 100% !important;
+  margin-left: auto;
+  margin-right: auto;
+  color: white;
+  background: #1989FA;
+  font-size: 28rpx;
+  margin-bottom: 40rpx;
+
+}
+
+.close {
+  position: absolute;
+  top: 10rpx;
+  left: 158rpx;
+
+}
+
+.image {
+  width: 200rpx;
+  height: 200rpx;
+}
+.img-box {
+  position: relative;
+}
+.img-box:nth-child(2) {
+  margin-left: 20rpx;
 }

+ 1 - 1
utils/util.js

@@ -2,7 +2,7 @@ const globalData = {
   
   publicUrl: 'http://info.windd.cn:8080/test',
 
-
+ //publicUrl: 'http://10.16.4.8:7001',
 };
 module.exports = {
   globalData: globalData,