Commit f3f00306 authored by leon's avatar leon

feat: page add share

parent 17888a7c
...@@ -125,7 +125,10 @@ ...@@ -125,7 +125,10 @@
this.getReportIdList() this.getReportIdList()
} }
this.getReportCharts() this.getReportCharts()
}, },
onShareAppMessage() {
},
onShow() { onShow() {
const that = this const that = this
/** /**
......
...@@ -115,7 +115,11 @@ ...@@ -115,7 +115,11 @@
onLoad() { onLoad() {
this.userAuthCheck() this.userAuthCheck()
}, },
onShareAppMessage() {
},
// detail页面也会监听这两个事件,所有index页面需要在onShow里面增加监听,在onHide里面移除监听 // detail页面也会监听这两个事件,所有index页面需要在onShow里面增加监听,在onHide里面移除监听
onShow() { onShow() {
const that = this const that = this
......
<template> <template>
<view class="wrap"> <view class="wrap">
<view class="content"> <view class="content">
<u-form <u-form ref="uForm" :model="params" :error-type="['toast']" :label-width="200">
ref="uForm" <u-form-item label="用户名" prop="userName">
:model="params" <u-input v-model="params.userName" placeholder="请输入用户名" type="text" />
:error-type="['toast']" </u-form-item>
:label-width="200" <u-form-item label="密码" prop="password">
> <u-input v-model="params.password" placeholder="请输入密码" type="password" :password-icon="true" />
<u-form-item label="用户名" prop="userName"> </u-form-item>
<u-input <u-form-item label="员工号(选填)" prop="staffNo">
v-model="params.userName" <u-input v-model="params.staffNo" placeholder="填写员工号可以更精确的获取权限" type="number" />
placeholder="请输入用户名" </u-form-item>
type="text" </u-form>
/> <u-button class="my-u-block u-m-t-80" type="warning" shape="square" :ripple="true" @click="submit('login')"
</u-form-item> :disabled="!submitDisabled">登入</u-button>
<u-form-item label="密码" prop="password"> <u-button class="my-u-block u-m-t-80" type="warning" shape="square" :ripple="true"
<u-input @click="submit('register')" :disabled="!submitDisabled">注册</u-button>
v-model="params.password"
placeholder="请输入密码" <text class="tips-text">使用须知:仅限企业内部人员使用,使用前需要认证用户</text>
type="password" </view>
:password-icon="true" </view>
/> </template>
</u-form-item>
<u-form-item label="员工号(选填)" prop="staffNo"> <script>
<u-input export default {
v-model="params.staffNo" data() {
placeholder="填写员工号可以更精确的获取权限" return {
type="number" params: {
/> appId: wx.getAccountInfoSync().miniProgram.appId,
</u-form-item> userName: '',
</u-form> password: '',
<u-button staffNo: ''
class="my-u-block u-m-t-80" },
type="warning" rules: {
shape="square" userName: [{
:ripple="true" required: true,
@click="submit('login')" message: '请输入用户名',
:disabled="!submitDisabled" trigger: 'blur'
>登入</u-button> }],
<u-button password: [{
class="my-u-block u-m-t-80" required: true,
type="warning" message: '请输入密码',
shape="square" trigger: 'blur'
:ripple="true" }],
@click="submit('register')" staffNumber: [{
:disabled="!submitDisabled" required: true,
>注册</u-button> message: '员工号(选填)',
trigger: 'blur'
<text class="tips-text">使用须知:仅限企业内部人员使用,使用前需要认证用户</text> }]
</view> }
</view> }
</template> },
computed: {
<script> submitDisabled() {
export default { return this.params.userName && this.params.password
data() { }
return { },
params: { methods: {
appId: wx.getAccountInfoSync().miniProgram.appId, // 登录
userName: '', submit(type) {
password: '', this.$refs.uForm.validate(async valid => {
staffNo:'' if (valid) {
}, var info = {
rules: { url: this.$u.api.quickLogin(this.params),
userName: [ msg: '登录成功'
{ required: true, message: '请输入用户名', trigger: 'blur' } }
], if ('register' == type) {
password: [ info = {
{ required: true, message: '请输入密码', trigger: 'blur' } url: this.$u.api.register(this.params),
], msg: '注册成功'
staffNumber:[ }
{ required: true, message: '员工号(选填)', trigger: 'blur' } }
] let res = await info.url
} const {
} Status,
}, Result
computed: { } = res.data
submitDisabled() { if (Status === 'true') {
return this.params.userName && this.params.password this.$u.vuex('vuex_token', `${res.token_type} ${res.access_token}`)
} this.$u.toast(info.msg)
}, this.removeUserStorage()
methods: { this.saveUserStorage(res.data.Result)
// 登录 // 登录成功后返回来源页面
submit(type) { let timer = setTimeout(() => {
this.$refs.uForm.validate(async valid => { const backUrl = uni.getStorageSync('back_url') || '/pages/index/index'
if (valid) { this.$u.route({
var info = { type: 'reLaunch',
url: this.$u.api.quickLogin(this.params), url: backUrl
msg: '登录成功' })
} clearTimeout(timer)
if ('register' == type) { }, 500)
info = { } else {
url: this.$u.api.register(this.params), this.$u.toast(res.data.Msg)
msg: '注册成功' }
} } else {
} console.log('验证失败');
let res = await info.url }
const { Status, Result } = res.data })
if (Status === 'true') { },
this.$u.vuex('vuex_token', `${res.token_type} ${res.access_token}`)
this.$u.toast(info.msg) // 清除用户信息
this.removeUserStorage() removeUserStorage() {
this.saveUserStorage(res.data.Result) uni.removeStorageSync('userId');
// 登录成功后返回来源页面 uni.removeStorageSync('username');
let timer = setTimeout(() => { uni.removeStorageSync('appId');
const backUrl = uni.getStorageSync('back_url') || '/pages/index/index' uni.removeStorageSync('authorized');
this.$u.route({ uni.removeStorageSync('admin');
type: 'reLaunch', uni.removeStorageSync('show');
url: backUrl },
}) // 存储用户信息
clearTimeout(timer) saveUserStorage(info) {
}, 500) uni.setStorageSync('userId', info.id);
} else { uni.setStorageSync('username', info.userName);
this.$u.toast(res.data.Msg) uni.setStorageSync('appId', info.appId);
} uni.setStorageSync('authorized', info.authorized);
} else { uni.setStorageSync('admin', info.admin);
console.log('验证失败'); uni.setStorageSync('show', info.show);
} uni.setStorageSync('staffNo', info.staffNo);
}) }
},
},
// 清除用户信息 onReady() {
removeUserStorage() { this.$refs.uForm.setRules(this.rules)
uni.removeStorageSync('userId'); },
uni.removeStorageSync('username'); onShareAppMessage() {
uni.removeStorageSync('appId');
uni.removeStorageSync('authorized'); }
uni.removeStorageSync('admin');
uni.removeStorageSync('show'); };
}, </script>
// 存储用户信息
saveUserStorage(info) { <style lang="scss" scoped>
uni.setStorageSync('userId', info.id); .tips-text {
uni.setStorageSync('username', info.userName); color: black;
uni.setStorageSync('appId', info.appId); size: 20rpx;
uni.setStorageSync('authorized', info.authorized); padding-top: 50rpx;
uni.setStorageSync('admin', info.admin); }
uni.setStorageSync('show', info.show); </style>
uni.setStorageSync('staffNo', info.staffNo);
}
},
onReady() {
this.$refs.uForm.setRules(this.rules)
}
};
</script>
<style lang="scss" scoped>
.tips-text {
color: black;
size: 20rpx;
padding-top: 50rpx;
}
</style>
\ No newline at end of file
...@@ -46,6 +46,10 @@ ...@@ -46,6 +46,10 @@
onLoad() { onLoad() {
this.getReportList() this.getReportList()
}, },
onShareAppMessage() {
},
methods: { methods: {
/** /**
* 获取页面报表配置 * 获取页面报表配置
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment