Commit c3a4a5ff authored by 刘怀志's avatar 刘怀志

feat(我的): 对接接口

parent cb93c6b7
...@@ -50,6 +50,13 @@ export function getInfo() { ...@@ -50,6 +50,13 @@ export function getInfo() {
'method': 'get' 'method': 'get'
}) })
} }
// 获取用户详细信息
export function getUserInfoConsole() {
return request({
'url': '/console/userinfo',
'method': 'get'
})
}
// 退出方法 // 退出方法
export function logout() { export function logout() {
......
...@@ -74,3 +74,10 @@ export function CardPaymentVip(data) { ...@@ -74,3 +74,10 @@ export function CardPaymentVip(data) {
data: data data: data
}) })
} }
export function getQRById(id) {
return request({
url: '/staff/getUserInfoByUserId/' + id,
method: 'get',
responseType: 'arraybuffer'
})
}
...@@ -21,12 +21,12 @@ ...@@ -21,12 +21,12 @@
<img class="user-img" :src="headImg" /> <img class="user-img" :src="headImg" />
<view class="use-info"> <view class="use-info">
<view class="user-name"> <view class="user-name">
<text class="name-text">张三</text> <text class="name-text">{{userInfoConsole.idmName}}</text>
<text class="name-text">·</text> <text class="name-text">·</text>
<text class="name-text">品质担当</text> <text class="name-text">{{userInfoConsole.productionRoleName}}</text>
</view> </view>
<view class="dept"> <view class="dept">
<text>发动机装配科</text> <text>{{userInfoConsole.deptName}}</text>
</view> </view>
</view> </view>
<img class="qr-icon" :src="qrImg" @click="viewCode" /> <img class="qr-icon" :src="qrImg" @click="viewCode" />
...@@ -39,11 +39,13 @@ ...@@ -39,11 +39,13 @@
<img class="user-img-popup" :src="headImg" /> <img class="user-img-popup" :src="headImg" />
<view> <view>
<text class="user-title"> <text class="user-title">
陈海毅 | 发动机装配科 {{userInfoConsole.idmName}}{{userInfoConsole.deptName}}
</text> </text>
</view> </view>
<view> <view class="qrcode">
<canvas id="myQrcode" type="2d" style="width: 440rpx; height: 440rpx;" /> <div style="width: 440rpx; height: 440rpx;">
<img :src="QrImg" alt="" />
</div>
</view> </view>
</view> </view>
<view style="position: relative;left: 41%;top: 80rpx;" @click="close"> <view style="position: relative;left: 41%;top: 80rpx;" @click="close">
...@@ -59,6 +61,9 @@ ...@@ -59,6 +61,9 @@
<script> <script>
import drawQrcode from '../../utils/dist_weapp.qrcode.esm' import drawQrcode from '../../utils/dist_weapp.qrcode.esm'
import { mapGetters } from 'vuex'
import {getUserInfoConsole} from "../../api/login";
import {getQRById} from "../../api/system/user";
/** /**
* @property {String} title 导航栏标题,如设置为空字符,将会隐藏标题占位区域 * @property {String} title 导航栏标题,如设置为空字符,将会隐藏标题占位区域
* @property {String | Number} titleWidth 导航栏标题的最大宽度,内容超出会以省略号隐藏 * @property {String | Number} titleWidth 导航栏标题的最大宽度,内容超出会以省略号隐藏
...@@ -128,6 +133,8 @@ export default { ...@@ -128,6 +133,8 @@ export default {
}, },
data() { data() {
return { return {
QrImg: null,
userInfoConsole: {},
popStyle: { popStyle: {
background: 'url("/static/images/popBackground.png") center/contain no-repeat', background: 'url("/static/images/popBackground.png") center/contain no-repeat',
backgroundColor: 'transparent', backgroundColor: 'transparent',
...@@ -135,27 +142,46 @@ export default { ...@@ -135,27 +142,46 @@ export default {
height: '860rpx' height: '860rpx'
}, },
showCode: false, showCode: false,
headImg: require('../../static/images/profile.jpg'), headImg: require('../../static/images/home-avatar.svg'),
qrImg: require('../../static/images/qrImg.png'), qrImg: require('../../static/images/qrImg.png'),
iconClose: require('../../static/images/iconClose.png') iconClose: require('../../static/images/iconClose.png')
} }
}, },
computed: { computed: {
...mapGetters(['userInfo']),
totalHeight() { totalHeight() {
return uni.$u.addUnit(uni.$u.getPx(this.height) + uni.$u.sys().statusBarHeight, 'px') return uni.$u.addUnit(uni.$u.getPx(this.height) + uni.$u.sys().statusBarHeight, 'px')
} }
}, },
onShow() {
},
onLoad() { onLoad() {
}, },
created() { created() {
this.getUserInfo()
}, },
mounted() { mounted() {
}, },
methods: { methods: {
getUserInfo() {
getUserInfoConsole().then(res => {
console.log('获取用户信息', res)
this.userInfoConsole = res.data
})
},
// 获取二维码
getQrCode() {
getQRById(this.userInfo.businessId).then(async res => {
// 将 arraybuffer 转换为 Blob 对象
const blob = new Blob([res], { type: 'image/png' }); // 假设返回的是 PNG 图片,根据实际情况修改类型
// 使用 Blob 对象创建 URL
this.QrImg = window.URL.createObjectURL(blob);
this.showCode = true;
});
},
// 创建二维码 // 创建二维码
createQrcode: function() { createQrcode: function() {
var that = this var that = this
...@@ -204,8 +230,7 @@ export default { ...@@ -204,8 +230,7 @@ export default {
}, },
// 点击二维码 // 点击二维码
viewCode() { viewCode() {
this.createQrcode() this.getQrCode()
this.showCode = true
}, },
} }
} }
...@@ -310,4 +335,9 @@ export default { ...@@ -310,4 +335,9 @@ export default {
z-index: -1; z-index: -1;
background: url('https://qf.91isoft.com/cwfile/tmt-pic/pet-app/%E9%A1%B6%E9%83%A8%E8%83%8C%E6%99%AF-img.png') center/cover no-repeat; background: url('https://qf.91isoft.com/cwfile/tmt-pic/pet-app/%E9%A1%B6%E9%83%A8%E8%83%8C%E6%99%AF-img.png') center/cover no-repeat;
} }
.qrcode{
display: flex;
justify-content: center;
align-items: center;
}
</style> </style>
\ No newline at end of file
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<view class="header-section" @click="goMyAccount"> <view class="header-section" @click="goMyAccount">
<view class="section-detail"> <view class="section-detail">
<view class="detail-left"> <view class="detail-left">
<image :src="userInfo" class="icon-left" /> <image :src="userInfoImg" class="icon-left" />
<view class="user-info"> <view class="user-info">
<text> <text>
个人信息 个人信息
...@@ -269,12 +269,13 @@ import { getPetOwners } from '../../api/system/pet' ...@@ -269,12 +269,13 @@ import { getPetOwners } from '../../api/system/pet'
import { myAccountList } from '../../api/system/my_account' import { myAccountList } from '../../api/system/my_account'
import config from '@/config' import config from '@/config'
import { listBaseConfig } from '../../api/system/baseConfig' import { listBaseConfig } from '../../api/system/baseConfig'
import {mineNavbar} from '../../components/mine-navbar/mineNavbar' import MineNavbar from '../../components/mine-navbar/mineNavbar.vue'
import { mapGetters } from 'vuex'
export default { export default {
components: { mineNavbar }, components: { MineNavbar },
data() { data() {
return { return {
userInfo: require('../../static/images/userInfo.png'), userInfoImg: require('../../static/images/userInfo.png'),
logout: require('../../static/images/logout.png'), logout: require('../../static/images/logout.png'),
show: false, show: false,
hosConfig: { hosConfig: {
...@@ -307,30 +308,18 @@ export default { ...@@ -307,30 +308,18 @@ export default {
user: '', user: '',
userId: '', userId: '',
form: {}, form: {},
avatar: '',
avatar123: '', avatar123: '',
baseUrl: config.imageUrl baseUrl: config.imageUrl
} }
}, },
computed: { computed: {
avatar() { ...mapGetters(['userInfo']),
this.avatar123 = this.$store.state.user.avatar
return this.$store.state.user.avatar
},
windowHeight() { windowHeight() {
return uni.getSystemInfoSync().getInfowindowHeight - 50 return uni.getSystemInfoSync().getInfowindowHeight - 50
} }
}, },
onShow() { onShow() {
if (this.isAddFlag === true) {
this.$u.toast('添加账户成功')
this.isAddFlag = false
setTimeout(this.getUserinfo, 1000)
}
this.getuser()
this.getUserinfo()
this.getConfig()
}, },
methods: { methods: {
handleLogout() { handleLogout() {
...@@ -365,15 +354,6 @@ export default { ...@@ -365,15 +354,6 @@ export default {
this.show = true this.show = true
} }
}, },
getConfig() {
listBaseConfig({ type: '2' }).then(response => {
if (response.code === 200 && response.rows.length > 0) {
const obj = JSON.parse(response.rows[0].content)
this.hosConfig = obj
console.log('1111111', obj)
}
})
},
// 功能未开放提示 // 功能未开放提示
toastaction() { toastaction() {
uni.showToast({ uni.showToast({
...@@ -494,24 +474,6 @@ export default { ...@@ -494,24 +474,6 @@ export default {
handleHelp() { handleHelp() {
this.$tab.navigateTo('/pages/mine/help/index') this.$tab.navigateTo('/pages/mine/help/index')
}, },
getUserinfo() {
const value = JSON.parse(uni.getStorageSync('user'))
this.petOwnerId = value.petOwnerId
console.log('宠zhuid', this.petOwnerId)
myAccountList({ petsOwnersId: this.petOwnerId }).then(res => {
console.log('myAccountList', res)
this.cardList = res.data
this.cardListLength = res.data.length
})
getPetOwners(this.petOwnerId).then(response => {
this.form = response.data[0]
if (this.form.ownersCover !== null && this.form.ownersCover !== '' && this.form.ownersCover !== undefined) {
this.ownersCover = this.form.ownersCover
}
console.log('宠物主信息', this.form)
console.log('宠物主信息', this.form.nickname)
})
},
handleSetting() { handleSetting() {
this.$tab.navigateTo('/pages/mine/setting/index') this.$tab.navigateTo('/pages/mine/setting/index')
}, },
...@@ -524,17 +486,6 @@ export default { ...@@ -524,17 +486,6 @@ export default {
handleBuilding() { handleBuilding() {
this.$modal.showToast('模块建设中~') this.$modal.showToast('模块建设中~')
}, },
// 查询用户信息获取到用户id
getuser() {
getUserProfile().then(res => {
this.userId = res.data.userId
this.user = res.data
this.avatar = res.data.avatar
console.log('res', res)
console.log('this.user1111111', this.user)
console.log('user', this.avatar)
})
}
} }
} }
</script> </script>
......
This diff is collapsed.
...@@ -5,6 +5,7 @@ const getters = { ...@@ -5,6 +5,7 @@ const getters = {
roles: state => state.user.roles, roles: state => state.user.roles,
permissions: state => state.user.permissions, permissions: state => state.user.permissions,
isShowConfirm: state => state.user.isShowConfirm, isShowConfirm: state => state.user.isShowConfirm,
userInfo: state => state.user.userInfo,
logoutBtn: state => state.user.logoutBtn logoutBtn: state => state.user.logoutBtn
} }
export default getters export default getters
...@@ -13,6 +13,7 @@ const user = { ...@@ -13,6 +13,7 @@ const user = {
avatar: storage.get(constant.avatar), avatar: storage.get(constant.avatar),
roles: storage.get(constant.roles), roles: storage.get(constant.roles),
permissions: storage.get(constant.permissions), permissions: storage.get(constant.permissions),
userInfo: storage.get(constant.userInfo),
isShowConfirm: true, isShowConfirm: true,
logoutBtn: false logoutBtn: false
}, },
...@@ -35,6 +36,10 @@ const user = { ...@@ -35,6 +36,10 @@ const user = {
state.avatar = avatar state.avatar = avatar
storage.set(constant.avatar, avatar) storage.set(constant.avatar, avatar)
}, },
SET_USER_INFO: (state, info) => {
state.userInfo = info
storage.set(constant.userInfo, info)
},
SET_ROLES: (state, roles) => { SET_ROLES: (state, roles) => {
state.roles = roles state.roles = roles
storage.set(constant.roles, roles) storage.set(constant.roles, roles)
...@@ -77,15 +82,16 @@ const user = { ...@@ -77,15 +82,16 @@ const user = {
GetInfo({ commit, state }) { GetInfo({ commit, state }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
getInfo().then(res => { getInfo().then(res => {
const user = res.user const user = res.data.user
const avatar = (user == null || user.avatar == "" || user.avatar == null) ? require("@/static/images/profile.jpg") : baseUrl + user.avatar const avatar = (user == null || user.avatar == "" || user.avatar == null) ? require("@/static/images/profile.jpg") : baseUrl + user.avatar
const username = (user == null || user.userName == "" || user.userName == null) ? "" : user.userName const username = (user == null || user.userName == "" || user.userName == null) ? "" : user.userName
if (res.roles && res.roles.length > 0) { if (res.data.roles && res.data.roles.length > 0) {
commit('SET_ROLES', res.roles) commit('SET_ROLES', res.data.roles)
commit('SET_PERMISSIONS', res.permissions) commit('SET_PERMISSIONS', res.data.permissions)
} else { } else {
commit('SET_ROLES', ['ROLE_DEFAULT']) commit('SET_ROLES', ['ROLE_DEFAULT'])
} }
commit('SET_USER_INFO', user)
commit('SET_NAME', username) commit('SET_NAME', username)
commit('SET_AVATAR', avatar) commit('SET_AVATAR', avatar)
resolve(res) resolve(res)
...@@ -102,6 +108,7 @@ const user = { ...@@ -102,6 +108,7 @@ const user = {
commit('SET_TOKEN', '') commit('SET_TOKEN', '')
commit('SET_ROLES', []) commit('SET_ROLES', [])
commit('SET_PERMISSIONS', []) commit('SET_PERMISSIONS', [])
commit('SET_USER_INFO', '')
removeToken() removeToken()
storage.clean() storage.clean()
resolve() resolve()
......
...@@ -2,6 +2,7 @@ const constant = { ...@@ -2,6 +2,7 @@ const constant = {
avatar: 'vuex_avatar', avatar: 'vuex_avatar',
name: 'vuex_name', name: 'vuex_name',
roles: 'vuex_roles', roles: 'vuex_roles',
userInfo: 'vuex_user_info',
permissions: 'vuex_permissions', permissions: 'vuex_permissions',
isShowConfirm: true isShowConfirm: true
} }
......
...@@ -32,7 +32,8 @@ const request = config => { ...@@ -32,7 +32,8 @@ const request = config => {
url: config.baseUrl || baseUrl + config.url, url: config.baseUrl || baseUrl + config.url,
data: config.data, data: config.data,
header: config.header, header: config.header,
dataType: 'json' dataType: 'json',
responseType: config.responseType || 'text'
}).then(response => { }).then(response => {
let [error, res] = response let [error, res] = response
if (error) { if (error) {
......
...@@ -4,7 +4,7 @@ import constant from './constant' ...@@ -4,7 +4,7 @@ import constant from './constant'
let storageKey = 'storage_data' let storageKey = 'storage_data'
// 存储节点变量名 // 存储节点变量名
let storageNodeKeys = [constant.avatar, constant.name, constant.roles, constant.permissions] let storageNodeKeys = [constant.avatar, constant.name, constant.roles, constant.permissions, constant.userInfo]
// 存储的数据 // 存储的数据
let storageData = uni.getStorageSync(storageKey) || {} let storageData = uni.getStorageSync(storageKey) || {}
......
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