center.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <div class="center">
  3. <!-- 头部 -->
  4. <header>
  5. <div class="beijin"></div>
  6. <div class="flex aic users pixed" style="width:50%;">
  7. <img :src="require('../../../assets/img/personal/userHead.png')" class="imege" />
  8. <span class="f16 fff ml-20">{{userInfo.name}} </span>
  9. </div>
  10. </header>
  11. <!-- 主体 -->
  12. <main class="mt-10">
  13. <div class="bg-fff">
  14. <van-cell title="账号" :title-style="'flex: 0.5;'" :value="userInfo.phone"></van-cell>
  15. <van-cell title="公司" :title-style="'flex: 0.5;'" :value="userInfo.companyName"></van-cell>
  16. <van-cell title="修改密码" isLink to="/my/set"></van-cell>
  17. </div>
  18. <van-cell :title="'绑定'+(isCorpWX?'企业':'')+'微信'" v-if="isCorpWX || isWX" @click="bindWeiXin" style="margin-top:10px;" :title-style="'flex: 2.5;'" label="绑定微信后可接收工时填报提醒">
  19. <template>
  20. <span v-if="(isCorpWX && userInfo.corpwxUserid == null) || (isWX && userInfo.wxOpenid == null)" style="color:#ff0000;">未绑定</span>
  21. <span v-if="(isCorpWX && userInfo.corpwxUserid != null) || (isWX && userInfo.wxOpenid != null)" style="color:#7CCD7C;">已绑定</span>
  22. </template>
  23. </van-cell>
  24. <van-button class="logout" @click="logout" block round type="danger" >退出登录</van-button>
  25. </main>
  26. <Footer page="my" />
  27. </div>
  28. </template>
  29. <script>
  30. import Footer from "@/components/Footer";
  31. import { mapGetters } from "vuex";
  32. export default {
  33. components: {
  34. Footer
  35. },
  36. computed: {
  37. ...mapGetters(["userId", "isLogin"])
  38. },
  39. data() {
  40. return {
  41. userInfo: JSON.parse(localStorage.userInfo),
  42. isCorpWX:false,
  43. isWX:false,
  44. }
  45. },
  46. methods: {
  47. logout() {
  48. this.$store.commit("updateLogin", false);
  49. localStorage.removeItem("userInfo");
  50. this.$router.push("/login");
  51. },
  52. bindWeiXin(){
  53. //企业微信
  54. if (this.isCorpWX && this.userInfo.corpwxUserid != null) {
  55. return;
  56. }
  57. //微信
  58. else if (this.isWX && this.userInfo.wxOpenid != null) {
  59. return;
  60. }
  61. var appId = "wx749c84daac654e1e";//工时管家公众号
  62. if (this.isCorpWX) {
  63. appId = "ww4e237fd6abb635af"; //企业微信第三方的SUIT ID
  64. }
  65. var url = "http://mobworktime.ttkuaiban.com/";//授权回调页面
  66. var weixinUrl="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appId+"&redirect_uri="+encodeURI(url)+"&response_type=code&scope=snsapi_base&state="+this.userInfo.id+"#wechat_redirect";
  67. window.location.href = weixinUrl;
  68. },
  69. },
  70. create() {
  71. },
  72. mounted() {
  73. var ua = navigator.userAgent.toLowerCase();
  74. if (ua.indexOf("wxwork") > 0) {
  75. this.isCorpWX = true;
  76. } else if (ua.indexOf("micromessenger") > 0) {
  77. this.isWX = true;
  78. }
  79. }
  80. };
  81. </script>
  82. <style lang="less" scoped>
  83. /* 本页公共样式 */
  84. .gray {
  85. color: #797d82;
  86. }
  87. .bott0 {
  88. bottom: 0;
  89. }
  90. .orange {
  91. color: #ff5f16
  92. }
  93. .yellow {
  94. color: #ffb232
  95. }
  96. .bd-gray {
  97. border-bottom: 1px solid #f5f5f5;
  98. }
  99. // 头部图片
  100. .beijin {
  101. background: url(../../../assets/img/personal/head_back.jpg) repeat-y center center;
  102. height: 200px;
  103. background-size: cover;
  104. margin-top: -44px;
  105. }
  106. // 用户名和头像
  107. .users {
  108. top: 55px;
  109. left: 22px;
  110. position: absolute;
  111. // 头像
  112. .imege {
  113. height: 65px;
  114. border-radius: 50%;
  115. }
  116. .fff {
  117. font-size: 22px;
  118. }
  119. }
  120. // 导航
  121. .nav {
  122. height: 75px;
  123. .iconfont {
  124. font-weight: bold;
  125. }
  126. .cit {
  127. height: 26px;
  128. }
  129. }
  130. .logout {
  131. width: 80%;
  132. margin: 50px auto 0;
  133. }
  134. // 主体
  135. main {
  136. .list {
  137. height: 50px;
  138. .image {
  139. height: 20px;
  140. }
  141. }
  142. .foun {
  143. font-size: 12px;
  144. }
  145. }
  146. /* 底部 */
  147. .footer {
  148. height: 50px;
  149. }
  150. </style>