From f68f67f34857085d627cc2acdcfe714eb8bbdcb5 Mon Sep 17 00:00:00 2001
From: 安瑾然 <m17681517455@outlook.com>
Date: 星期四, 23 三月 2023 13:58:11 +0800
Subject: [PATCH] 图片预览

---
 miniprogram/pages/user/loginInfo/index.ts |   89 +++++++++++++++++++++++++++++++++++---------
 1 files changed, 71 insertions(+), 18 deletions(-)

diff --git a/miniprogram/pages/user/loginInfo/index.ts b/miniprogram/pages/user/loginInfo/index.ts
index 432b492..1308f7a 100644
--- a/miniprogram/pages/user/loginInfo/index.ts
+++ b/miniprogram/pages/user/loginInfo/index.ts
@@ -1,22 +1,55 @@
 // 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
   },
+  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) {
@@ -26,21 +59,39 @@
         })
         return
     }
-    console.log("meizhic")
-   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'
-           })
-       }
-   })
+    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({
@@ -54,10 +105,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,

--
Gitblit v1.8.0