李双庆 1 year ago
parent
commit
d33582186e
  1. 55
      pages/student/login/login.vue

55
pages/student/login/login.vue

@ -14,7 +14,7 @@
<view style="width: 95%;height: 30rpx;"></view> <view style="width: 95%;height: 30rpx;"></view>
<view style="width: 95%;margin:30rpx auto;"> <view style="width: 95%;margin:30rpx auto;">
<fui-input borderTop placeholder="登录账号" v-model="user" @input="input" <fui-input borderTop placeholder="登录账号" v-model="user" @input="input"
backgroundColor="#f2f2f2"></fui-input> backgroundColor="#f2f2f2"></fui-input>
</view> </view>
<view style="width: 95%;margin: auto;"> <view style="width: 95%;margin: auto;">
<fui-input borderTop :padding="['20rpx','32rpx']" v-model="password1" placeholder="登录密码" <fui-input borderTop :padding="['20rpx','32rpx']" v-model="password1" placeholder="登录密码"
@ -36,14 +36,14 @@
</template> </template>
<script> <script>
import medicationApi from '@/api/medication.js'; import medicationApi from '@/api/medication.js';
export default { export default {
data() { data() {
return { return {
password: true, password: true,
user: '',// user: '18888888888', //
password1: ''// password1: '123456' //
} }
}, },
onLoad() { onLoad() {
@ -62,41 +62,38 @@ import medicationApi from '@/api/medication.js';
url: '/pages/student/login/forgot' url: '/pages/student/login/forgot'
}) })
}, },
// //
login() { login() {
let item = {}; let item = {};
item['username'] = this.user item['username'] = this.user
item['password'] = this.password1 item['password'] = this.password1
// //
medicationApi.login(item).then(res => { medicationApi.login(item).then(res => {
if (res.code == 1) { if (res.code == 1) {
res.data.userType = 2
uni.setStorageSync('token', res.data.token); uni.setStorageSync('token', res.data.token);
uni.setStorageSync('userType', res.data.userType); uni.setStorageSync('userType', res.data.userType);
let url_path = '' let url_path = ''
switch (String(res.data.userType)) { switch (String(res.data.userType)) {
case '1':// case '1': //
url_path = '/pages/coach/home/index' url_path = '/pages/coach/home/index'
break; break;
case '2':// case '2': //
url_path = '/pages/market/index/index' url_path = '/pages/market/index/index'
break; break;
case '3':// case '3': //
url_path = '/pages/student/index/index' url_path = '/pages/student/index/index'
break; break;
default: default:
uni.showToast({ uni.showToast({
title: '用户类型错误', title: '用户类型错误',
icon: 'none' icon: 'none'
}) })
return; return;
} }
uni.navigateTo({ uni.navigateTo({
url: url_path url: url_path
}) })
} else { } else {
uni.showToast({ uni.showToast({
title: res.msg, title: res.msg,

Loading…
Cancel
Save