李志伟 3 anos atrás
pai
commit
d949555d15

+ 11
- 8
src/pages/index/components/User/index.jsx Ver arquivo

@@ -1,4 +1,5 @@
1 1
 import { useState,useEffect } from "react"
2
+import { useModel } from '@/store'
2 3
 import Taro from "@tarojs/taro"
3 4
 import { View, Image, ScrollView } from "@tarojs/components"
4 5
 import userBgi from '@/assets/user/userBgi.png'
@@ -16,7 +17,8 @@ import banner1 from '@/assets/banner/1.jpg'
16 17
 import './style.less'
17 18
 
18 19
 export default (props) => {
19
-  const { isLogin } = props
20
+  const { phone,setPhone } = useModel('phone')
21
+
20 22
   const handleAccount = () => { 
21 23
     Taro.navigateTo({ url: '/pages/userInfo/index' });
22 24
    }
@@ -42,28 +44,29 @@ export default (props) => {
42 44
     Taro.navigateTo({ url: '/pages/bankCard/index' });
43 45
    }
44 46
   const signOut = () => { 
47
+    setPhone()
45 48
     Taro.reLaunch({ url: '/pages/index/index?tab=2' });
46 49
   }
47 50
   return (
48 51
     <ScrollView scrollY style={{ height: '100%' }}>
49 52
       {
50
-        isLogin &&
53
+        phone &&
51 54
         <View className='personTip'>该账号归张三所属</View>
52 55
       }
53 56
       <View className='userHead'>
54 57
         <Image src={userBgi} className='userBgi' />
55
-        <View className='headcontent' onClick={handleLogin}>
56
-          <Image src={isLogin ? banner1 : avatar} className='avatar' />
58
+        <View className='headcontent' onClick={phone?'':handleLogin}>
59
+          <Image src={phone ? banner1 : avatar} className='avatar' />
57 60
           {
58
-            isLogin ? <View>
61
+            phone ? <View>
59 62
               <View>张三</View>
60
-              <View>13612345678</View>
63
+              <View>{phone}</View>
61 64
             </View> : <View>点击登录</View>
62 65
           }
63 66
         </View>
64 67
       </View>
65 68
       {
66
-        isLogin &&
69
+        phone &&
67 70
         <View className='userCard'>
68 71
           <View
69 72
             className='cardItem'
@@ -103,7 +106,7 @@ export default (props) => {
103 106
           <MyCell icon={feedback} action={goto} user handleAction={handleFeedback}>意见反馈</MyCell>
104 107
         </View>
105 108
         {
106
-          isLogin && <View className='signOut' onClick={signOut}>退出登录</View>
109
+          phone && <View className='signOut' onClick={signOut}>退出登录</View>
107 110
         }
108 111
       </View>
109 112
 

+ 28
- 9
src/pages/login/index.jsx Ver arquivo

@@ -14,8 +14,8 @@ import './style.less'
14 14
 
15 15
 export default (props) => {
16 16
   const { person } = useModel('person')
17
+  const { setPhone:setphone } = useModel('phone')
17 18
 
18
-  console.log(person)
19 19
   const [agreement,setAgreement]=useState(false)
20 20
   const [phone,setPhone]=useState()
21 21
   const [qCode,setqCode]=useState()
@@ -28,9 +28,20 @@ export default (props) => {
28 28
   }
29 29
   const changeqCode=()=>{
30 30
     if (rulePhone(phone)) {
31
-      setQcode({phone:phone})
31
+      setQcode({phone:phone}).then((res)=>{
32
+        Taro.showToast({
33
+          title: '发送成功,请注意查收',
34
+          icon: 'none',
35
+          duration: 2000
36
+        })
37
+      }).catch(() => {
38
+        Taro.showToast({
39
+          title: '网络异常, 请刷新小程序重试',
40
+          icon: 'none',
41
+        })
42
+      })
32 43
 
33
-      let time=10
44
+      let time=60
34 45
       setDsb(true)
35 46
       // 调接口
36 47
       let timer = setInterval(() => {
@@ -72,13 +83,21 @@ export default (props) => {
72 83
         return false
73 84
       }
74 85
       // 登录
75
-      Taro.showToast({
76
-        title: '登录成功',
77
-        icon: 'none',
78
-        duration: 1000
86
+      updatePhone(person.personId,{phone:phone,captcha:qCode}).then((res)=>{
87
+        Taro.showToast({
88
+          title: '登录成功',
89
+          icon: 'none',
90
+          duration: 1000
91
+        })
92
+        setphone(res.phone)
93
+        Taro.reLaunch({ url: '/pages/index/index?tab=2&&isLogin=true' });
94
+      }).catch((e) => {
95
+        console.log(e)
96
+        Taro.showToast({
97
+          title: '网络异常, 请刷新小程序重试',
98
+          icon: 'none',
99
+        })
79 100
       })
80
-      Taro.reLaunch({ url: '/pages/index/index?tab=2&&isLogin=true' });
81
-
82 101
     } else {
83 102
       Taro.showToast({
84 103
         title: '请输入正确的手机号和验证码',

+ 1
- 1
src/pages/login/style.less Ver arquivo

@@ -39,7 +39,7 @@
39 39
       }
40 40
     }
41 41
     .loginAction{
42
-      width: 9em;
42
+      width: 10em;
43 43
       background: linear-gradient(0deg, #00AE39,#A0E067);
44 44
       border-radius: 20px;
45 45
       line-height: 68px;

+ 1
- 2
src/store/models/person.js Ver arquivo

@@ -8,10 +8,9 @@ export default () => {
8 8
 
9 9
   const login = (params) => {
10 10
     signIn(params).then((res) => {
11
-      const { person: taPerson,  sessionKey: skey,  token } = res;
11
+      const { person: taPerson,  sessionKey: skey } = res;
12 12
       setPerson(taPerson);
13 13
       setSessionKey(skey);
14
-      Taro.setStorage({ key: 'token', data: token })
15 14
     })
16 15
   }
17 16