odc.xiaohui
2023-03-20 1ad98e72e116155c30b14beb2da59e80ca971a6b
miniprogram/pages/user/loginInfo/index.ts
@@ -1,22 +1,51 @@
// 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
    pic:null,
    viewData: {
        style: myStyle,
        styleId:myStyle
       }
  },
  getName(e){
      console.log(e.detail.value)
      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
  },
  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) {
@@ -26,7 +55,23 @@
        })
        return
    }
    console.log("meizhic")
    wx.request({
                    url: loginInfo.globalData.url+"/wx/login",
                    data: {
                        "code": wx.getStorageSync('uesrCode'),
                        "phoneNumberCode": wx.getStorageSync('userPhoneNumberCode')
                    },
                    method: "GET",
                    success: (res) => {
                        console.log(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)
                    }
                })
   wx.request({
       url:loginInfo.globalData.url+"/wx/user/add",
       method:"POST",
@@ -54,10 +99,12 @@
                filePath: res.tempFiles[0].tempFilePath,
                name: "file",
                header: {
                    'token': wx.getStorageSync('token'),
                    // 'token': wx.getStorageSync('token'),
                    'content-type': 'application/json'
                },
                success:(res)=>{
                    // 成功通知
                    Notify({ type: 'primary', message: '采集成功' });
                    const result = JSON.parse(res.data)
                    this.setData({
                        pic:result.data,