// index.ts
|
// 获取应用实例
|
const loginInfo = getApp()
|
import Toast from '../../../miniprogram_npm/@vant/weapp/toast/toast';
|
import Notify from '../../../miniprogram_npm/@vant/weapp/notify/notify';
|
let myStyle = `
|
--color:black;
|
`
|
|
let chageStyle = `
|
--color:red;
|
`
|
Page({
|
data: {
|
user:{},
|
isShow:false,
|
pic:null,
|
viewData: {
|
style: myStyle,
|
styleId:myStyle
|
}
|
},
|
|
getName(e){
|
if(e.detail.value){
|
this.setData({'viewData.style': myStyle})
|
}
|
this.data.user.realName=e.detail.value
|
},
|
getIdcard(e){
|
if(e.detail.value){
|
this.setData({'viewData.styleId': myStyle})
|
}
|
this.data.user.userIdcard=e.detail.value
|
},
|
getPhoneNumber:function(e){
|
console.log(e);
|
|
},
|
submit(){
|
if(!/^[\u4e00-\u9fa5]{2,4}$/.test(this.data.user.realName)){
|
// Toast.fail('请输入正确的姓名');
|
Notify({ type: 'warning', message: '请输入正确的姓名' });
|
this.setData({'viewData.style': chageStyle})
|
return
|
}
|
if(!/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(this.data.user.userIdcard)){
|
// Toast.fail('请输入正确的身份证号');
|
Notify({ type: 'warning', message: '请输入正确的身份证号' });
|
this.setData({'viewData.styleId': chageStyle})
|
return
|
}
|
this.data.user.pic=this.data.pic
|
this.data.user.id=wx.getStorageSync('id')
|
if ( this.data.user.pic == null||this.data.user.realName==null|| this.data.user.realName==null) {
|
wx.showToast({
|
icon: "none",
|
title: '请完整填完表单!',
|
})
|
return
|
}
|
wx.request({
|
|
url: loginInfo.globalData.url+"/wx/login",
|
data: {
|
"phone": wx.getStorageSync('phone'),
|
},
|
method: "GET",
|
success: (res) => {
|
wx.setStorageSync('token', res.data.data.token)
|
wx.setStorageSync('role', res.data.data.role)
|
wx.setStorageSync('id', res.data.data.id)
|
wx.setStorageSync('card',res.data.data.time)
|
console.log(res.data.data.id)
|
this.data.user.id= res.data.data.id
|
wx.setStorageSync('id',res.data.data.id)
|
wx.request({
|
url:loginInfo.globalData.url+"/wx/user/add",
|
method:"POST",
|
data:this.data.user,
|
header:{
|
'token':wx.getStorageSync('token')
|
},
|
success:(res)=>{
|
wx.setStorageSync('info',true)
|
wx.reLaunch({
|
url:'../../user/index'
|
})
|
}
|
})
|
}
|
|
})
|
|
},
|
face(){
|
wx.chooseMedia({
|
count:1,
|
mediaType:['image'],
|
sourceType:['camera'],
|
camera:"front",
|
success:(res)=>{
|
wx.uploadFile({
|
url: loginInfo.globalData.url+"/minio/upload",
|
filePath: res.tempFiles[0].tempFilePath,
|
name: "file",
|
header: {
|
// 'token': wx.getStorageSync('token'),
|
'content-type': 'application/json'
|
},
|
success:(res)=>{
|
const result = JSON.parse(res.data)
|
this.setData({
|
pic:result.data,
|
isShow:true
|
})
|
// 成功通知
|
Notify({ type: 'primary', message: '采集成功' });
|
}
|
})
|
}
|
})
|
},
|
onLoad() {
|
// wx.request(
|
// {
|
// url:"http://42.193.1.25:8081/report",
|
// method:"GET",
|
// header:{'token':wx.getStorageSync('token')},
|
// success:(res)=>{
|
// this.setData({
|
// reportList:res.data.data.records
|
// })
|
// }
|
// })
|
}
|
})
|