Browse Source

联调接口

master
邓宏 2 years ago
parent
commit
5006b1e5ef
  1. 6
      common/request.js
  2. 28
      pages/home/my.vue
  3. 58
      pages/home/personalInfo.vue
  4. 80
      pages/home/rePassword.vue
  5. 2
      pages/massif/detail.vue
  6. 2
      pages/massif/mana/plantPlan.vue
  7. 2
      pages/massif/mana/recovery.vue
  8. 9
      router/home.js
  9. 17
      store/index.js
  10. 2
      uni.scss
  11. 2
      uni_modules/d-form/components/d-form/d-form.vue

6
common/request.js

@ -42,7 +42,7 @@ const request=async function(url,param={}){
if(param.file||param.filePath){
var res=await uni.uploadFile({
url:`${param.host||host()}${('/'+url).replace(/\/{2}/,'/').replace(/\?.+/,"")}?${pathData}`,
url:`${param.host||host(undefined,param.suffix)}${('/'+url).replace(/\/{2}/,'/').replace(/\?.+/,"")}?${pathData}`,
file:param.file||{},
filePath:param.filePath||"",
name:"file",
@ -69,9 +69,7 @@ const request=async function(url,param={}){
if(res){
if(res.data.code==401){
uni.reLaunch({
url:"/pages/home/login",
})
store.commit('outLogin')
return{statu:false, msg:"登录超时!"}
}
else if(res.data.code==200)return { statu:true, data:res.data.result }

28
pages/home/my.vue

@ -16,10 +16,7 @@
margin:0;
display: flex;
flex-direction: column;
.headImg{
width:140rpx;
height:140rpx;
border-radius: 50%;
.u-transition{
margin:-120rpx auto 10rpx auto;
}
.name{
@ -40,7 +37,7 @@
text{
&:first-child{
color:#10C176;
font-size:30rpx;
font-size:36rpx;
margin-right:32rpx;
}
&:nth-child(3){
@ -55,33 +52,36 @@
<view class="container">
<image class="head" src="@/static/my_head.png" mode="aspectFit"/>
<view class="card">
<image class="headImg" src="@/static/userHeader.png" mode="aspectFill"/>
<u-image radius="50%" width="140rpx" height="140rpx" :src="`${host('imgUrl')}/${$store.getters['userInfo'].avatar}`" mode="aspectFill" @click="reHeadImg">
<image slot="error" style="width:140rpx;height:140rpx;border-radius:50%;" src="@/static/userHeader.png" mode="aspectFill"/>
</u-image>
<text class="name">{{$store.getters.userInfo.realname}}</text>
<text class="phone">{{$store.getters.userInfo.phone}}</text>
<view class="item" @click="$u.route({url:'pages/home/personalInfo'})">
<text class="plant-gerenzhongxinwode"/> <text>个人信息</text> <text class="plant-youbian"/>
</view>
<view class="item" @click="$u.route({url:'pages/home/personalInfo'})">
<text class="plant-gerenzhongxinwode"/> <text>修改密码</text> <text class="plant-youbian"/>
</view>
<view class="item" @click="$u.route({url:'pages/home/personalInfo'})">
<text class="plant-gerenzhongxinwode"/> <text>采购记录</text> <text class="plant-youbian"/>
<view class="item" @click="$u.route({url:'pages/home/rePassword'})">
<text class="plant-icon2"/> <text>修改密码</text> <text class="plant-youbian"/>
</view>
<view class="item" @click="$u.route({url:'pages/home/personalInfo'})">
<text class="plant-gerenzhongxinwode"/> <text>领用记录</text> <text class="plant-youbian"/>
<view class="item">
<text class="plant-liulanjilu-tianchong"/> <text>采购记录</text> <text class="plant-youbian"/>
</view>
<view class="item">
<text class="plant-kufangguanli-lingyongguihuan"/> <text>领用记录</text> <text class="plant-youbian"/>
</view>
<view class="item" @click="$store.commit('outLogin')">
<text class="plant-tuichu"/> <text>退出</text> <text class="plant-youbian"/>
</view>
</view>
</view>
</template>
<script>
import {host} from '@/common/request'
export default{
data(){
return{
host,
}
},
methods:{

58
pages/home/personalInfo.vue

@ -7,10 +7,6 @@
padding:20rpx 0;
margin:0 30rpx;
border-bottom:2rpx solid rgba(216, 216, 216, 0.2);
image{
width:80rpx;
height:80rpx;
}
text{
&:first-child{
color:#999;
@ -27,28 +23,70 @@
<template>
<view class="container">
<view class="item">
<text>头像</text> <image src="@/static/userHeader.png" mode="aspectFill"/> <text class="plant-youbian"/>
<text>头像</text>
<u-image radius="5rpx" width="80rpx" height="80rpx" :src="`${host}/${$store.getters['userInfo'].avatar}`" mode="aspectFill" @click="reHeadImg">
<image slot="error" style="width:80rpx;height:80rpx" src="@/static/userHeader.png" mode="aspectFill"/>
</u-image>
<text class="plant-youbian"/>
</view>
<view class="item">
<text>所属企业</text> <text>云南云创数据公司</text> <text class="plant-youbian"/>
<text>所属企业</text> <text>{{$store.getters['userInfo'].companyName}}</text> <text class="plant-youbian"/>
</view>
<view class="item">
<text>系统账号</text> <text>1231552684376</text> <text class="plant-youbian"/>
<text>系统账号</text> <text>{{$store.getters['userInfo'].username}}</text> <text class="plant-youbian"/>
</view>
<view class="item">
<text>身份</text> <text>1231552684376</text> <text class="plant-youbian"/>
<text>身份</text> <text>{{identity[$store.getters['userInfo'].roleCode]}}</text> <text class="plant-youbian"/>
</view>
</view>
</template>
<script>
import request,{host} from '@/common/request'
export default{
data(){
return{
host:host('imgUrl'),
identity:{
admin:"管理员",
baseAdmin:"基地管理员",
companyAdmin:"企业管理员",
majingfu:"第三方登录",
third_role:"第三方登录角色",
}
}
},
methods:{
async reHeadImg(){
uni.chooseImage({
count:1,
success:async e=>{
if(/ok/.test(e.errMsg)){
var res=await request("/sys/common/upload",{
file:e.tempFiles[0],
body:{ biz: "temp" }
})
if(res.statu){
var userInfo=await request("/sys/user/edit",{
method:"post",
suffix:"/jeecgboot",
body:{
avatar:res.data,
id: this.$store.getters['userInfo'].id
}
})
if(userInfo.statu){
uni.showToast({title:"修改成功!",icon:"success"})
this.$store.commit("setHeadImg",res.data)
}else{
uni.showToast({title:"修改失败!",icon:"error"})
}
}else{
uni.showToast({title:"上传头像失败!",icon:"error"})
}
}
}
})
},
}
}
</script>

80
pages/home/rePassword.vue

@ -0,0 +1,80 @@
<style lang="scss">
.container{
padding:30rpx 0;
background:#f6f6f6;
min-height:100%;
.card{
padding-bottom:100rpx;
input{
background:#F7F7F7;
height:80rpx;
border-radius: 24rpx;
font-size:25rpx;
padding:0 28rpx;
&+input{
margin-top:28rpx;
}
}
}
}
</style>
<template>
<view class="container">
<d-navbar text="修改密码" isBack style="--bg:#10C176;--c:#fff;">
<button slot="right" class="cu-btn round" @click="submit">提交</button>
</d-navbar>
<view class="card">
<input placeholder="请输入新密码(6-20位字母和数字的组合)" type="password" v-model="formData.password"/>
<input placeholder="再次输入新密码" type="password" v-model="formData.confirmPassword"/>
</view>
</view>
</template>
<script>
import request from '@/common/request'
export default{
data(){
return{
formData:{
confirmPassword: "",
password: "",
username: this.$store.getters['userInfo'].username,
}
}
},
methods:{
check(){
if(!this.formData.password){
uni.showToast({title:"请输入密码!",icon:"none"})
return false
}else if(!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/.test(this.formData.password)){
uni.showToast({title:"密码格式为6-20位字母和数字的组合!",icon:"none"})
return false
}else if(!this.formData.confirmPassword){
uni.showToast({title:"输入密码不一致!",icon:"none"})
return false
}
return true
},
async submit(){
if(this.check()){
var res=await request("/sys/user/changePassword",{
method:"put",
suffix:"/jeecgboot",
body: this.formData
})
if(res.statu){
uni.navigateBack()
}else{
uni.showModal({
title:"提示",
content:res.msg||"修改失败!",
showCancel:false,
})
}
}
},
}
}
</script>

2
pages/massif/detail.vue

@ -96,7 +96,7 @@ import request,{host} from '@/common/request'
data(){
return{
detail:{},
imgUrl:host(undefined,"/plant_manage/sys/common/static"),
imgUrl:host("imgUrl"),
}
},
onLoad(options){

2
pages/massif/mana/plantPlan.vue

@ -154,7 +154,7 @@ export default {
},
total:0,
list:[],
host:host(undefined,"/plant_manage/sys/common/static"),
host:host("imgUrl"),
}
},
created(){

2
pages/massif/mana/recovery.vue

@ -114,7 +114,7 @@ export default {
return{
show:false,
dateType:"startTime",
host:host(undefined,"/plant_manage/sys/common/static"),
host:host("imgUrl"),
searchVal:{
pageNo:1,
pageSize:5,

9
router/home.js

@ -46,4 +46,13 @@ module.exports=[
}
}
},
{
path:"pages/home/rePassword",
style:{
navigationBarTitleText:"修改密码",
"app-plus":{
titleNView:false
}
}
},
]

17
store/index.js

@ -13,9 +13,22 @@ export default new Vuex.Store({
},
mutations:{
setUserInfo(state, val){
state.userInfo=val.userInfo
state.userInfo={
...val.userInfo,
companyName:val.departs[0].departName
}
state.token=val.token
}
},
outLogin(state){
state.userInfo={}
state.token=''
uni.reLaunch({
url:"/pages/home/login",
})
},
setHeadImg(state,val){
state.userInfo.avatar=val
},
},
actions:{

2
uni.scss

@ -77,7 +77,7 @@ $uni-font-size-paragraph:15px;
@import '@/common/main.css';
@import 'uview-ui/theme.scss';
@import url('https://at.alicdn.com/t/c/font_3852037_bwfjvlm958.css');
@import url('https://at.alicdn.com/t/c/font_3852037_owoae3ai5lc.css');
[class*=plant-]{
font-family: "plantMana" !important;
font-size: 16px;

2
uni_modules/d-form/components/d-form/d-form.vue

@ -318,7 +318,7 @@ import {dataType} from 'black-knight/lib/config/tools'
if(this.type=='dateRange' && this.dateType=='end' && this.value[0])return new Date(this.value[0]).getTime();
},
imgs(){
if(this.type=='upImg')return this.value.map((v,index)=>({url:`${host(undefined,"/plant_manage/sys/common/static")}/${v}`,status:"success",index,type:'saved'})).concat(this.imgList.map((v,index)=>Object.assign(v,{index,type:'unsaved'})))
if(this.type=='upImg')return this.value.map((v,index)=>({url:`${host('imgUrl')}/${v}`,status:"success",index,type:'saved'})).concat(this.imgList.map((v,index)=>Object.assign(v,{index,type:'unsaved'})))
return []
},
pickerContent(){//

Loading…
Cancel
Save