微信登录页面
This commit is contained in:
1 parent
446e545f2e
commit
cfdfeb4537
6 files changed
+280
-21733
No files matched your search
Generated
-21474
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,4 @@
|
||||
<script lang="ts">
|
||||
import isDevEnv from "./sheep/utils/isDevEnv"
|
||||
|
||||
// import { onLaunch, onShow, onHide } from "@dcloudio/uni-app"
|
||||
// onLaunch(() => {})
|
||||
// onShow(() => {})
|
||||
|
||||
+89
-89
@@ -1,91 +1,91 @@
|
||||
{
|
||||
"name": "",
|
||||
"appid": "",
|
||||
"description": "浦江县机关事务智慧后勤一体化平台",
|
||||
"versionName": "1.0.0",
|
||||
"versionCode": "100",
|
||||
"transformPx": false,
|
||||
/* 5+App特有相关 */
|
||||
"app-plus": {
|
||||
"usingComponents": true,
|
||||
"nvueCompiler": "uni-app",
|
||||
"renderer": "native",
|
||||
"nvueStyleCompiler": "uni-app",
|
||||
"compilerVersion": 3,
|
||||
"splashscreen": {
|
||||
"alwaysShowBeforeRender": true,
|
||||
"waiting": true,
|
||||
"autoclose": true,
|
||||
"delay": 0
|
||||
},
|
||||
/* 模块配置 */
|
||||
"modules": {},
|
||||
/* 应用发布信息 */
|
||||
"distribute": {
|
||||
/* android打包配置 */
|
||||
"android": {
|
||||
"permissions": [
|
||||
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
|
||||
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
|
||||
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
|
||||
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
|
||||
"<uses-feature android:name=\"android.hardware.camera\"/>",
|
||||
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>"
|
||||
]
|
||||
},
|
||||
/* ios打包配置 */
|
||||
"ios": {},
|
||||
/* SDK配置 */
|
||||
"sdkConfigs": {}
|
||||
}
|
||||
},
|
||||
/* 快应用特有相关 */
|
||||
"quickapp": {},
|
||||
/* 小程序特有相关 */
|
||||
"mp-weixin": {
|
||||
"appid": "",
|
||||
"setting": {
|
||||
"urlCheck": false,
|
||||
"es6": true,
|
||||
"postcss": true,
|
||||
"minified": true
|
||||
},
|
||||
"usingComponents": true,
|
||||
"requiredPrivateInfos": ["getLocation"],
|
||||
"permission": {
|
||||
"scope.userLocation": {
|
||||
"desc": "你的位置信息将用于小程序位置接口的效果展示"
|
||||
}
|
||||
}
|
||||
},
|
||||
"mp-alipay": {
|
||||
"usingComponents": true
|
||||
},
|
||||
"mp-baidu": {
|
||||
"usingComponents": true
|
||||
},
|
||||
"mp-toutiao": {
|
||||
"usingComponents": true
|
||||
},
|
||||
"uniStatistics": {
|
||||
"enable": false
|
||||
},
|
||||
"vueVersion": "3",
|
||||
"h5": {
|
||||
"router": {
|
||||
"base": "/h5/",
|
||||
"mode": "hash"
|
||||
},
|
||||
"title": "浦江县机关事务智慧后勤一体化平台"
|
||||
}
|
||||
"name" : "",
|
||||
"appid" : "",
|
||||
"description" : "浦江县机关事务智慧后勤一体化平台",
|
||||
"versionName" : "1.0.0",
|
||||
"versionCode" : "100",
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
"app-plus" : {
|
||||
"usingComponents" : true,
|
||||
"nvueCompiler" : "uni-app",
|
||||
"renderer" : "native",
|
||||
"nvueStyleCompiler" : "uni-app",
|
||||
"compilerVersion" : 3,
|
||||
"splashscreen" : {
|
||||
"alwaysShowBeforeRender" : true,
|
||||
"waiting" : true,
|
||||
"autoclose" : true,
|
||||
"delay" : 0
|
||||
},
|
||||
/* 模块配置 */
|
||||
"modules" : {},
|
||||
/* 应用发布信息 */
|
||||
"distribute" : {
|
||||
/* android打包配置 */
|
||||
"android" : {
|
||||
"permissions" : [
|
||||
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
|
||||
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
|
||||
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
|
||||
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
|
||||
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
|
||||
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
|
||||
"<uses-feature android:name=\"android.hardware.camera\"/>",
|
||||
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
|
||||
"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>"
|
||||
]
|
||||
},
|
||||
/* ios打包配置 */
|
||||
"ios" : {},
|
||||
/* SDK配置 */
|
||||
"sdkConfigs" : {}
|
||||
}
|
||||
},
|
||||
/* 快应用特有相关 */
|
||||
"quickapp" : {},
|
||||
/* 小程序特有相关 */
|
||||
"mp-weixin" : {
|
||||
"appid" : "wxe860b6ed8d1ceabe",
|
||||
"setting" : {
|
||||
"urlCheck" : false,
|
||||
"es6" : true,
|
||||
"postcss" : true,
|
||||
"minified" : true
|
||||
},
|
||||
"usingComponents" : true,
|
||||
"requiredPrivateInfos" : [ "getLocation" ],
|
||||
"permission" : {
|
||||
"scope.userLocation" : {
|
||||
"desc" : "你的位置信息将用于小程序位置接口的效果展示"
|
||||
}
|
||||
}
|
||||
},
|
||||
"mp-alipay" : {
|
||||
"usingComponents" : true
|
||||
},
|
||||
"mp-baidu" : {
|
||||
"usingComponents" : true
|
||||
},
|
||||
"mp-toutiao" : {
|
||||
"usingComponents" : true
|
||||
},
|
||||
"uniStatistics" : {
|
||||
"enable" : false
|
||||
},
|
||||
"vueVersion" : "3",
|
||||
"h5" : {
|
||||
"router" : {
|
||||
"base" : "/h5/",
|
||||
"mode" : "hash"
|
||||
},
|
||||
"title" : "浦江县机关事务智慧后勤一体化平台"
|
||||
}
|
||||
}
|
||||
@@ -252,21 +252,21 @@ import deptApi from "@/sheep/api/integrated/dept"
|
||||
|
||||
// 表单数据
|
||||
const formData = reactive({
|
||||
name: '测试访客',
|
||||
mobile: '13800138000',
|
||||
companyName: '测试公司',
|
||||
isOtherPeople: '1', // 默认有随行人员
|
||||
isDrive: '1', // 默认有车辆
|
||||
deptId: '', // 这个需要等部门列表加载后设置
|
||||
deptName: '',
|
||||
receiveId: '', // 这个需要等用户列表加载后设置
|
||||
userName: '',
|
||||
vstartDate: '', // 这个会在页面加载时设置
|
||||
vendDate: '',
|
||||
type: '1',
|
||||
checkStatus: '0',
|
||||
reasonValue: '', // 这个需要等原因列表加载后设置
|
||||
reasonLabel: '',
|
||||
name: "测试访客",
|
||||
mobile: "13800138000",
|
||||
companyName: "测试公司",
|
||||
isOtherPeople: "1", // 默认有随行人员
|
||||
isDrive: "1", // 默认有车辆
|
||||
deptId: "", // 这个需要等部门列表加载后设置
|
||||
deptName: "",
|
||||
receiveId: "", // 这个需要等用户列表加载后设置
|
||||
userName: "",
|
||||
vstartDate: "", // 这个会在页面加载时设置
|
||||
vendDate: "",
|
||||
type: "1",
|
||||
checkStatus: "0",
|
||||
reasonValue: "", // 这个需要等原因列表加载后设置
|
||||
reasonLabel: "",
|
||||
})
|
||||
|
||||
// 随行人员列表默认数据
|
||||
@@ -305,7 +305,7 @@ const reasonList = ref<any[]>([])
|
||||
|
||||
// 生成未来一周的日期
|
||||
const dateList = computed(() => {
|
||||
const dates = []
|
||||
const dates: any = []
|
||||
const weekDays = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]
|
||||
|
||||
for (let i = 0; i < 7; i++) {
|
||||
@@ -322,7 +322,7 @@ const dateList = computed(() => {
|
||||
|
||||
// 生成时间段列表(8:00-18:00,每小时一个时间段)
|
||||
const timeList = computed(() => {
|
||||
const times = []
|
||||
const times: any = []
|
||||
for (let i = 8; i < 18; i++) {
|
||||
times.push(`${i.toString().padStart(2, "0")}:00-${(i + 1).toString().padStart(2, "0")}:00`)
|
||||
}
|
||||
@@ -331,11 +331,9 @@ const timeList = computed(() => {
|
||||
|
||||
// 过滤后的用户列表
|
||||
const filteredUserList = computed(() => {
|
||||
if (!searchKeyword.value) return userList.value
|
||||
const keyword = searchKeyword.value.toLowerCase()
|
||||
return userList.value.filter(user =>
|
||||
user.name.toLowerCase().includes(keyword)
|
||||
)
|
||||
if (!searchKeyword.value) return userList.value
|
||||
const keyword = searchKeyword.value.toLowerCase()
|
||||
return userList.value.filter((user) => user.name.toLowerCase().includes(keyword))
|
||||
})
|
||||
|
||||
// 获取部门数据
|
||||
@@ -412,31 +410,31 @@ const goBack = () => {
|
||||
|
||||
// 表单验证
|
||||
const validateForm = () => {
|
||||
if (!formData.name) {
|
||||
uni.showToast({ title: '请输入姓名', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
if (!formData.mobile) {
|
||||
uni.showToast({ title: '请输入联系方式', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
if (!formData.deptId || !formData.deptName) {
|
||||
uni.showToast({ title: '请选择到访单位', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
if (!formData.receiveId || !formData.userName) {
|
||||
uni.showToast({ title: '请选择接待人', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
if (!formData.vstartDate || !formData.vendDate) {
|
||||
uni.showToast({ title: '请选择到访时间', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
if (!formData.reasonValue || !formData.reasonLabel) {
|
||||
uni.showToast({ title: '请选择拜访原因', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
return true
|
||||
if (!formData.name) {
|
||||
uni.showToast({ title: "请输入姓名", icon: "none" })
|
||||
return false
|
||||
}
|
||||
if (!formData.mobile) {
|
||||
uni.showToast({ title: "请输入联系方式", icon: "none" })
|
||||
return false
|
||||
}
|
||||
if (!formData.deptId || !formData.deptName) {
|
||||
uni.showToast({ title: "请选择到访单位", icon: "none" })
|
||||
return false
|
||||
}
|
||||
if (!formData.receiveId || !formData.userName) {
|
||||
uni.showToast({ title: "请选择接待人", icon: "none" })
|
||||
return false
|
||||
}
|
||||
if (!formData.vstartDate || !formData.vendDate) {
|
||||
uni.showToast({ title: "请选择到访时间", icon: "none" })
|
||||
return false
|
||||
}
|
||||
if (!formData.reasonValue || !formData.reasonLabel) {
|
||||
uni.showToast({ title: "请选择拜访原因", icon: "none" })
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
@@ -460,30 +458,30 @@ const handleSubmit = async () => {
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
if (code === 0) {
|
||||
uni.showToast({
|
||||
title: '提交成功,请耐心等待您的拜访对象接受此次申请',
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
})
|
||||
if (code === 0) {
|
||||
uni.showToast({
|
||||
title: "提交成功,请耐心等待您的拜访对象接受此次申请",
|
||||
icon: "none",
|
||||
duration: 3000,
|
||||
})
|
||||
|
||||
// 延迟返回,让用户能看到提示
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 2000)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: msg || '提交失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '提交失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
// 延迟返回,让用户能看到提示
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 2000)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: msg || "提交失败",
|
||||
icon: "none",
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: "提交失败",
|
||||
icon: "none",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 显示时间选择器
|
||||
@@ -551,26 +549,26 @@ const selectDept = (dept: any) => {
|
||||
|
||||
// 部门选择确认
|
||||
const confirmDeptSelect = () => {
|
||||
if (!selectedDeptId.value) {
|
||||
uni.showToast({
|
||||
title: '请选择到访单位',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!selectedDeptId.value) {
|
||||
uni.showToast({
|
||||
title: "请选择到访单位",
|
||||
icon: "none",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 更新表单数据,同时保存ID和名称
|
||||
formData.deptId = selectedDeptId.value
|
||||
formData.deptName = selectedDeptName.value
|
||||
// 更新表单数据,同时保存ID和名称
|
||||
formData.deptId = selectedDeptId.value
|
||||
formData.deptName = selectedDeptName.value
|
||||
|
||||
// 清空已选择的接待人
|
||||
formData.receiveId = ''
|
||||
formData.userName = ''
|
||||
selectedUserName.value = ''
|
||||
selectedUserId.value = ''
|
||||
// 清空已选择的接待人
|
||||
formData.receiveId = ""
|
||||
formData.userName = ""
|
||||
selectedUserName.value = ""
|
||||
selectedUserId.value = ""
|
||||
|
||||
// 关闭弹窗
|
||||
closeDeptPicker()
|
||||
// 关闭弹窗
|
||||
closeDeptPicker()
|
||||
}
|
||||
|
||||
// 获取部门下的用户列表
|
||||
@@ -595,42 +593,42 @@ const selectUser = (user: any) => {
|
||||
|
||||
// 用户选择确认
|
||||
const confirmUserSelect = () => {
|
||||
if (!selectedUserId.value) {
|
||||
uni.showToast({
|
||||
title: '请选择接待人',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!selectedUserId.value) {
|
||||
uni.showToast({
|
||||
title: "请选择接待人",
|
||||
icon: "none",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 更新表单数据,同时保存ID和名称
|
||||
formData.receiveId = selectedUserId.value
|
||||
formData.userName = selectedUserName.value
|
||||
// 更新表单数据,同时保存ID和名称
|
||||
formData.receiveId = selectedUserId.value
|
||||
formData.userName = selectedUserName.value
|
||||
|
||||
// 关闭弹窗
|
||||
closeUserPicker()
|
||||
// 关闭弹窗
|
||||
closeUserPicker()
|
||||
}
|
||||
|
||||
// 显示用户选择器
|
||||
const showUserPicker = async () => {
|
||||
if (!formData.deptId) {
|
||||
uni.showToast({
|
||||
title: '请先选择到访单位',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!formData.deptId) {
|
||||
uni.showToast({
|
||||
title: "请先选择到访单位",
|
||||
icon: "none",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 如果切换了部门,重新获取用户列表
|
||||
if (formData.deptId !== currentDeptId.value) {
|
||||
await getUserList(formData.deptId)
|
||||
currentDeptId.value = formData.deptId
|
||||
// 清空选择
|
||||
selectedUserId.value = ''
|
||||
selectedUserName.value = ''
|
||||
}
|
||||
// 如果切换了部门,重新获取用户列表
|
||||
if (formData.deptId !== currentDeptId.value) {
|
||||
await getUserList(formData.deptId)
|
||||
currentDeptId.value = formData.deptId
|
||||
// 清空选择
|
||||
selectedUserId.value = ""
|
||||
selectedUserName.value = ""
|
||||
}
|
||||
|
||||
showUserPopup.value = true
|
||||
showUserPopup.value = true
|
||||
}
|
||||
|
||||
// 关闭用户选择器
|
||||
@@ -677,29 +675,28 @@ onMounted(async () => {
|
||||
formData.deptId = firstDept.id
|
||||
formData.deptName = firstDept.name
|
||||
|
||||
// 获取该部门的用户列表
|
||||
await getUserList(firstDept.id)
|
||||
|
||||
// 设置默认的接待人(选择第一个用户)
|
||||
if (userList.value.length > 0) {
|
||||
const firstUser = userList.value[0]
|
||||
selectedUserId.value = firstUser.userId
|
||||
selectedUserName.value = firstUser.name
|
||||
formData.receiveId = firstUser.userId
|
||||
formData.userName = firstUser.name
|
||||
}
|
||||
}
|
||||
// 获取该部门的用户列表
|
||||
await getUserList(firstDept.id)
|
||||
|
||||
// 设置默认的接待人(选择第一个用户)
|
||||
if (userList.value.length > 0) {
|
||||
const firstUser = userList.value[0]
|
||||
selectedUserId.value = firstUser.userId
|
||||
selectedUserName.value = firstUser.name
|
||||
formData.userId = firstUser.userId
|
||||
formData.receiveId = firstUser.userId
|
||||
formData.userName = firstUser.name
|
||||
}
|
||||
}
|
||||
|
||||
// 设置默认的接待人(选择第一个用户)
|
||||
if (userList.value.length > 0) {
|
||||
const firstUser = userList.value[0]
|
||||
selectedUserId.value = firstUser.userId
|
||||
selectedUserName.value = firstUser.name
|
||||
formData.userId = firstUser.userId
|
||||
formData.userName = firstUser.name
|
||||
}
|
||||
|
||||
// 设置默认的拜访原因(选择第一个原因)
|
||||
if (reasonList.value.length > 0) {
|
||||
const firstReason = reasonList.value[0]
|
||||
|
||||
+65
-39
@@ -1,12 +1,29 @@
|
||||
<template>
|
||||
<crud-layout title="登录" bg="/static/page/blue-bg.png">
|
||||
<view class="card p-x-30rpx p-y-40rpx mt-5">
|
||||
<tm-form ref="applyFormRef" v-model="applyForm" :rules="applyFormRules" direction="vertical">
|
||||
<tm-form-item name="username" label="用户名" :showBottom="false">
|
||||
<tm-input v-model="applyForm.username" placeholder="请输入用户名.." />
|
||||
</tm-form-item>
|
||||
<view class="h-10rpx" />
|
||||
<tm-form-item name="password" label="密码" :showBottom="false">
|
||||
<tm-input password showEye v-model="applyForm.password" placeholder="请输入用户密码.." />
|
||||
</tm-form-item>
|
||||
</tm-form>
|
||||
</view>
|
||||
<tm-button class="my-3" block @tap="doSubmit">登录</tm-button>
|
||||
|
||||
<button style="background-color: #0779fd; border-radius: 24rpx; color: white; font-size: 32rpx" @click="getUserInfo">
|
||||
微信一键登录
|
||||
</button>
|
||||
</crud-layout>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive } from "vue"
|
||||
import { onShow } from "@dcloudio/uni-app"
|
||||
import { constant, router } from "@@/index"
|
||||
import { userApi } from "@@/api"
|
||||
|
||||
const state = reactive<any>({
|
||||
userInfo: null,
|
||||
})
|
||||
const applyForm = reactive<any>({
|
||||
username: "",
|
||||
password: "",
|
||||
@@ -16,21 +33,18 @@ const applyFormRules = reactive<any>({
|
||||
password: [{ required: true, message: "请输入密码" }],
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
const userInfoKey = constant.storageConstant.USERINFO
|
||||
state.userInfo = uni.getStorageSync(userInfoKey)
|
||||
})
|
||||
|
||||
const applyFormRef = ref<any>(null)
|
||||
const doSubmit = async () => {
|
||||
applyFormRef.value.submit()
|
||||
const { isPass } = applyFormRef.value.validate()
|
||||
if (!isPass) return
|
||||
|
||||
const tokenKey = constant.storageConstant.TOKEN
|
||||
const userInfoKey = constant.storageConstant.USERINFO
|
||||
|
||||
uni.removeStorageSync(tokenKey)
|
||||
uni.showLoading({ title: "登录中...", mask: true })
|
||||
const res = await userApi.login({
|
||||
const res: any = await userApi.login({
|
||||
...applyForm,
|
||||
grant_type: "password",
|
||||
scope: "server",
|
||||
@@ -46,36 +60,48 @@ const doSubmit = async () => {
|
||||
uni.showToast({ title: "登录成功", icon: "none" })
|
||||
router.back()
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<crud-layout title="登录" bg="/static/page/blue-bg.png">
|
||||
<view class="h-30rpx" />
|
||||
<view class="card p-x-30rpx p-y-40rpx">
|
||||
<tm-form ref="applyFormRef" v-model="applyForm" :rules="applyFormRules" direction="vertical">
|
||||
<tm-form-item name="username" label="用户名" :showBottom="false">
|
||||
<tm-input v-model="applyForm.username" placeholder="请输入用户名.." />
|
||||
</tm-form-item>
|
||||
<view class="h-30rpx" />
|
||||
<tm-form-item name="password" label="密码" :showBottom="false">
|
||||
<tm-input password showEye v-model="applyForm.password" placeholder="请输入用户密码.." />
|
||||
</tm-form-item>
|
||||
</tm-form>
|
||||
</view>
|
||||
<view
|
||||
v-if="state.detailType != 'view'"
|
||||
class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-60rpx sub-text-30 color-white!"
|
||||
@tap="doSubmit"
|
||||
>
|
||||
登录
|
||||
</view>
|
||||
</crud-layout>
|
||||
</template>
|
||||
// import { useUserStore } from "@/store/user.js"
|
||||
// 使用store仓库
|
||||
// const userStore = useUserStore()
|
||||
// 获取用户信息的方法
|
||||
const getUserInfo = () => {
|
||||
uni.getUserInfo({
|
||||
success: (res) => {
|
||||
// 存储用户信息
|
||||
// console.log(res.userInfo);
|
||||
// userStore.updateUserInfo(res.userInfo)
|
||||
|
||||
<style lang="scss" scoped>
|
||||
:deep() {
|
||||
.tmFormItemLabel {
|
||||
padding-bottom: 10rpx !important;
|
||||
getToken(res)
|
||||
},
|
||||
fail: (res) => {
|
||||
return uni.showToast({ title: "API调用失败", icon: "error" })
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// 请求获取token
|
||||
const getToken = async (info: any) => {
|
||||
const result = await uni.login().catch((error) => error)
|
||||
// 判断是否调用失败
|
||||
if (result.errMsg === "login:ok") {
|
||||
const params = {
|
||||
mobile: "MINI@" + result.code,
|
||||
code: result.code,
|
||||
}
|
||||
const res: any = await userApi.login(params)
|
||||
if (res == 0) {
|
||||
// const token = "Bearer 123456789"
|
||||
// 更新获取的token
|
||||
// userStore.updateToken(token)
|
||||
|
||||
router.back()
|
||||
return uni.showToast({ title: "登录成功", icon: "none" })
|
||||
} else {
|
||||
return uni.showToast({ title: "获取token失败,登录失败", icon: "error" })
|
||||
}
|
||||
} else {
|
||||
uni.showToast({ title: "获取登录code失败", icon: "error" })
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</script>
|
||||
@@ -35,7 +35,7 @@ function showLoading(message: string) {
|
||||
// 读取token并处理Authorization请求头
|
||||
const getAuthHeader = (tokenStorage: any) => {
|
||||
// if (isDevEnv()) {
|
||||
return tokenStorage?.access_token ? `Bearer ${tokenStorage.access_token}` : null
|
||||
return tokenStorage?.access_token ? `Bearer ${tokenStorage.access_token}` : null
|
||||
// }
|
||||
// return tokenStorage?.accessToken?.tokenValue ? `Bearer ${tokenStorage.accessToken.tokenValue}` : null
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user