mine.vue 6.7 KB

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