info.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <view class="check">
  3. <uni-forms ref="form" :model="datainfo" :rules="rules">
  4. <view class="cbox">
  5. <view class="chmain">
  6. <uni-forms-item label="头像" name="phonenumber">
  7. <view class="flexjd mt10">
  8. <image :src="avatar?baseUrl+avatar:aphoto" class="inimg" @click="handleToAvatar"></image>
  9. </view>
  10. </uni-forms-item>
  11. <uni-forms-item label="用户名称" name="nickName">
  12. <view class="flexc">
  13. <uni-easyinput v-model="datainfo.nickName" :disabled="isdisabled" :inputBorder='false' placeholder="用户名称" />
  14. </view>
  15. </uni-forms-item>
  16. <uni-forms-item label="性别" name="sex">
  17. <picker range-key='dictLabel' :disabled="isdisabled" :value="xbidx" :range="xbList" @change='bindDateChange'>
  18. <view class="flexc" style="height: 70rpx;">
  19. <view class="flex1 txr f13 co27" v-if="datainfo.sex&&!xb">{{statusFormats(datainfo.sex,xbList,'xb')}}</view>
  20. <view class="flex1 txr f13" v-else :class="xb?'co27':'coa'">{{xb||"性别"}}</view>
  21. </view>
  22. </picker>
  23. </uni-forms-item>
  24. <uni-forms-item label="手机号码" name="phonenumber">
  25. <view class="flexc">
  26. <uni-easyinput v-model="datainfo.phonenumber" :disabled="isdisabled" :inputBorder='false' placeholder="手机号码" />
  27. </view>
  28. </uni-forms-item>
  29. <uni-forms-item label="邮箱" name="email">
  30. <view class="flexc">
  31. <uni-easyinput v-model="datainfo.email" :disabled="isdisabled" :inputBorder='false' placeholder="邮箱" />
  32. </view>
  33. </uni-forms-item>
  34. <!-- <uni-forms-item label="岗位" name="postGroup">
  35. <view class="flexc">
  36. <uni-easyinput v-model="postGroup" :disabled="isdisabled" :inputBorder='false' placeholder="岗位" />
  37. </view>
  38. </uni-forms-item>
  39. <uni-forms-item label="角色" name="roleGroup" style="border:none">
  40. <view class="flexc">
  41. <uni-easyinput v-model="roleGroup" :disabled="isdisabled" :inputBorder='false' placeholder="角色" />
  42. </view>
  43. </uni-forms-item> -->
  44. </view>
  45. </view>
  46. </uni-forms>
  47. <view class="rhbtn mt30" @click="getEditFn" v-if="isdisabled">修改</view>
  48. <view class="rhbtn mt30" @click="getSubmit" v-else>提交</view>
  49. <loading></loading>
  50. </view>
  51. </template>
  52. <script>
  53. import config from '@/config'
  54. import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
  55. import {uploadIdentify,selectValueKey} from '@/utils/common.js'
  56. import {getDictionaryFn,getUserProfile,updateUserProfile} from "@/api/system/user.js"
  57. export default {
  58. components: {},
  59. data() {
  60. return {
  61. aphoto:require("@/static/images/mine/head.png"),
  62. baseUrl: config.baseUrl,
  63. checkflag:true,
  64. isdisabled:true,
  65. roleGroup: "",
  66. postGroup: "",
  67. datainfo: {},
  68. xbList:[],
  69. xbidx:'',
  70. xb:"",
  71. rules: {
  72. nickName: {
  73. rules: [{
  74. required: true,
  75. errorMessage: '用户昵称不能为空'
  76. }]
  77. },
  78. phonenumber: {
  79. rules: [{
  80. required: true,
  81. errorMessage: '手机号码不能为空'
  82. }, {
  83. pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
  84. errorMessage: '请输入正确的手机号码'
  85. }]
  86. },
  87. // email: {
  88. // rules: [{
  89. // required: true,
  90. // errorMessage: '邮箱地址不能为空'
  91. // }, {
  92. // format: 'email',
  93. // errorMessage: '请输入正确的邮箱地址'
  94. // }]
  95. // }
  96. }
  97. }
  98. },
  99. onLoad: function() {
  100. this.init()
  101. this.getUser()
  102. },
  103. computed: {
  104. avatar() {
  105. return this.$store.state.user.avatar
  106. },
  107. },
  108. methods: {
  109. checkPermi,
  110. checkRole,
  111. getEditFn(){
  112. this.isdisabled=false;
  113. },
  114. handleToAvatar() {
  115. if(this.isdisabled){
  116. return
  117. }
  118. this.$tab.navigateTo('/pages/mine/avatar/index')
  119. },
  120. statusFormats(data, list,type) {
  121. var aite=selectValueKey(list, data);
  122. if(type=='xbidx'){
  123. this.xbidxidx=aite.key
  124. }
  125. return aite.actions;
  126. },
  127. getUser() {
  128. getUserProfile().then(response => {
  129. this.datainfo = response.data
  130. this.roleGroup = response.roleGroup
  131. this.postGroup = response.postGroup
  132. })
  133. },
  134. init(){
  135. // 性别
  136. getDictionaryFn('sys_user_sex').then(res=>{
  137. if(res.code==200){
  138. if(res.data){
  139. this.xbList = res.data.map(v => {
  140. return {
  141. dictLabel: v.dictLabel,
  142. dictValue: v.dictValue
  143. }
  144. })
  145. }
  146. }
  147. })
  148. },
  149. bindDateChange(e){
  150. var val=e.detail.value;
  151. this.datainfo.sex=this.xbList[val].dictValue;
  152. this.xb=this.xbList[val].dictLabel;
  153. },
  154. getSubmit(ref) {
  155. this.$refs.form.validate().then(res => {
  156. updateUserProfile(this.datainfo).then(response => {
  157. this.$modal.msgSuccess("修改成功")
  158. })
  159. })
  160. }
  161. }
  162. }
  163. </script>
  164. <style>
  165. page{background: #F3F3F0;}
  166. </style>
  167. <style lang="scss" scoped>
  168. .check /deep/ .uni-forms-item{min-height: 106rpx;box-sizing: border-box;display: flex;align-items: center;margin-bottom: 0;border-bottom: 2rpx solid #E6E6E6;padding:10rpx 0;}
  169. // .check .cbox /deep/ .uni-forms-item:last-child{border: none;}
  170. .check /deep/ .uni-forms-item__label{font-weight: bold;font-size: 26rpx;color: #222327;flex: 0 0 auto;width: auto !important;}
  171. .check /deep/ .uni-easyinput{flex: 1;text-align: right;font-size: 26rpx;color: #222327;}
  172. .check /deep/ .uni-easyinput__content-textarea{min-height: 40rpx;font-size: 26rpx;}
  173. .check /deep/ .uni-easyinput__placeholder-class{font-size: 26rpx;color: #AAAAAA;}
  174. .check /deep/ .uni-input-input{font-size: 26rpx;}
  175. .check /deep/ .uni-textarea-textarea{font-size: 26rpx;}
  176. .check /deep/ .is-disabled{color: #222327;background-color: #ffffff !important;}
  177. .check /deep/ .uni-data-checklist .checklist-group .checklist-box{margin:10rpx 8rpx 10rpx 16rpx;}
  178. .check /deep/ .uni-forms-item__label text{width: 110rpx;text-align-last: justify;}
  179. .check /deep/ .uni-data-checklist{flex: 0 0 auto;}
  180. .check{min-height: 100vh;padding: 20rpx 18rpx 24rpx;box-sizing: border-box;}
  181. .cbox{background: #FFFFFF;border-radius: 20rpx;flex: 1;margin-bottom: 24rpx;
  182. .chmain{
  183. padding: 0 32rpx;
  184. .upbox{height: 224rpx;background: #EFF4FF;border-radius: 20rpx;display: flex;align-items: center;justify-content: center;flex-direction: column;margin-bottom: 8rpx;overflow: auto;
  185. .img{width: 100%;height: 100%;}
  186. .addimg{width: 70rpx;height: 70rpx;margin-bottom: 16rpx;}
  187. view{font-weight: bold;font-size: 26rpx;color: #4C6686;}
  188. }
  189. .rimg{width: 16rpx;height: 28rpx;flex: 0 0 auto;margin-left: 20rpx;
  190. image{width: 100%;height: 100%;}
  191. }
  192. .checkimg{width: 80rpx;height: 40rpx;margin-right: 8rpx;}
  193. .aphoto{padding: 0 24rpx;border-left: 2rpx solid #e6e6e6;margin-left: 26rpx;
  194. image{width: 40rpx;height: 38rpx;}
  195. }
  196. }
  197. }
  198. .addimgs{display: flex;align-items: center;flex-wrap: wrap;justify-content: flex-end;
  199. .assimg{width: 128rpx;height: 128rpx;position: relative;overflow: hidden;margin: 0 0 20rpx 24rpx;
  200. .img{width: 100%;height: 100%;}
  201. .delimg{width: 24rpx;height: 24rpx;position: absolute;right: 0;top: 0;}
  202. }
  203. }
  204. .addbox{width: 102rpx;height: 102rpx;background: #F0F0F0;border-radius: 20rpx;display: flex;flex-direction: column;align-items: center;justify-content: center;margin-left: 24rpx;margin-bottom: 20rpx;flex: 0 0 auto;
  205. image{width: 48rpx;height: 42rpx;}
  206. // view{font-weight: 500;font-size: 24rpx;color: #666666;}
  207. }
  208. .inimg{width: 102rpx;height: 102rpx;border-radius: 50%;}
  209. .tips{font-weight: bold;color: #272727;font-size: 26rpx;margin-left: 8rpx;}
  210. </style>