平安校园
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.vue 6.7 KiB

3 months ago
3 months ago
3 months ago
3 months ago
2 months ago
3 months ago
3 months ago
3 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <view style="padding: 0 30rpx;">
  3. <view class="header">
  4. <view style="padding-top: 44rpx;" class="headerContent">
  5. <u-avatar :src="userInfo.avatar" size="180rpx"></u-avatar>
  6. <view class="right">
  7. <view class="name">
  8. {{userInfo.name}}
  9. </view>
  10. <view class="des">
  11. <image src="/static/image/school.png" mode=""></image>
  12. {{userInfo.orgNames}} | {{userInfo.positionName}}
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="whiteCard">
  18. <view class="title">
  19. 个人信息
  20. </view>
  21. <u-cell title="账号" :titleStyle="{fontSize:'28rpx',color:'#333'}" :border="false">
  22. <view slot="value" class="valueBox disabled">
  23. {{userInfo.account}}
  24. </view>
  25. </u-cell>
  26. <u-cell title="姓名" :titleStyle="{fontSize:'28rpx',color:'#333'}" :border="false" isLink
  27. @click="cellClick('修改姓名')">
  28. <view slot="value" class="valueBox">
  29. {{userInfo.name}}
  30. </view>
  31. </u-cell>
  32. <u-cell title="手机" :titleStyle="{fontSize:'28rpx',color:'#333'}" :border="false" isLink
  33. @click="cellClick('修改手机号')">
  34. <view slot="value" class="valueBox">
  35. {{userInfo.phone}}
  36. </view>
  37. </u-cell>
  38. <u-cell title="昵称" :titleStyle="{fontSize:'28rpx',color:'#333'}" :border="false" isLink
  39. @click="cellClick('设置昵称')">
  40. <view slot="value" class="valueBox">
  41. {{userInfo.nickname||'未设置'}}
  42. </view>
  43. </u-cell>
  44. <picker mode="date" :value="userInfo.birthday" @change="dateChange">
  45. <u-cell title="出生日期" :titleStyle="{fontSize:'28rpx',color:'#333'}" :border="false" isLink>
  46. <view slot="value" class="valueBox">
  47. {{userInfo.birthday}}
  48. </view>
  49. </u-cell>
  50. </picker>
  51. </view>
  52. <view class="btn" @click="loginOut">
  53. 退出登录
  54. </view>
  55. <u-popup :show="show" mode="center" :round="10">
  56. <view class="popupInfo">
  57. <view class="title">
  58. {{this.action}}
  59. </view>
  60. <u--input v-model="inputValue" :customStyle="{height: '84rpx',boxSizing:'border-box'}" placeholder="请输入" border="surround" clearable></u--input>
  61. <view class="bottom">
  62. <view class="cancel" @click="cancel">
  63. 取消
  64. </view>
  65. <view class="confirm" @click="confirm">
  66. 确定
  67. </view>
  68. </view>
  69. </view>
  70. </u-popup>
  71. </view>
  72. </template>
  73. <script>
  74. import {updateUserInfo} from '@/api/user.js'
  75. export default {
  76. data() {
  77. return {
  78. show: false,
  79. action: '',
  80. inputValue: '',
  81. }
  82. },
  83. onShow() {
  84. this.$store.dispatch('getUserInfo')
  85. },
  86. methods: {
  87. cellClick(action) {
  88. this.action = action
  89. this.inputValue = ''
  90. this.show = true
  91. },
  92. confirm() {
  93. switch (this.action) {
  94. case '修改姓名':
  95. if (!this.inputValue) {
  96. this.TOAST('请输入姓名')
  97. return
  98. }
  99. this.LOADING()
  100. updateUserInfo({...this.userInfo,name:this.inputValue}).then(res=>{
  101. this.HIDE_LOADING()
  102. if(res.code != 200)return
  103. this.$store.dispatch('getUserInfo')
  104. this.cancel()
  105. })
  106. break
  107. case '修改手机号':
  108. if (!this.inputValue) {
  109. this.TOAST('请输入手机号')
  110. return
  111. }
  112. if (!
  113. /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[1589]))\d{8}$/
  114. .test(this.inputValue)) {
  115. this.TOAST('请输入正确的手机号')
  116. return
  117. }
  118. this.LOADING()
  119. updateUserInfo({...this.userInfo,phone:this.inputValue}).then(res=>{
  120. this.HIDE_LOADING()
  121. if(res.code != 200)return
  122. this.$store.dispatch('getUserInfo')
  123. this.cancel()
  124. })
  125. break
  126. case '设置昵称':
  127. // if (!this.inputValue) {
  128. // this.TOAST('请输入昵称')
  129. // return
  130. // }
  131. this.LOADING()
  132. updateUserInfo({...this.userInfo,nickname:this.inputValue}).then(res=>{
  133. this.HIDE_LOADING()
  134. if(res.code != 200)return
  135. this.$store.dispatch('getUserInfo')
  136. this.cancel()
  137. })
  138. break
  139. }
  140. },
  141. cancel() {
  142. this.show = false
  143. },
  144. dateChange(e) {
  145. this.LOADING()
  146. updateUserInfo({...this.userInfo,birthday:e.detail.value}).then(res=>{
  147. this.HIDE_LOADING()
  148. if(res.code != 200)return
  149. this.$store.dispatch('getUserInfo')
  150. this.cancel()
  151. })
  152. },
  153. loginOut() {
  154. this.CONFIRM('您是否确认退出登录?').then(res=>{
  155. if(!res)return
  156. this.CLEAR_STORAGE()
  157. this.JUMP_TO('/pages/login')
  158. })
  159. }
  160. }
  161. }
  162. </script>
  163. <style scoped lang="scss">
  164. uni-page-body {
  165. /* #ifdef H5*/
  166. background-image: url('/static/image/mybgh5.png');
  167. /* #endif */
  168. /* #ifndef H5*/
  169. background-image: url('/static/image/mybg.png');
  170. /* #endif */
  171. background-position: top;
  172. background-size: 100% auto;
  173. background-repeat: no-repeat;
  174. }
  175. .header {
  176. /* #ifdef H5*/
  177. padding-top: 40rpx;
  178. /* #endif */
  179. /* #ifndef H5*/
  180. padding-top: 88rpx;
  181. /* #endif */
  182. color: #333;
  183. .headerContent {
  184. display: flex;
  185. }
  186. .right {
  187. flex: 1;
  188. padding-top: 24rpx;
  189. padding-left: 36rpx;
  190. .name {
  191. font-size: 46rpx;
  192. font-weight: 700;
  193. }
  194. .des {
  195. display: flex;
  196. font-size: 28rpx;
  197. margin-top: 30rpx;
  198. uni-image {
  199. width: 34rpx;
  200. height: 34rpx;
  201. margin-right: 12rpx;
  202. }
  203. }
  204. }
  205. }
  206. .whiteCard {
  207. background-color: #fff;
  208. border-radius: 20rpx;
  209. margin-top: 50rpx;
  210. // padding: 0 30rpx;
  211. .title {
  212. font-family: 'Alimama ShuHeiTi';
  213. font-weight: 700;
  214. color: #2388FF;
  215. font-size: 42rpx;
  216. line-height: 42rpx;
  217. padding: 60rpx 30rpx 30rpx;
  218. }
  219. }
  220. .u-cell {
  221. height: 90rpx;
  222. position: relative;
  223. &:not(&:last-child)::after {
  224. content: '';
  225. display: block;
  226. position: absolute;
  227. height: 1rpx;
  228. background-color: rgba(0, 0, 0, 0.1);
  229. width: calc(100% - 60rpx);
  230. left: 30rpx;
  231. bottom: 0rpx;
  232. }
  233. .valueBox {
  234. color: #333;
  235. font-size: 30rpx;
  236. font-weight: 700;
  237. &.disabled {
  238. font-weight: unset;
  239. }
  240. }
  241. }
  242. .btn {
  243. height: 98rpx;
  244. background-color: #fff;
  245. line-height: 98rpx;
  246. border-radius: 20rpx;
  247. text-align: center;
  248. color: #333;
  249. margin-top: 30rpx;
  250. font-size: 32rpx;
  251. }
  252. .popupInfo {
  253. padding: 30rpx 30rpx 0rpx;
  254. width: 540rpx;
  255. box-sizing: border-box;
  256. .title {
  257. font-size: 34rpx;
  258. font-weight: 700;
  259. text-align: center;
  260. margin-bottom: 30rpx;
  261. margin-top: 16rpx;
  262. }
  263. .bottom {
  264. margin-top: 30rpx;
  265. display: flex;
  266. line-height: 88rpx;
  267. border-top: 1rpx solid rgba(0, 0, 0, 0.1);
  268. margin-left: -30rpx;
  269. margin-right: -30rpx;
  270. position: relative;
  271. &::after {
  272. content: '';
  273. background-color: rgba(0, 0, 0, 0.1);
  274. display: block;
  275. position: absolute;
  276. width: 1rpx;
  277. height: 100%;
  278. left: 50%;
  279. top: 0;
  280. }
  281. &>* {
  282. width: 50%;
  283. text-align: center;
  284. color: #165DFF;
  285. font-weight: 32rpx;
  286. }
  287. }
  288. }
  289. </style>