userInfo.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <template>
  2. <view class="page">
  3. <uni-Cell :celllist="celllist" :leftStyle="{fontSize:'30rpx'}">
  4. <template #customContent="{ item }">
  5. <image v-if="item.title=='头像'" class="avatar"
  6. :src="userInfo.sysUser.headSculpture? userInfo.sysUser.headSculpture :'/static/image/avatar.png'"
  7. mode=""></image>
  8. <view class="" v-if="item.title=='实名认证'">
  9. <view class="authtag">
  10. {{userInfo.sysUser.authStatus==0?'未认证':userInfo.sysUser.authStatus==1?'已认证':'认证驳回'}}
  11. </view>
  12. </view>
  13. </template>
  14. </uni-Cell>
  15. <uni-Cell :celllist="celllist1" class="mt-2" :leftStyle="{fontSize:'30rpx'}">
  16. <template #customContent="{ item }">
  17. <view v-if="item.title=='身份'" class="dis a-c">
  18. <view class="authtag" v-for="item in identityType() " :key="item">
  19. {{item}}
  20. </view>
  21. </view>
  22. </template>
  23. </uni-Cell>
  24. <uni-Popup :show="userupShow" @close='userupShow=false' headerTitle="修改姓名" mode="center" width="80%">
  25. <template #content>
  26. <view class="p-4">
  27. <u--input class="mb-4" placeholder="请输入姓名" v-model="userName"></u--input>
  28. <view class="savebtn dis a-c j-c" @click="upName">
  29. 确定
  30. </view>
  31. </view>
  32. </template>
  33. </uni-Popup>
  34. <u-action-sheet :actions="list" title="性别" :show="sexshow" round="20rpx" @close="sexshow=false"
  35. @select="sexselect" :closeOnClickOverlay="true"></u-action-sheet>
  36. <!-- 租户机构选择 -->
  37. <uni-Popup :show="deptSelectShow" @close='deptSelectShow=false' headerTitle="选择出单机构" overflow="auto"
  38. maxHeight="580rpx">
  39. <template #content>
  40. <view class="overflow">
  41. <view class="deptselect dis f-c ">
  42. <u-radio-group v-model="deptradioValue" placement="column" iconPlacement="right"
  43. @change="deptchange">
  44. <view class="item dis a-c " v-for="(item, index) in tenantOrglist" :key="index">
  45. <u-radio activeColor="#FDE935" iconColor='#333' :name="item.systemCode"
  46. style="width: 100%;">
  47. <view class="textregion dis f-c ">
  48. <text>{{item.sysName}}</text>
  49. <text>{{item.deptName}}</text>
  50. </view>
  51. <image :src="item.iconAddress" mode=""></image>
  52. </u-radio>
  53. </view>
  54. </u-radio-group>
  55. </view>
  56. </view>
  57. </template>
  58. </uni-Popup>
  59. </view>
  60. </template>
  61. <script>
  62. import {
  63. mapState,
  64. mapMutations
  65. } from "vuex"
  66. import store from '@/store';
  67. export default {
  68. data() {
  69. return {
  70. deptradioValue: "", //选中租户code
  71. deptradioName: "", //选中租户名称
  72. tenantOrglist: [], //租户机构列表
  73. userName: "",
  74. namevalue: '',
  75. userupShow: false, //姓名弹窗
  76. sexshow: false, //性别弹窗
  77. deptSelectShow: false, //选择企业
  78. list: [{
  79. name: '男',
  80. value: 1,
  81. },
  82. {
  83. name: '女',
  84. value: 2,
  85. },
  86. ],
  87. }
  88. },
  89. onShow() {
  90. this.getuser();
  91. },
  92. onLoad() {
  93. this.userName = this.userInfo.sysUser.name;
  94. this.deptradioValue = store.state.system_code;
  95. this.getOrganization(); //获取机构列表,人员信息回显
  96. this.getuser();
  97. },
  98. computed: {
  99. ...mapState(['userInfo']),
  100. celllist() {
  101. return [{
  102. title: "头像",
  103. useSlot: true, //是否插槽,
  104. handler: () => this.updateAvatar()
  105. },
  106. {
  107. title: "姓名",
  108. value: this.userInfo.sysUser.name || "未知",
  109. handler: () => this.userupShow = true,
  110. }, {
  111. title: "手机号",
  112. useSlot: true,
  113. url: "/pages/my/replacePhone",
  114. clickType: 'navigate',
  115. value: this.userInfo.sysUser.mobile || "未知",
  116. },
  117. {
  118. title: "性别",
  119. value: this.userInfo.sysUser.sex != null ?
  120. (this.userInfo.sysUser.sex == 1 ? '男' : '女') : '未知',
  121. handler: () => this.sexshow = true
  122. },
  123. {
  124. title: "实名认证",
  125. useSlot: true,
  126. clickType: 'auth',
  127. }
  128. ]
  129. },
  130. celllist1() {
  131. return [{
  132. title: "推荐人",
  133. url: "/pages/set/set",
  134. rightIcon: false,
  135. value: this.userInfo.sysUser.referrerName + '-' + this.userInfo.sysUser.referrerMobile,
  136. },
  137. {
  138. title: "所在企业",
  139. value: store.state.system_Name,
  140. handler: () => this.deptSelectShow = true
  141. },
  142. {
  143. title: "所在机构",
  144. url: "/pages/quote/quoteInfo",
  145. rightIcon: false,
  146. value: this.userInfo.sysUser.deptName || '无',
  147. }, {
  148. title: "身份",
  149. useSlot: true,
  150. rightIcon: false,
  151. }
  152. ]
  153. }
  154. },
  155. methods: {
  156. identityType() {
  157. const Map = {
  158. 1: '前线人员',
  159. 2: '后线人员',
  160. 3: '合伙人',
  161. 4: '工作室管理员',
  162. 5: '团队',
  163. 6: '个代',
  164. 7: '渠道',
  165. 8: '电销',
  166. }
  167. return this.userInfo.sysUser.typeNames.map(id => Map[id]);
  168. },
  169. //获取机构列表
  170. async getOrganization() {
  171. let res = await this.$http.post('/userInfo/getTenantList'); //获取机构列表
  172. if (res.code == '200') {
  173. this.tenantOrglist = res.data;
  174. }
  175. },
  176. //
  177. async deptchange(name) {
  178. let info = this.tenantOrglist.find(val => val.systemCode == name);
  179. this.deptradioValue = info.systemCode;
  180. await store.commit('setUserModules', {
  181. title: 'system_code',
  182. data: info.systemCode,
  183. })
  184. await store.commit('setUserModules', {
  185. title: 'system_Name',
  186. data: info.sysName,
  187. })
  188. this.deptSelectShow = false;
  189. },
  190. //切换性别
  191. async sexselect(e) {
  192. // 接口
  193. let res = await this.$http.post('/appUser/userInfoEdit', {
  194. id: this.userInfo.sysUser.id,
  195. sex: e.value,
  196. }); //获取机构列表
  197. if (res.code == '200') {
  198. uni.showToast({
  199. title: res.msg,
  200. icon: "none",
  201. })
  202. this.sexshow = false; //关闭弹窗
  203. this.getuser(); //更新用户信息
  204. };
  205. },
  206. //修改头像
  207. async updateAvatar() {
  208. let [chooseImageErr, chooseImageRes] = await uni.chooseImage({
  209. count: 1,
  210. sizeType: ['compressed']
  211. });
  212. if (chooseImageRes) {
  213. this.chooseAvatar(chooseImageRes.tempFilePaths[0]);
  214. } else {}
  215. },
  216. //裁剪组件
  217. chooseAvatar(src) {
  218. uni.navigateTo({
  219. url: '/pages/my/avatarCropper?src=' + src,
  220. })
  221. },
  222. //修改姓名
  223. async upName() {
  224. let res = await this.$http.post('/appUser/userInfoEdit', {
  225. id: this.userInfo.sysUser.id,
  226. name: this.userName,
  227. }); //获取机构列表
  228. if (res.code == '200') {
  229. uni.showToast({
  230. title: res.msg,
  231. icon: "none",
  232. })
  233. this.userupShow = false; //关闭弹窗
  234. this.getuser(); //更新用户信息
  235. };
  236. },
  237. async getuser() {
  238. let userInfoRes = await this.$http.get('/appUser/userInfoGet'); //用户信息
  239. store.commit('setUserModules', { //用户信息
  240. title: 'userInfo',
  241. data: {
  242. sysUser: {
  243. ...userInfoRes.data
  244. }
  245. }
  246. })
  247. }
  248. }
  249. }
  250. </script>
  251. <style lang="scss" scoped>
  252. .page {
  253. background-color: #F8F8F8;
  254. height: 100vh;
  255. }
  256. .customContent {
  257. image {
  258. width: 46rpx;
  259. height: 46rpx;
  260. }
  261. }
  262. //身份标签
  263. .authtag {
  264. padding: 2rpx 8rpx;
  265. box-sizing: border-box;
  266. background: linear-gradient(270deg, #FDE935 0%, #F1FF91 100%);
  267. border-radius: 4rpx 4rpx 4rpx 4rpx;
  268. font-size: 22rpx;
  269. color: #333;
  270. margin-left: 16rpx;
  271. }
  272. //头像
  273. .avatar {
  274. width: 50rpx;
  275. height: 50rpx;
  276. border-radius: 50%;
  277. }
  278. .savebtn {
  279. width: 100%;
  280. height: 80rpx;
  281. background: #FDE935;
  282. border-radius: 50rpx 50rpx 50rpx 50rpx;
  283. font-size: 30rpx;
  284. color: #1F1F1F;
  285. font-weight: bold;
  286. }
  287. //出单机构选择
  288. .overflow {
  289. padding: 30rpx;
  290. box-sizing: border-box;
  291. .deptselect {
  292. .item {
  293. border-radius: 10rpx;
  294. border: 1px solid #EEEEEE;
  295. padding: 24rpx 25rpx;
  296. margin-bottom: 30rpx;
  297. width: 100%;
  298. box-sizing: border-box;
  299. image {
  300. width: 72rpx;
  301. height: 72rpx;
  302. margin-right: 20rpx;
  303. }
  304. .textregion {
  305. margin-right: auto;
  306. text:first-child {
  307. font-size: 32rpx;
  308. color: #333;
  309. font-weight: bold;
  310. }
  311. text:last-child {
  312. font-size: 30rpx;
  313. color: #666;
  314. }
  315. }
  316. }
  317. }
  318. }
  319. </style>