Browse Source

app2.0:我的:增加切换账号,解绑微信,我的二维码,修改密码;

yanshi
dyy 2 years ago
parent
commit
16d63d7ad7
6 changed files with 467 additions and 45 deletions
  1. +6
    -0
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages.json
  2. +22
    -5
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/login.vue
  3. +31
    -3
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/my.vue
  4. +289
    -0
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/my/bindaccount.vue
  5. +117
    -35
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/my/password.vue
  6. +2
    -2
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/my/qrcode.vue

+ 6
- 0
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages.json View File

@@ -116,6 +116,12 @@
"navigationBarTitleText": "更改密码"
}
},
{
"path": "pages/my/bindaccount",
"style": {
"navigationBarTitleText": "切换账号"
}
},
{
"path": "pages/my/learun",
"style": {


+ 22
- 5
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/login.vue View File

@@ -31,7 +31,7 @@
<l-input v-if="ready" v-model="password" placeholder="请输入密码" password left>
<l-icon slot="title" type="lock" />
</l-input>
<l-button @click="login(null)" size="lg" color="blue" class="margin-top-sm block" block>登 录</l-button>
<l-button id="loginBtn" data-id="loginBtn" @click="login(null)" size="lg" color="blue" class="margin-top-sm block" block>登 录</l-button>
<!-- <l-button v-if="enableSignUp" @click="signUp" size="lg" line="blue" class="margin-top-sm block" block>
教师注册
</l-button> -->
@@ -80,13 +80,13 @@ export default {
}
},

async onLoad() {
await this.init()
async onLoad({isBindAccountLogin,bindUserName,bindUserPassword}) {
await this.init(isBindAccountLogin,bindUserName,bindUserPassword)
},

methods: {
// 页面初始化
async init() {
async init(isBindAccountLogin,bindUserName,bindUserPassword) {
const index = this.DEV ? this.CONFIG('devApiHostIndex') : this.CONFIG('prodApiHostIndex')
this.apiRootList = this.CONFIG('apiHost')
this.currentApiRoot = this.apiRootList[index]
@@ -98,7 +98,17 @@ export default {
this.username = account.username
this.password = account.password
}
this.ready = true
this.ready = true
//切换账号登录时:登录页赋值,触发登录事件;
if(isBindAccountLogin==1){
this.username=bindUserName
this.password=bindUserPassword
let _this = this;
setTimeout(function(){_this.login(null)},1000)
}
},

// 点击新用户注册
@@ -158,11 +168,13 @@ export default {
if (!loginResult) {
return
}

// loginUser 中合并 role、post 两个字段
const { baseinfo, mpinfo, post, role } = loginResult
const user = { ...baseinfo, post, role }
const token = baseinfo.token
const pwd = loginResult.pwd

// 返回的用户信息中,有 mpinfo 字段表示是否是小程序
if (mpinfo && Array.isArray(mpinfo) && mpinfo.includes(type)) {
@@ -173,8 +185,13 @@ export default {
this.SET_GLOBAL('loginUser', user)

this.SET_STORAGE('token', token)
this.SET_STORAGE('pwd', pwd)

this.HIDE_LOADING()
if(this.GET_STORAGE('pwd') == true){
this.NAV_TO('/pages/my/password')
return
}
this.TAB_TO('/pages/home')
},



+ 31
- 3
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/my.vue View File

@@ -25,15 +25,24 @@
<l-icon type="phone" color="blue" />
联系方式
</l-list-item>
<!-- <l-list-item @click="goTo('qrcode')" arrow>
<l-list-item @click="goTo('qrcode')" arrow>
<l-icon type="qrcode" color="blue" />
我的二维码
</l-list-item> -->
</l-list-item>
<l-list-item @click="goTo('password')" arrow>
<l-icon type="edit" color="blue" />
修改密码
</l-list-item>
<l-list-item @click="goTo('bindaccount')" arrow>
<l-icon type="group" color="blue" />
切换账号
</l-list-item>
</l-list>
<l-list border card>
<l-list-item @click="unbundweixin">
解绑微信
</l-list-item>
</l-list>

<!-- 关于菜单 -->
<!-- <l-list border card>
@@ -91,6 +100,25 @@ export default {
this.CLEAR_GLOBAL()
this.RELAUNCH_TO('/pages/login')
},
//点击 [解绑微信] 按钮
async unbundweixin(){
if (!(await this.CONFIRM('解绑确认', '确定要解绑微信账号吗?', true))) {
return
}
const success = await this.HTTP_POST(
'learun/adms/user/unbundWeiXin',
{},
'解绑微信账号失败'
)
if (!success) {
return
}
this.CLEAR_GLOBAL()
this.RELAUNCH_TO('/pages/login')
},

// #ifdef MP-ALIPAY || MP-WEIXIN
// 小程序绑定方法,只会编译到小程序
@@ -156,7 +184,7 @@ export default {
return ''
}

return this.API + `/user/img?data=${this.currentUser.userId}`
return this.API + `learun/adms/user/img?data=${this.currentUser.userId}`
}
},



+ 289
- 0
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/my/bindaccount.vue View File

@@ -0,0 +1,289 @@
<template>
<view class="page">
<!-- 主列表页 -->
<view
:class="sideOpen ? 'show' : ''"
class="mainpage"
style="padding-top: 80rpx"
>
<!-- 顶部条目/分页信息栏 -->
<l-customlist-banner @buttonClick="sideOpen = true">{{
tips
}}</l-customlist-banner>

<!-- 滚动列表,跨端支持上拉/下拉 -->
<l-scroll-list
v-if="ready"
@pullDown="pullDown"
@toBottom="fetchList()"
ref="list"
>
<l-customlist :tips="loadState" showTips>
<!-- 单条记录 -->
<view class="customlist-item" v-for="item of list" :key="item.Id">
<view class="customlist-item-field">
<text class="customlist-item-field-title">绑定账号:</text>
{{ displayListItem(item, "BindUserAccount") }}
</view>

<view class="customlist-item-field">
<text class="customlist-item-field-title">绑定时间:</text>
{{ displayListItem(item, "CreateTime") }}
</view>

<l-customlist-action
showButton
buttonText='登录'
icontype='roundright'
@join="action('tologin', item)"
hideView
/>
</view>
</l-customlist>
</l-scroll-list>
</view>

<!-- 关闭侧边抽屉按钮 -->
<view
@click="sideOpen = false"
:class="sideOpen ? 'show' : ''"
class="sideclose"
>
<l-icon type="pullright" color="blue" />
</view>

<!-- 侧边栏,用于设置查询条件 -->
<scroll-view :class="sideOpen ? 'show' : ''" class="sidepage" scroll-y>
<view v-if="ready" class="padding">
<l-input
v-model="queryData.BindUserAccount"
@change="searchChange"
title="绑定账号"
placeholder="按绑定账号查询"
/>

<!-- 重置查询条件按钮 -->
<view class="padding-tb">
<l-button @click="reset" line="orange" class="block" block
>重置查询条件</l-button
>
</view>
</view>
</scroll-view>

</view>
</template>


<script>
/*
* 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
* Copyright (c) 2013-2021 上海力软信息技术有限公司
* 创建人:超级管理员
* 日 期:2021-03-08 10:36
* 描 述:切换账号
*/

/**
* 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
* 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
* { "path": "pages/my/bindaccount", "style": { "navigationBarTitleText": "表单列表页" } }
*
* (navigationBarTitleText 字段为本页面的标题文本,可以修改)
* (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
*/
import moment from "moment";
import get from "lodash/get";
import set from "lodash/set";
import pickBy from "lodash/pickBy";
import mapValues from "lodash/mapValues";

export default {
data() {
return {
// 数据项的数据类型、结构
scheme: {
BindUserAccount: { type: "text" },
CreateTime: { type: "datetime" },
},

// 查询条件
searchData: {},
defaultQueryData: {},
queryData: {
BindUserAccount: "",
},

// 数据源
dataSource: {},

// 页面相关参数
ready: false,
tips: "加载中...",
loadState: "向下翻以加载更多",
sideOpen: false,

// 列表与分页信息
page: 1,
total: 2,
list: [],
};
},

async onLoad() {
await this.init();
},
onUnload() {
this.OFF("EducationalAdministrationLoginUserBind-list-change");
},

methods: {
// 页面初始化
async init() {
this.ON(
"EducationalAdministrationLoginUserBind-list-change",
this.refreshList
);

// 拉取加载列表和数据源
await Promise.all([() => {}]);
await this.fetchList();
// 初始化查询条件
this.defaultQueryData = this.COPY(this.queryData);
this.ready = true;
},

// 拉取列表
async fetchList() {
if (this.page > this.total) {
return;
}
this.searchData.CreateUserId=this.GET_GLOBAL('loginUser').userId
const result = await this.HTTP_GET(
"learun/EducationalAdministration/LoginUserBind/pagelist",
{
// 这里 sidx 表示排序字段,sord 表示排序方式(DESC=降序,ASC=升序)
// 代码生成器生成时默认按照主键排序,您可以修改成按创建时间的字段降序
pagination: { rows: 10, page: this.page, sidx: "CreateTime desc", sord: "DESC" },
queryJson: JSON.stringify(this.searchData),
},
"加载数据时出错"
);

if (!result) {
return;
}

this.total = result.total;
this.page = result.page + 1;
this.list = this.list.concat(result.rows);

this.tips = `已加载 ${Math.min(result.page, result.total)} / ${
result.total
} 页,共 ${result.records} 项`;
this.loadState =
result.page >= result.total ? "已加载所有项目" : "向下翻以加载更多";
},

// 刷新清空列表
async refreshList() {
this.page = 1;
this.total = 2;
this.list = [];

await this.fetchList();
},

// 列表下拉
pullDown() {
this.refreshList().then(() => {
this.$refs.list.stopPullDown();
});
},

// 设置搜索条件
async searchChange() {
const result = {};

// 将其他查询项添加到查询 JSON 中
const queryObj = pickBy(this.queryData, (t) =>
Array.isArray(t) ? t.length > 0 : t
);
Object.assign(
result,
mapValues(queryObj, (t) => (Array.isArray(t) ? t.join(",") : t))
);
this.searchData = result;
await this.refreshList();
},

// 点击「清空查询条件」按钮
reset() {
this.queryData = this.COPY(this.defaultQueryData);
this.searchChange();
},

// 点击「登录」、按钮
async action(type, item) {
switch (type) {
case "tologin":
this.NAV_TO(`/pages/login?isBindAccountLogin=1&bindUserName=${item.BindUserAccount}&bindUserPassword=${item.BindUserPassword}`);
return;

default:
return;
}
},

// 显示列表中的标题项
displayListItem(item, field) {
const fieldItem = this.scheme[field];
const value = item[field];

switch (fieldItem.type) {
case "currentInfo":
case "organize":
return fieldItem.dataType === "time"
? value
: get(this.GET_GLOBAL(fieldItem.dataType), `${value}.name`, "");

case "radio":
case "select":
const selectItem = this.dataSource[field].find(
(t) => t.value === String(value)
);
return get(selectItem, "text", "");

case "checkbox":
if (!value || value.split(",").length <= 0) {
return "";
}
const checkboxItems = value.split(",");
return this.dataSource[field]
.filter((t) => checkboxItems.includes(t.value))
.map((t) => t.text)
.join(",");

case "datetime":
if (!value) {
return "";
}
return moment(value).format(
Number(fieldItem.dateformat) === 0
? "YYYY年 M月 D日"
: "YYYY-MM-DD HH:mm"
);

default:
return value === null || value === undefined ? "" : value;
}
},
},
};
</script>


<style lang="less" scoped>
@import "~@/common/css/sidepage.less";
@import "~@/common/css/customlist.less";
</style>

+ 117
- 35
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/my/password.vue View File

@@ -1,59 +1,141 @@
<template>
<view class="page">
<l-title>修改密码</l-title>
<l-input v-model="oldPwd" title="旧密码" placeholder="请输入旧密码" password></l-input>
<l-input v-model="newPwd" title="新的密码" placeholder="请输入新密码" password></l-input>
<l-input v-model="confirmPwd" title="确认输入" placeholder="请再次输入新密码" password></l-input>
<l-input
@input="setValue('password.oldPwd', $event)"
:value="getValue('password.oldPwd')"
password
title="旧密码"
/>
<l-input
@input="setValue('password.newPwd', $event)"
:value="getValue('password.newPwd')"
password
title="新密码"
/>
<l-input
@input="setValue('password.confirmPwd', $event)"
:value="getValue('password.confirmPwd')"
password
title="确认输入"
placeholder="请再次输入新密码"
/>

<view class="margin-sm">新密码必须8-20位同时包含1.[大小写字母]、2[数字]、3[特殊符号!@@#$%^&*]</view>

<view class="margin-sm text-red" v-if="strongFlag">您的密码不满足强度要求,请您先修改密码后再执行系统其他操作!</view>
<view class="padding">
<l-button @click="submit" size="lg" color="blue" class="block" block>确认修改</l-button>
</view>
<view class="padding" v-if="strongFlag">
<l-button @click="logout" size="lg" color="red" class="block" block>退出</l-button>
</view>
</view>
</template>

<script>
<script>
import get from 'lodash/get'
import set from 'lodash/set'
import customPageMixins from '@/common/custompage.js'
export default {
mixins: [customPageMixins],
data() {
return {
oldPwd: '',
newPwd: '',
confirmPwd: ''
strongFlag:false,
// 表单数据
current: {},
origin: {},
// 表单项数据结构
scheme: {
password:{
oldPwd: { type: 'text',title:'旧密码',verify:'NotNull' },
newPwd: { type: 'text',title:'新密码',verify:'NotNull' },
confirmPwd: { type: 'text',title:'确认密码',verify:'NotNull' },
}
},
}
},

async onLoad({}){
await this.init();
},

methods: {
async init(){
//判断是否是验证强密码打开的页面
console.log(this.GET_STORAGE('pwd'))
if(this.GET_STORAGE('pwd') == true){
this.strongFlag=true
}
this.origin = await this.getDefaultForm()
this.current=this.COPY(this.origin)
},
// 提交修改
async submit() {
const { auth, oldPwd, newPwd, confirmPwd } = this
if (oldPwd.length < 6) {
this.CONFIRM('操作失败', '旧密码输入不正确,请重新确认')
return
}
if (newPwd.length < 6 || newPwd.length > 16) {
this.CONFIRM('操作失败', '新密码不符合要求,请修改后重试')
return
}
if (newPwd !== confirmPwd) {
this.CONFIRM('操作失败', '新密码和确认密码输入不一致,请修改')
return
}
const verifyResult = this.verifyForm()
if (verifyResult.length > 0) {
this.CONFIRM('表单验证失败', verifyResult.join('\n'))
return
}
const postData = await this.getPostData()
const postVal = JSON.parse(postData.strEntity)
var reg = /^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*,\.])[0-9a-zA-Z!@#$%^&*,\.]{8,20}$/;
if(!reg.test(postVal.newPwd)){
this.TOAST('新密码不满足强度要求');
return ;
}
if(postVal.newPwd != postVal.confirmPwd){
this.TOAST('新密码和确认密码输入不一致');
return ;
}

const success = await this.HTTP_POST(
'learun/adms/user/modifypw',
{
newpassword: this.MD5(newPwd),
oldpassword: this.MD5(oldPwd)
},
'未能成功修改密码'
)
const success = await this.HTTP_POST(
'learun/adms/user/modifypw',
{
newpassword: this.MD5(postVal.newPwd),
oldpassword: this.MD5(postVal.oldPwd)
},
'未能成功修改密码'
)

if (!success) {
return
}

this.NAV_BACK()
this.TOAST('密码修改成功')
}
if (!success) {
return
}
// this.NAV_BACK()
this.TOAST('密码修改成功')
this.CLEAR_GLOBAL()
this.RELAUNCH_TO('/pages/login')
},
// 点击「注销登录」按钮
async logout() {
if (!(await this.CONFIRM('注销确认', '确定要注销登录吗?', true))) {
return
}
this.CLEAR_GLOBAL()
this.RELAUNCH_TO('/pages/login')
},
// 获取表单值
getValue(path) {
return get(this.current, path)
},
// 设置表单值
setValue(path, val) {
set(this.current, path, val)
} ,
}
}
</script>

+ 2
- 2
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/my/qrcode.vue View File

@@ -18,7 +18,7 @@
export default {
data() {
return {
qrCodeValue: 'http://www.learun.cn/'
qrCodeValue: this.GET_GLOBAL('loginUser').userId
}
},

@@ -30,7 +30,7 @@ export default {

// 头像图片 url
avatar() {
return this.API + `/user/img?data=${this.currentUser.userId}`
return this.API + `learun/adms/user/img?data=${this.currentUser.userId}`
},

// 用户公司部门 tag


Loading…
Cancel
Save