Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

4 anni fa
4 anni fa
4 anni fa
4 anni fa
4 anni fa
4 anni fa
4 anni fa
4 anni fa
4 anni fa
4 anni fa
4 anni fa
4 anni fa
4 anni fa
4 anni fa
4 anni fa
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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="aspectFill"
  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. </view>
  79. </template>
  80. <script>
  81. export default {
  82. methods: {
  83. // 点击「注销登录」按钮
  84. async logout() {
  85. if (!(await this.CONFIRM('注销确认', '确定要注销登录吗?', true))) {
  86. return
  87. }
  88. this.CLEAR_GLOBAL()
  89. this.RELAUNCH_TO('/pages/login')
  90. },
  91. // #ifdef MP-ALIPAY || MP-WEIXIN
  92. // 小程序绑定方法,只会编译到小程序
  93. async userBind() {
  94. const type = this.PLATFORM
  95. const confirm = await this.CONFIRM(
  96. '绑定确认',
  97. `确定要将智慧校园账号与当前登录的${this.PLATFORM_TEXT}账号绑定吗?\n(绑定后可以使用一键登录功能)`,
  98. true
  99. )
  100. if (!confirm) {
  101. return
  102. }
  103. this.LOADING('绑定中…')
  104. const [codeErr, { code }] = await uni.login({ provider: type })
  105. if (codeErr || !code) {
  106. this.HIDE_LOADING()
  107. this.TOAST('获取用户授权码失败')
  108. return
  109. }
  110. const success = await this.HTTP_POST('learun/adms/user/openid_bind', { code, type }, '绑定失败')
  111. if (!success) {
  112. return
  113. }
  114. this.HIDE_LOADING()
  115. this.SET_GLOBAL('loginUser', Object.assign({}, this.currentUser, { miniProgram: true }))
  116. this.TOAST(`已成功绑定到当前的${this.PLATFORM_TEXT}账号`)
  117. },
  118. // 解绑小程序
  119. async userUnBind() {
  120. const confirm = await this.CONFIRM(
  121. '解绑确认',
  122. '确定要解除小程序账号绑定吗? (解绑将自动退出登录,需使用力软账号和密码再次登录)',
  123. true
  124. )
  125. if (!confirm) {
  126. return
  127. }
  128. const success = await this.HTTP_POST('learun/adms/user/openid_unbind', { type: this.PLATFORM }, '解除绑定失败')
  129. if (!success) {
  130. return
  131. }
  132. this.CLEAR_GLOBAL()
  133. this.RELAUNCH_TO('/pages/login')
  134. this.TOAST('已成功解除绑定')
  135. },
  136. // #endif
  137. // 跳转到
  138. goTo(urlPath) {
  139. this.NAV_TO(`/pages/my/${urlPath}`)
  140. },
  141. // 解绑微信
  142. unbound(){
  143. this.CONFIRM('提示', '确定要解绑微信账号?', true).then(res => {
  144. if (res) {
  145. this.LOADING('正在解绑…');
  146. this.HTTP_POST('learun/adms/user/unbundWeiXin', null, '解绑失败').then(success => {
  147. this.HIDE_LOADING();
  148. if (!success) {
  149. return
  150. }
  151. this.TOAST("解绑成功")
  152. setTimeout(()=>{
  153. this.CLEAR_GLOBAL()
  154. this.RELAUNCH_TO('/pages/login')
  155. },1000)
  156. });
  157. }
  158. });
  159. },
  160. // 用户头像 url
  161. avatarSrc() {
  162. if (!this.currentUser) {
  163. return ''
  164. }
  165. return this.API + `/learun/adms/user/img?data=${this.currentUser.userId}`
  166. }
  167. },
  168. computed: {
  169. // 返回当前用户
  170. currentUser() {
  171. return this.GET_GLOBAL('loginUser')
  172. },
  173. // 获取组织结构 tag 的显示
  174. userTag() {
  175. if (!this.currentUser) {
  176. return ''
  177. }
  178. const { companyId, departmentId } = this.currentUser
  179. if (!companyId) {
  180. return `总集团公司`
  181. }
  182. const company = this.GET_GLOBAL('company')
  183. const dep = this.GET_GLOBAL('department')
  184. // const companyName = company[companyId].name
  185. // if (!dep) {
  186. // return companyName
  187. // }
  188. // return `${companyName} / ${dep[departmentId].name}`
  189. },
  190. // 头像圆形/方形显示参数
  191. roundAvatar() {
  192. return this.CONFIG('pageConfig.roundAvatar')
  193. },
  194. // 页面底部公司/版权显示
  195. copyRightDisplay() {
  196. const year = new Date().getFullYear()
  197. const company = this.CONFIG('company')
  198. return `Copyright © ${year} ${company}`
  199. },
  200. // #ifdef MP-ALIPAY || MP-WEIXIN
  201. // 是否显示小程序绑定按钮
  202. MPBind() {
  203. return this.CONFIG(`miniProgramAccount.${this.PLATFORM}`).includes('bind')
  204. },
  205. // 是否显示小程序解绑按钮
  206. MPUnbind() {
  207. return this.CONFIG(`miniProgramAccount.${this.PLATFORM}`).includes('unbind')
  208. }
  209. // #endif
  210. }
  211. }
  212. </script>
  213. <style lang="less" scoped>
  214. .mybanner {
  215. background: #0c86d8;
  216. height: 120px;
  217. padding: 25px 15px;
  218. display: flex;
  219. align-items: center;
  220. .avatarslot {
  221. .avatar {
  222. height: 60px;
  223. width: 60px;
  224. }
  225. }
  226. .info {
  227. padding-left: 20px;
  228. .username {
  229. margin-bottom: 5px;
  230. }
  231. }
  232. .badge {
  233. flex-grow: 1;
  234. display: flex;
  235. justify-content: flex-end;
  236. }
  237. }
  238. .footer {
  239. text-align: center;
  240. font-size: 14px;
  241. color: #ccc;
  242. margin-bottom: 10rpx;
  243. }
  244. </style>