| | |
| | | import md5 from '@/static/js/md5.js' |
| | | |
| | | let network = uni.getStorageSync('Network') |
| | | let baseUrl = `http://${network[0].ip}:${network[0].port}/${network[0].address}` |
| | | |
| | | async function onLogin(user) { |
| | | let _this = this, |
| | | item = {}; |
| | | var login = await uni.request({ |
| | | url: `${baseUrl}/login.action`, |
| | | data: { |
| | | username: user.username, |
| | | password: md5.hex_md5(user.password) |
| | | }, |
| | | }).then((result) => { |
| | | result = result.data |
| | | if (result.code === 200 && result.data.token) { |
| | | uni.setStorageSync('token', result.data.token); |
| | | } |
| | | item = result |
| | | }, (res) => { |
| | | item = {code: 0} |
| | | }) |
| | | return item |
| | | } |
| | | |
| | | module.exports = { |
| | | onLogin: onLogin |
| | | } |