45
chenyc
2022-10-20 b785655ee996378ef61e64f43163888278900c57
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
<script lang="ts" setup>
    import { ref,onMounted } from 'vue'
    import {useRoute,useRouter} from 'vue-router'
    import { ajaxGet ,ajaxPost} from '@/utils/axios'
    // import { Session } from '@/utils/storage'
    import { Dialog  } from 'vant'
    import { userInfoStore } from '@/stores/userInfo'
    import logo from 'assets/logo.png'
    import shoujiLogin from 'assets/yijianLogin.png'
    import pswdLogin from 'assets/pswdLogin.png'
    const userInfo = userInfoStore()
    const route = useRoute()
    const router=useRouter()
    const username = ref('')
    const password = ref('')
    const visible=ref(1)
    const seconds=ref(60)
    const loadingBUt=ref(false)
    const ruleForm2=ref({
        newPassword:'',
        pass:'',
        validateCode:'',
        userPhone:''
    })
    const ruleForm3=ref({
        validateCode:'',
        userPhone:''
    })
    const asyncValidator = (val:any) =>{
        return val===ruleForm2.value.pass
    }
    const onSubmit = (values:any) => {
        console.log('submit', values)
        router.push('/')
        // const str=`user_no=${username.value}&user_password=${password.value}`
        loadingBUt.value=true
        // signIn(str).then((res:any)=>{
        //     Session.set('token', res.data)
        //         router.push('/')
        //     })
        // }).catch(()=>{
        //     loadingBUt.value=false
        // })
    }
    const onSubmit2=(values:any)=>{
        console.log('提交表单',ruleForm2.value)
        console.log(values)
        visible.value=1
        Dialog.alert({
            title: '提示',
            message: '密码重置成功请重新登录',
        }).then(() => {
            // on close
        })
    }
    const onSubmit3=(values:any)=>{
        console.log('提交表单',ruleForm3.value)
        console.log(values)
    }
    const sendCode=()=>{
        if (ruleForm2.value.userPhone===''){
            Toast('手机号码不能为空')
            return
        }
        // sendValidateCode('mobileNo='+ruleForm2.value.userPhone).then(re=>{
        //     console.log(re)
        //     const timer= setInterval(() => {
        //         if (seconds.value > 0) {
        //             seconds.value--
        //         } else {
        //             seconds.value = 60
        //             clearInterval(timer)
        //         }
        //     }, 1000)
        // })
    }
    const wjmm=()=>{
        visible.value=2
        ruleForm2.value.newPassword=''
        ruleForm2.value.pass=''
        ruleForm2.value.userPhone=''
        ruleForm2.value.validateCode=''
    }
    const shoujiLoginfun=()=>{
        visible.value=3
        ruleForm3.value.userPhone=''
        ruleForm3.value.validateCode=''
    }
    const isWechat = () => {
        return String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === 'micromessenger'
    }
    onMounted(()=>{
        if (isWechat()){
            console.log('初始化',route)
            const queryInfo=route.query
            const {code}=queryInfo
            console.log(code)
            if (code){
                ajaxGet('wechat/code',{code}).then((re:any)=>{
                    console.log(re)
                    userInfo.setUserInfo({openid:re.openid,nickname:re.nickname,headimgurl:re.headimgurl})
                    const openid = re.openid
                    if (openid) {
                        ajaxPost('patient/info/wechatLogin',{openid}).then((re:any)=>{
                            console.log('openid换的accesstoken=',re)
                        })
                    }
 
                })
            }
            else {
                const appid = 'wx790bd67db6206070' // 微信APPid
                const local = window.location.href
                window.location.href =
                    'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' +
                    appid +
                    '&redirect_uri=' +
                    encodeURIComponent(local) +
                    '&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect'
 
            }
        } else {
            console.log('不是微信浏览器')
            Dialog.alert({
                title: '提示',
                message: '请在微信中打开浏览',
            }).then(() => {
                // on close
            })
        }
    })
</script>
 
<template>
    <div class="login">
        <div class="titlebiaoti">
            <van-image
                fit="cover"
                width="95px"
                height="84px"
                :src="logo"
            />
        </div>
        <div>
            <van-form ref="form1" v-show="visible === 1" @submit="onSubmit" label-width="4em">
                <van-cell-group inset>
                    <van-field
                        v-model="username"
                        name="登录名"
                        label="登录名"
                        placeholder="请输入登录名"
                        :rules="[{ required: true, message: '请输入登录名' }]"
                    />
                    <van-field
                        v-model="password"
                        type="password"
                        name="密  码"
                        label="密&nbsp&nbsp码"
                        placeholder="6-16位数字或者字母组合"
                        :rules="[{ required: true, message: '请填写密码' }]"
                    >
                        <template #button>
                            <van-button size="small" type="default" @click="wjmm">忘记密码</van-button>
                        </template>
                    </van-field>
                </van-cell-group>
                <div style="margin: 16px;text-align:center;">
                    <div class="tss"><van-icon name="circle" /> 登录即视为已经阅读并同意<b style="color: #769AFF;">网站服务条款、法律声明及隐私权政策</b></div>
                    <van-button :loading="loadingBUt" round block type="primary" native-type="submit">
                        登  录
                    </van-button>
                </div>
            </van-form>
            <van-form ref="form2" v-show="visible === 3" @submit="onSubmit3" label-width="80px">
                <van-cell-group inset>
                    <van-field
                        v-model="ruleForm3.userPhone"
                        label="手机号码"
                        placeholder="请输入手机号码"
                        :rules="[{ required: true, message: '请输入手机号码' }]"
                    />
                    <van-field
                        v-model="ruleForm3.validateCode"
                        center
                        clearable
                        label="短信验证码"
                        placeholder="请输入短信验证码"
                        :rules="[{ required: true, message: '请输入短信验证码' }]"
                    >
                        <template #button>
                            <van-button size="small" :disabled="seconds < 60" @click="sendCode" type="primary">{{seconds}}发送验证码</van-button>
                        </template>
                    </van-field>
                </van-cell-group>
                <div style="margin: 16px;text-align:center;">
                    <div class="tss"><van-icon name="circle" /> 登录即视为已经阅读并同意<b style="color: #769AFF;">网站服务条款、法律声明及隐私权政策</b></div>
                    <van-button :loading="loadingBUt" round block type="primary" native-type="submit">
                        登  录
                    </van-button>
                </div>
            </van-form>
            <van-row class="loginType">
                <div class="toptype">
                    <van-divider
                        :style="{ color: '#1989fa', borderColor: '#1989fa', padding: '0 16px' }"
                    >
                        登录方式
                    </van-divider>
                </div>
            </van-row>
            <van-row>
                <van-col span="12" @click="shoujiLoginfun" class="logintt">
                    <van-image
                        fit="cover"
                        width="42px"
                        height="42px"
                        :src="shoujiLogin"
                    />
                    <div class="loginwenz">
                        手机登录
                    </div>
                </van-col>
                <van-col span="12" @click="visible = 1" class="logintt">
                    <van-image
                        fit="cover"
                        width="42px"
                        height="42px"
                        :src="pswdLogin"
                    />
                    <div class="loginwenz">密码登录</div>
                </van-col>
            </van-row>
        </div>
        <transition name="van-slide-up">
            <div v-show="visible === 2">
                <van-form @submit="onSubmit2" label-width="80px">
                    <van-cell-group inset>
                        <van-field
                            v-model="ruleForm2.userPhone"
                            label="手机号码"
                            placeholder="请输入手机号码"
                            :rules="[{ required: true, message: '请输入手机号码' }]"
                        />
                        <van-field
                            v-model="ruleForm2.validateCode"
                            center
                            clearable
                            label="短信验证码"
                            placeholder="请输入短信验证码"
                            :rules="[{ required: true, message: '请输入短信验证码' }]"
                        >
                            <template #button>
                                <van-button size="small" :disabled="seconds < 60" @click="sendCode" type="primary">{{seconds}}发送验证码</van-button>
                            </template>
                        </van-field>
                        <van-field
                            v-model="ruleForm2.pass"
                            type="password"
                            label="密&nbsp&nbsp码"
                            placeholder="6-16位数字或者字母组合"
                            :rules="[{ required: true, message: '请填写密码' }]"
                        />
                        <van-field
                            v-model="ruleForm2.newPassword"
                            type="password"
                            label="确认密码"
                            placeholder="6-16位数字或者字母组合"
                            :rules="[{ validator: asyncValidator, message: '密码输入不一致' }]"
                        />
                    </van-cell-group>
                    <div style="margin: 16px;">
                        <van-button :loading="loadingBUt" round block type="primary" native-type="submit">
                            确认
                        </van-button>
                    </div>
                    <div style="text-align: right; padding-right: 20px;">
                        <span type="primary" @click="visible = 1" native-type="submit">
                            返回到登录
                        </span>
                    </div>
                </van-form>
            </div>
        </transition>
 
    </div>
</template>
<style lang="scss">
.login{
    width: 100%;
    min-height: 900px;
}
.logintt{
    text-align: center;
}
.loginwenz{
    font-size: 12px;
    font-weight: 400;
    color: #AAAAAA;
}
.loginType{
    width: 100%;
    margin-top: 120px;
    text-align: center;
    font-size: 11px;
    font-weight: 400;
    color: #AAAAAA;
    // background: black;
    .toptype{
        width: 100%;
    }
}
.titlebiaoti{
    padding-top: 70px;
    text-align:center;
    padding-left: 30px;
    // border: 1px solid black;
    font-size: 15px;
    padding-bottom: 70px;
}
.tss{
    font-size: 10px;
    font-weight: 400;
    color: #AAAAAA;
    height: 50px;
    // line-height: 50px;
}
</style>