您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

286 行
7.0 KiB

  1. <template>
  2. <view v-if="currentUser" id="my" class="page">
  3. <!-- 顶部用户名、头像 banner -->
  4. <view @click="goTo('info')" class="mybanner">
  5. <view class="avatarslot">
  6. <image
  7. :src="avatarSrc()"
  8. :style="{ borderRadius: roundAvatar ? '50%' : '3px' }"
  9. mode="aspectFit"
  10. class="avatar"
  11. ></image>
  12. </view>
  13. <view class="info">
  14. <view class="username text-xl text-white">{{ currentUser.realName }}</view>
  15. <view class="usertag">
  16. <l-tag color="green">{{ userTag }}</l-tag>
  17. </view>
  18. </view>
  19. <view class="badge text-white text-lg"><l-icon type="right" round /></view>
  20. </view>
  21. <!-- 用户信息菜单 -->
  22. <l-list border card>
  23. <l-list-item @click="goTo('contact')" arrow>
  24. <l-icon type="phone" color="blue" />
  25. 联系方式
  26. </l-list-item>
  27. <!-- <l-list-item @click="goTo('qrcode')" arrow>
  28. <l-icon type="qrcode" color="blue" />
  29. 我的二维码
  30. </l-list-item> -->
  31. <l-list-item @click="goTo('password')" arrow>
  32. <l-icon type="edit" color="blue" />
  33. 修改密码
  34. </l-list-item>
  35. <l-list-item @click="unbound" arrow>
  36. <image src="@/static/unbound.png" mode="" style="color: #0081ff;width: 14px;height: 14px;margin: 0 10px 0 5px;"></image>
  37. 解绑微信
  38. </l-list-item>
  39. </l-list>
  40. <!-- 关于菜单 -->
  41. <!-- <l-list border card>
  42. <l-list-item @click="goTo('learun')" arrow>
  43. <l-icon type="home" color="blue" />
  44. 关于泉江
  45. </l-list-item>
  46. <l-list-item @click="goTo('framework')" arrow>
  47. <l-icon type="info" color="blue" />
  48. 数字化智慧校园
  49. </l-list-item>
  50. </l-list> -->
  51. <view class="padding" style="padding-top: 0;">
  52. <!-- 小程序账号绑定/解除按钮 -->
  53. <!-- #ifdef MP-ALIPAY || MP-WEIXIN -->
  54. <l-button
  55. v-if="MPBind && !currentUser.miniProgram"
  56. @click="userBind"
  57. size="lg"
  58. line="blue"
  59. class="block margin-top"
  60. block
  61. >
  62. 绑定{{ PLATFORM_TEXT }}账号
  63. </l-button>
  64. <l-button
  65. v-if="MPUnbind && currentUser.miniProgram"
  66. @click="userUnBind"
  67. size="lg"
  68. line="red"
  69. class="block margin-top"
  70. block
  71. >
  72. 解绑{{ PLATFORM_TEXT }}账号
  73. </l-button>
  74. <!-- #endif -->
  75. <l-button @click="logout" size="lg" color="red" class="block margin-top" block>退出登录</l-button>
  76. </view>
  77. <view class="footer">{{ copyRightDisplay }}</view>
  78. <tabBar selectedPath='/pages/my'></tabBar>
  79. </view>
  80. </template>
  81. <script>
  82. export default {
  83. onShow() {
  84. uni.hideTabBar()
  85. },
  86. methods: {
  87. // 点击「注销登录」按钮
  88. async logout() {
  89. if (!(await this.CONFIRM('注销确认', '确定要注销登录吗?', true))) {
  90. return
  91. }
  92. this.CLEAR_GLOBAL()
  93. this.RELAUNCH_TO('/pages/login')
  94. },
  95. // #ifdef MP-ALIPAY || MP-WEIXIN
  96. // 小程序绑定方法,只会编译到小程序
  97. async userBind() {
  98. const type = this.PLATFORM
  99. const confirm = await this.CONFIRM(
  100. '绑定确认',
  101. `确定要将智慧校园账号与当前登录的${this.PLATFORM_TEXT}账号绑定吗?\n(绑定后可以使用一键登录功能)`,
  102. true
  103. )
  104. if (!confirm) {
  105. return
  106. }
  107. this.LOADING('绑定中…')
  108. const [codeErr, { code }] = await uni.login({ provider: type })
  109. if (codeErr || !code) {
  110. this.HIDE_LOADING()
  111. this.TOAST('获取用户授权码失败')
  112. return
  113. }
  114. const success = await this.HTTP_POST('learun/adms/user/openid_bind', { code, type }, '绑定失败')
  115. if (!success) {
  116. return
  117. }
  118. this.HIDE_LOADING()
  119. this.SET_GLOBAL('loginUser', Object.assign({}, this.currentUser, { miniProgram: true }))
  120. this.TOAST(`已成功绑定到当前的${this.PLATFORM_TEXT}账号`)
  121. },
  122. // 解绑小程序
  123. async userUnBind() {
  124. const confirm = await this.CONFIRM(
  125. '解绑确认',
  126. '确定要解除小程序账号绑定吗? (解绑将自动退出登录,需使用力软账号和密码再次登录)',
  127. true
  128. )
  129. if (!confirm) {
  130. return
  131. }
  132. const success = await this.HTTP_POST('learun/adms/user/openid_unbind', { type: this.PLATFORM }, '解除绑定失败')
  133. if (!success) {
  134. return
  135. }
  136. this.CLEAR_GLOBAL()
  137. this.RELAUNCH_TO('/pages/login')
  138. this.TOAST('已成功解除绑定')
  139. },
  140. // #endif
  141. // 跳转到
  142. goTo(urlPath) {
  143. this.NAV_TO(`/pages/my/${urlPath}`)
  144. },
  145. // 解绑微信
  146. unbound(){
  147. this.CONFIRM('提示', '确定要解绑微信账号?', true).then(res => {
  148. if (res) {
  149. this.LOADING('正在解绑…');
  150. this.HTTP_POST('learun/adms/user/unbundWeiXin', null, '解绑失败').then(success => {
  151. this.HIDE_LOADING();
  152. if (!success) {
  153. return
  154. }
  155. this.TOAST("解绑成功")
  156. setTimeout(()=>{
  157. this.CLEAR_GLOBAL()
  158. this.RELAUNCH_TO('/pages/login')
  159. },1000)
  160. });
  161. }
  162. });
  163. },
  164. // 用户头像 url
  165. avatarSrc() {
  166. if (!this.currentUser) {
  167. return ''
  168. }
  169. return this.API + `/learun/adms/user/img?data=${this.currentUser.userId}`
  170. }
  171. },
  172. computed: {
  173. // 返回当前用户
  174. currentUser() {
  175. return this.GET_GLOBAL('loginUser')
  176. },
  177. // 获取组织结构 tag 的显示
  178. userTag() {
  179. if (!this.currentUser) {
  180. return ''
  181. }
  182. const { companyId, departmentId } = this.currentUser
  183. if (!companyId) {
  184. return `总集团公司`
  185. }
  186. const company = this.GET_GLOBAL('company')
  187. const dep = this.GET_GLOBAL('department')
  188. // const companyName = company[companyId].name
  189. // if (!dep) {
  190. // return companyName
  191. // }
  192. // return `${companyName} / ${dep[departmentId].name}`
  193. },
  194. // 头像圆形/方形显示参数
  195. roundAvatar() {
  196. return this.CONFIG('pageConfig.roundAvatar')
  197. },
  198. // 页面底部公司/版权显示
  199. copyRightDisplay() {
  200. const year = new Date().getFullYear()
  201. const company = this.CONFIG('company')
  202. return `Copyright © ${year} ${company}`
  203. },
  204. // #ifdef MP-ALIPAY || MP-WEIXIN
  205. // 是否显示小程序绑定按钮
  206. MPBind() {
  207. return this.CONFIG(`miniProgramAccount.${this.PLATFORM}`).includes('bind')
  208. },
  209. // 是否显示小程序解绑按钮
  210. MPUnbind() {
  211. return this.CONFIG(`miniProgramAccount.${this.PLATFORM}`).includes('unbind')
  212. }
  213. // #endif
  214. }
  215. }
  216. </script>
  217. <style lang="less" scoped>
  218. .page{
  219. padding-bottom: 48px;
  220. }
  221. .mybanner {
  222. background: #0c86d8;
  223. height: 120px;
  224. padding: 25px 15px;
  225. display: flex;
  226. align-items: center;
  227. .avatarslot {
  228. .avatar {
  229. height: 80px;
  230. width: 60px;
  231. }
  232. }
  233. .info {
  234. padding-left: 20px;
  235. .username {
  236. margin-bottom: 5px;
  237. }
  238. }
  239. .badge {
  240. flex-grow: 1;
  241. display: flex;
  242. justify-content: flex-end;
  243. }
  244. }
  245. .footer {
  246. text-align: center;
  247. font-size: 14px;
  248. color: #ccc;
  249. margin-bottom: 10rpx;
  250. }
  251. </style>