This commit is contained in:
parent
c7b4290b04
commit
3ce3363085
1
App.vue
1
App.vue
|
|
@ -20,7 +20,6 @@
|
|||
// 监听消息
|
||||
pushListener()
|
||||
// #endif
|
||||
|
||||
console.log('App Launch')
|
||||
})
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
import { get, post, put, del } from '../utils/request';
|
||||
|
||||
export const userInfo = (data : any) => get('/power/drv', data);
|
||||
export const userInfo = (data : any) => get('v1/info', data);
|
||||
|
||||
export const register = (data : any) => post('/power/drv', data);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
import { get, post, put, del } from '../utils/request';
|
||||
|
||||
export const newMessage = (data : any = {}) => get('v1/message/new/count', data);
|
||||
|
||||
export const register = (data : any) => post('/power/drv', data);
|
||||
|
||||
export const updateUser = (data : any) => put('/power/drv', data);
|
||||
|
||||
export const deleteUser = (data : any) => del('/power/drv', data);
|
||||
|
||||
export const captcha = (data : any) => get('v1/captcha', data);
|
||||
|
||||
export const login = (data : any) => post('v1/login', data);
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
"packages": {
|
||||
"": {
|
||||
"dependencies": {
|
||||
"crypto-js": "^4.2.0",
|
||||
"pinia-plugin-persistedstate": "^4.2.0"
|
||||
}
|
||||
},
|
||||
|
|
@ -522,6 +523,11 @@
|
|||
"resolved": "https://registry.npmmirror.com/convert-source-map/-/convert-source-map-2.0.0.tgz",
|
||||
"integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg=="
|
||||
},
|
||||
"node_modules/crypto-js": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/crypto-js/-/crypto-js-4.2.0.tgz",
|
||||
"integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmmirror.com/debug/-/debug-4.4.0.tgz",
|
||||
|
|
@ -1741,6 +1747,11 @@
|
|||
"resolved": "https://registry.npmmirror.com/convert-source-map/-/convert-source-map-2.0.0.tgz",
|
||||
"integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg=="
|
||||
},
|
||||
"crypto-js": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/crypto-js/-/crypto-js-4.2.0.tgz",
|
||||
"integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
|
||||
},
|
||||
"debug": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmmirror.com/debug/-/debug-4.4.0.tgz",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"pinia-plugin-persistedstate": "^4.2.0"
|
||||
"pinia-plugin-persistedstate": "^4.2.0",
|
||||
"crypto-js": "^4.2.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
20
pages.json
20
pages.json
|
|
@ -1,14 +1,5 @@
|
|||
{
|
||||
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
|
||||
{
|
||||
"path": "pages/login/index",
|
||||
"style": {
|
||||
"enablePullDownRefresh": false,
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "登录页"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/index/index",
|
||||
"style": {
|
||||
|
|
@ -18,6 +9,15 @@
|
|||
"navigationBarTitleText": "首页"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/login/index",
|
||||
"style": {
|
||||
"enablePullDownRefresh": false,
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "登录页"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/message/index",
|
||||
"style": {
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "",
|
||||
"navigationBarTitleText": "物业综合管理平台",
|
||||
"navigationBarBackgroundColor": "#F8F8F8",
|
||||
"backgroundColor": "#F8F8F8"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -96,6 +96,12 @@
|
|||
import {
|
||||
bannerList
|
||||
} from '@/api/banner';
|
||||
import {
|
||||
userInfo
|
||||
} from '@/api/login';
|
||||
import {
|
||||
newMessage
|
||||
} from '@/api/message';
|
||||
import {
|
||||
ref
|
||||
} from 'vue'
|
||||
|
|
@ -105,7 +111,7 @@
|
|||
declare const uni : Uni
|
||||
const card_back = uni.$globalData?.RESOURCE_URL + 'home/card-back.png'
|
||||
const keyword = ref<string>('')
|
||||
const messageCount = ref<number>(10)
|
||||
const messageCount = ref<number>(0)
|
||||
const current = ref<number>(0)
|
||||
const state = ref<string>('loading')
|
||||
|
||||
|
|
@ -254,8 +260,15 @@
|
|||
state.value = 'finished'
|
||||
})
|
||||
|
||||
// 加载页面数据
|
||||
const loadData = (async () => {
|
||||
var mess = await newMessage()
|
||||
messageCount.value = mess.data.count
|
||||
})
|
||||
|
||||
onLoad(() => {
|
||||
getBannerList()
|
||||
loadData()
|
||||
// getBannerList()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
</view>
|
||||
<view class="li-w-80% li-mx-auto li-mt-100">
|
||||
<!-- 账号 -->
|
||||
<wd-input :maxlength="11" placeholder="请输入账号" type='number' v-model="form.phone" prefix-icon="user"
|
||||
<wd-input :maxlength="11" placeholder="请输入账号" type='number' v-model="form.username" prefix-icon="user"
|
||||
placeholderStyle="font-size:30rpx" :focus-when-clear="false" clear-trigger="focus" clearable
|
||||
no-border />
|
||||
<!-- 密码 -->
|
||||
|
|
@ -22,19 +22,18 @@
|
|||
prefix-icon="secured" placeholderStyle="font-size:30rpx" :focus-when-clear="false"
|
||||
clear-trigger="focus" clearable no-border />
|
||||
</view>
|
||||
<view class="li-bg-white li-w-150 li-h-68">
|
||||
<image class="li-w-150 li-h-68" src="/static/code.jpg" mode=""></image>
|
||||
<view class="li-bg-white li-w-150 li-h-68" @click="getCode()">
|
||||
<image class="li-w-150 li-h-68" :src="captchaData.image" mode=""></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- button -->
|
||||
<view class="li-w-85% li-mx-auto li-mt-90">
|
||||
<wd-button @click="login" block custom-class="custom-shadow">登录</wd-button>
|
||||
<wd-button @click="loginHandle" block custom-class="custom-shadow">登录</wd-button>
|
||||
</view>
|
||||
<!-- -->
|
||||
<view
|
||||
class="li-flex li-items-center li-justify-center li-w-90% li-mx-auto li-text-#a5a5a5 li-text-24 li-mt-300">
|
||||
<wd-checkbox checked-color="#2EA1EA" v-model="check" @change="handleChange" />
|
||||
<view class="li-flex li-items-center li-justify-center li-w-90% li-mx-auto li-text-#a5a5a5 li-text-24 li-mt-32">
|
||||
<wd-checkbox checked-color="#2EA1EA" v-model="check" />
|
||||
阅读并同意
|
||||
<text class="li-text-#2EA1EA li-mx-10">
|
||||
《用户协议》
|
||||
|
|
@ -49,28 +48,103 @@
|
|||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive } from 'vue'
|
||||
import { captcha, login, userInfo } from '@/api/login';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import { md5 } from '@/utils/common';
|
||||
|
||||
interface formItem {
|
||||
phone : string
|
||||
username : string
|
||||
password : string
|
||||
code : string
|
||||
code : string,
|
||||
uuid : string
|
||||
}
|
||||
|
||||
interface CaptchaData {
|
||||
uuid : string
|
||||
image : string
|
||||
}
|
||||
|
||||
const form = ref<formItem>({
|
||||
phone: '',
|
||||
username: '',
|
||||
password: '',
|
||||
code: ""
|
||||
code: "",
|
||||
uuid: ""
|
||||
})
|
||||
|
||||
let captchaData = ref<CaptchaData>({
|
||||
uuid: '',
|
||||
image: ''
|
||||
})
|
||||
|
||||
const check = ref<boolean>(true)
|
||||
|
||||
const handleChange = ({ value }) => {
|
||||
console.log(value)
|
||||
}
|
||||
|
||||
const login = ()=>{
|
||||
const loginHandle = async () => {
|
||||
if (!check.value) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '请阅读并同意《用户协议》和《隐私政策》',
|
||||
duration: 2000
|
||||
})
|
||||
return;
|
||||
}
|
||||
if (!form.value.username) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '登录账号不能为空',
|
||||
duration: 2000
|
||||
})
|
||||
return;
|
||||
}
|
||||
if (!form.value.password) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '登录密码不能为空',
|
||||
duration: 2000
|
||||
})
|
||||
return;
|
||||
}
|
||||
if (!form.value.code) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '验证码不能为空',
|
||||
duration: 2000
|
||||
})
|
||||
return;
|
||||
}
|
||||
// 请求数据处理
|
||||
form.value.uuid = captchaData.value.uuid
|
||||
form.value.password = md5(form.value.password)
|
||||
const res = await login(form.value)
|
||||
if (res.code != 200) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: res.msg,
|
||||
duration: 3000
|
||||
})
|
||||
form.value.password = ""
|
||||
form.value.code = ""
|
||||
getCode()
|
||||
return;
|
||||
}
|
||||
// 登录成功,保存token,跳转首页
|
||||
uni.$store.commit("setToken", res.data.token)
|
||||
// 加载用户信息
|
||||
const user = await userInfo({})
|
||||
uni.$store.commit("setUserInfos", user.data)
|
||||
// 跳转至首页
|
||||
uni.switchTab({
|
||||
url:'/pages/index/index'
|
||||
})
|
||||
}
|
||||
|
||||
onShow(() => {
|
||||
getCode()
|
||||
});
|
||||
|
||||
const getCode = async () => {
|
||||
const res = await captcha({})
|
||||
captchaData.value = res.data as CaptchaData
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@
|
|||
<view class="li-flex li-justify-between li-items-center li-w-94% li-mx-auto li-mt-60">
|
||||
<view class="li-flex li-items-center">
|
||||
<view class="li-flex li-items-end li-mr-20">
|
||||
<image class="li-w-100 li-h-100 li-rd-50% border-4-white" src="/static/m_avatar.png" mode="">
|
||||
<image class="li-w-100 li-h-100 li-rd-50% border-4-white" :src="user_info.avatar" mode="">
|
||||
</image>
|
||||
</view>
|
||||
<view class="li-flex li-flex-col">
|
||||
<text class="li-text-38 li-text-#000000 li-mb-2">刘烨烨</text>
|
||||
<text class="li-text-24 li-text-#b1bbc7">辽宁中金物业集团有限公司</text>
|
||||
<text class="li-text-38 li-text-#000000 li-mb-2">{{user_info.realname}}</text>
|
||||
<text class="li-text-24 li-text-#b1bbc7">{{user_info.owner.name}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<image class="li-w-240 li-h-240" :src="mine_back" mode="aspectFill"></image>
|
||||
|
|
@ -78,9 +78,18 @@
|
|||
|
||||
<script setup lang="ts">
|
||||
import SafeAreaTop from '@/components/SafeAreaTop/index.vue'
|
||||
import { onLoad, onReachBottom, Uni } from "@dcloudio/uni-app"
|
||||
import { onShow, onReachBottom, Uni } from "@dcloudio/uni-app"
|
||||
import { ref } from "vue"
|
||||
declare const uni : Uni
|
||||
|
||||
const user_info = ref({
|
||||
"realname": "里派",
|
||||
"avatar": "/static/m_avatar.png",
|
||||
"owner": {
|
||||
"name": "里派(杭州)网络科技有限公司"
|
||||
}
|
||||
})
|
||||
|
||||
const mine_back = uni.$globalData?.RESOURCE_URL + 'mine/mine-back1.png'
|
||||
const card_back = uni.$globalData?.RESOURCE_URL + 'mine/card-back.png'
|
||||
|
||||
|
|
@ -137,9 +146,15 @@
|
|||
title: '设置',
|
||||
number: 0,
|
||||
icon: uni.$globalData?.RESOURCE_URL + 'mine/icon/shezhi.png'
|
||||
},
|
||||
|
||||
}
|
||||
])
|
||||
|
||||
onShow(async () => {
|
||||
const userInfo = await uni.$store.state.userInfos
|
||||
userInfo.realname && (user_info.value.realname = userInfo.realname)
|
||||
userInfo.avatar && (user_info.value.avatar = userInfo.avatar)
|
||||
userInfo.owner.name && (user_info.value.owner.name = userInfo.owner.name)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
import { userInfo } from '@/api/login'
|
||||
import { defineStore } from 'pinia'
|
||||
/**
|
||||
* 用户信息
|
||||
|
|
@ -11,7 +11,7 @@ export const useUserInfo = defineStore('userInfo', {
|
|||
}),
|
||||
actions: {
|
||||
async getUserInfo() {
|
||||
const res = await userInfoApi({})
|
||||
const res = await userInfo({})
|
||||
const data = res.data
|
||||
this.setUserInfos(data)
|
||||
return data
|
||||
|
|
@ -31,6 +31,9 @@ export const useUserInfo = defineStore('userInfo', {
|
|||
uni.clearStorageSync()
|
||||
this.userInfos = '';
|
||||
this.token = '';
|
||||
uni.redirectTo({
|
||||
url: "/pages/login/index"
|
||||
})
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
import CryptoJS from 'crypto-js';
|
||||
|
||||
/**
|
||||
* 将分转换为元(保留2位小数,带千分位)
|
||||
* @param cent 分为单位的金额
|
||||
|
|
@ -136,3 +138,24 @@ export const getCityCode = async (longitude : number, latitude : number) : Promi
|
|||
})
|
||||
})
|
||||
}
|
||||
|
||||
/*
|
||||
base64编码
|
||||
*/
|
||||
export const base64_encrypt = (data: String) => {
|
||||
return CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(data))
|
||||
}
|
||||
|
||||
/*
|
||||
base64解码
|
||||
*/
|
||||
export const base64_decrypt = (cipher: any) => {
|
||||
return CryptoJS.enc.Base64.parse(cipher).toString(CryptoJS.enc.Utf8)
|
||||
}
|
||||
|
||||
/*
|
||||
md5加密
|
||||
*/
|
||||
export const md5 = (data: String) => {
|
||||
return CryptoJS.MD5(data).toString()
|
||||
}
|
||||
|
|
@ -12,6 +12,7 @@ interface RequestOptions {
|
|||
//请求头
|
||||
const DEFAULT_HEADERS = {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + uni.getStorageSync('token')
|
||||
};
|
||||
|
||||
// 将对象转换为查询字符串的辅助函数
|
||||
|
|
@ -39,6 +40,11 @@ export const request = (endpoint: string, options: RequestOptions = {}) => {
|
|||
header: DEFAULT_HEADERS,
|
||||
success: (response) => {
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
if (response.data.code == 500) {
|
||||
uni.$store.commit("logout")
|
||||
reject(response.data)
|
||||
return;
|
||||
}
|
||||
resolve(response.data);
|
||||
} else {
|
||||
reject(new Error(`HTTP error! status: ${response.statusCode}`));
|
||||
|
|
|
|||
Loading…
Reference in New Issue