mine.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template>
  2. <view>
  3. <cu-custom heighten="94" ref="Dustom"
  4. bgImage="https://yostest175549.obs.cn-east-2.myhuaweicloud.com:443/202306151686796745663B52544232.png">
  5. <view slot="head" class="head" :style="{ 'height': headHeight, 'top': posTop }">
  6. <view class="custom-bar" :style="{ 'height': customBar }">
  7. <navigator class="iconfont icon-wode-xuanzhong" url="#" @click.stop="showUserCenter" />
  8. </view>
  9. <navigator class="user" url="#" @click.stop="showUserCenter">
  10. <image class="profile-photo" v-if="userMsg.attinfos.length" :src="userMsg.attinfos[0].url"
  11. mode="aspectFill" />
  12. <view v-else class="profile-photo">
  13. <view class="substitution">
  14. <text class="iconfont icon-wode-xuanzhong" />
  15. </view>
  16. </view>
  17. <view class="text">
  18. <view class="name u-line-1">
  19. {{ userMsg.name }}
  20. </view>
  21. <view class="replenish">
  22. <text class="iconfont icon-shoujihao" />
  23. {{ userMsg.phonenumber || '未填写' }}
  24. <block v-if="userMsg.hr.userid">
  25. <text style="margin: 0 10px;">
  26. |
  27. </text>
  28. {{ userMsg.hr.position || '未知职位' }}
  29. </block>
  30. </view>
  31. </view>
  32. </navigator>
  33. </view>
  34. </cu-custom>
  35. <view class="nav-box">
  36. <navigator class="nav-item" url="/pages/index/mine-modules/changePassword">
  37. <text class="iconfont icon-mima" />
  38. <view class="view">
  39. 修改登录密码
  40. </view>
  41. <text class="iconfont icon-a-wodetiaozhuan" />
  42. </navigator>
  43. <navigator class="nav-item" v-if="usePort == 'wechat'" url="#" @tap="bindingWechat">
  44. <text class="iconfont icon-wode-xuanzhong" />
  45. <view class="view">
  46. 绑定微信
  47. </view>
  48. <view class="already-bound" v-if="userMsg.wechatuserinfo.avatarUrl || false">
  49. <view class="portrait">
  50. <image class="image" :src="userMsg.wechatuserinfo.avatarUrl" mode="aspectFit" />
  51. </view>
  52. <text>
  53. 已绑定
  54. </text>
  55. </view>
  56. <view class="not-bound" v-else>
  57. 未绑定
  58. </view>
  59. <text class="iconfont icon-a-wodetiaozhuan" />
  60. </navigator>
  61. </view>
  62. <u-button :customStyle="butStyle" @click="logOut()">退出登录</u-button>
  63. <user-center ref="userCenter" :userMsg="userMsg" @getMsg="getUserMsg" />
  64. </view>
  65. </template>
  66. <script>
  67. import userCenter from "../mine-modules/userCenter.vue"
  68. export default {
  69. name: 'Mine',
  70. components: { userCenter },
  71. data() {
  72. return {
  73. usePort: this.usePort,
  74. uninitialized: true,
  75. posTop: this.tovw(this.StatusBar),
  76. headHeight: this.tovw(this.CustomBar - this.StatusBar),
  77. customBar: this.tovw(this.CustomBar - this.StatusBar),
  78. butStyle: {
  79. position: "fixed",
  80. bottom: '32vw',
  81. left: "2.667vw",
  82. width: "94.667vw",
  83. height: "12vw",
  84. background: "rgba(255,255,255,0.1)",
  85. borderRadius: "1.067vw",
  86. border: "0.267vw solid rgba(255,255,255,0.5)",
  87. fontSize: "4vw",
  88. color: "#FFFFFF"
  89. },
  90. userMsg: {},
  91. };
  92. },
  93. methods: {
  94. init(forcedUpdating = true) {
  95. this.uninitialized = false;
  96. this.getUserMsg()
  97. },
  98. // 获取用户信息
  99. getUserMsg() {
  100. this.$Http.basic({
  101. id: 20230608105102,
  102. content: {
  103. nocache: true
  104. }
  105. }).then(res => {
  106. console.log("用户信息", res)
  107. if (this.cutoff(res.msg)) return;
  108. this.userMsg = res.data;
  109. })
  110. },
  111. /* 打开用户中心 */
  112. showUserCenter() {
  113. this.$refs.userCenter.show = !this.$refs.userCenter.show;
  114. this.$refs.userCenter.spaceUsage = this.$refs.Dustom.getHeight();
  115. },
  116. logOut() {
  117. uni.showModal({
  118. title: '提示',
  119. content: '是否确认退出登录',
  120. success: ({ confirm }) => {
  121. if (confirm) uni.reLaunch({
  122. url: "/pages/login/login"
  123. })
  124. },
  125. })
  126. },
  127. /* 绑定或解绑微信 */
  128. bindingWechat(e) {
  129. let that = this;
  130. if (this.userMsg.iswechatbinding) {
  131. uni.showModal({
  132. title: "提示",
  133. content: "是否解除绑定",
  134. success: (res) => {
  135. if (res.confirm) handleBDWechat(0);
  136. }
  137. })
  138. } else {
  139. handleBDWechat(1);
  140. }
  141. function handleBDWechat(isbinging) {
  142. wx.getUserProfile({
  143. desc: '用于完善用户资料',
  144. success: ({
  145. userInfo
  146. }) => {
  147. wx.login({
  148. success(res) {
  149. if (res.code) that.$Http.basic({
  150. id: 20230608105702,
  151. content: {
  152. "wechat_code": res.code,
  153. isbinging, // 0解绑 1绑定
  154. wechatuserinfo: userInfo,
  155. "appid": "wxd162e1286b6d7ecd"
  156. }
  157. }).then(s => {
  158. console.log("微信绑定", isbinging, s)
  159. if (s.msg != '成功') return wx.showToast({
  160. title: s.data,
  161. icon: "none"
  162. });
  163. setTimeout(() => {
  164. wx.showToast({
  165. title: isbinging == 0 ? '解除成功' : '绑定成功',
  166. icon: "none"
  167. })
  168. }, 100);
  169. that.getUserMsg();
  170. })
  171. }
  172. })
  173. },
  174. fail: () => {
  175. wx.showToast({
  176. title: '操作失败,未获得授权',
  177. icon: "none"
  178. })
  179. }
  180. })
  181. }
  182. },
  183. }
  184. }
  185. </script>
  186. <style lang="scss">
  187. .head {
  188. position: fixed;
  189. width: 100vw;
  190. z-index: 99991;
  191. .custom-bar {
  192. width: 100vw;
  193. position: relative;
  194. .iconfont {
  195. position: absolute;
  196. bottom: 14px;
  197. font-size: 16px;
  198. color: #FFFFFF;
  199. margin-left: 10px;
  200. }
  201. }
  202. .user {
  203. display: flex;
  204. height: 84px;
  205. width: 100vw;
  206. padding: 10px;
  207. box-sizing: border-box;
  208. .profile-photo {
  209. width: 64px;
  210. height: 64px;
  211. border-radius: 50%;
  212. overflow: hidden;
  213. flex-shrink: 0;
  214. margin-right: 10px;
  215. .substitution {
  216. width: 64px;
  217. line-height: 64px;
  218. text-align: center;
  219. background: #EFF4FA;
  220. .iconfont {
  221. font-size: 32px;
  222. color: #7C98BB;
  223. }
  224. }
  225. }
  226. .text {
  227. flex: 1;
  228. height: 64px;
  229. width: 0;
  230. .name {
  231. height: 24px;
  232. line-height: 24px;
  233. font-size: 17px;
  234. color: #FFFFFF;
  235. margin-top: 5px;
  236. }
  237. .replenish {
  238. margin-top: 10px;
  239. line-height: 20px;
  240. font-size: 14px;
  241. color: #FFFFFF;
  242. .iconfont {
  243. font-size: 14px;
  244. margin-right: 5px;
  245. }
  246. }
  247. }
  248. }
  249. }
  250. .nav-box {
  251. width: 355px;
  252. margin: 10px auto 0;
  253. border-radius: 4px;
  254. overflow: hidden;
  255. background: rgba($color: #fff, $alpha: 0.1);
  256. .nav-item {
  257. display: flex;
  258. align-items: center;
  259. width: 100%;
  260. height: 45px;
  261. padding: 0 10px;
  262. box-sizing: border-box;
  263. color: #fff;
  264. font-size: 14px;
  265. .view {
  266. flex: 1;
  267. margin-left: 10px;
  268. }
  269. /* 绑定wx */
  270. .already-bound {
  271. display: flex;
  272. align-items: center;
  273. font-size: 0;
  274. text {
  275. font-size: 13px;
  276. }
  277. .image {
  278. width: 20px;
  279. height: 20px;
  280. border-radius: 50%;
  281. margin-right: 6px;
  282. }
  283. }
  284. .not-bound {
  285. display: flex;
  286. align-items: center;
  287. font-size: 13px;
  288. color: #FF3B30;
  289. }
  290. .iconfont {
  291. font-size: 14px;
  292. flex-shrink: 0;
  293. }
  294. }
  295. }
  296. .cu-bar .content {
  297. overflow: auto !important;
  298. }
  299. </style>