odc.xiaohui
2023-04-07 f693c859cdaf607c2a146ef89a7a2ce0d9476d1a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// 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
    //           })
    //       }
    //           })
    }
})