From fb73be20fcdc285c46f1a350960e69c894361709 Mon Sep 17 00:00:00 2001 From: whycq <913841844@qq.com> Date: 星期三, 01 十一月 2023 22:50:26 +0800 Subject: [PATCH] # --- pages/api/common/common.js | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-) diff --git a/pages/api/common/common.js b/pages/api/common/common.js index e69de29..67a13a7 100644 --- a/pages/api/common/common.js +++ b/pages/api/common/common.js @@ -0,0 +1,29 @@ +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 +} \ No newline at end of file -- Gitblit v1.9.1