center.vue 5.1 KB

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