center.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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="工号" :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="isCorpWX || 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. </main>
  28. <Footer page="my" />
  29. </div>
  30. </template>
  31. <script>
  32. import Footer from "@/components/Footer";
  33. import { mapGetters } from "vuex";
  34. export default {
  35. components: {
  36. Footer
  37. },
  38. computed: {
  39. ...mapGetters(["userId", "isLogin"])
  40. },
  41. data() {
  42. return {
  43. userInfo: JSON.parse(localStorage.userInfo),
  44. isCorpWX:false,
  45. isWX:false,
  46. }
  47. },
  48. methods: {
  49. logout() {
  50. this.$store.commit("updateLogin", false);
  51. localStorage.removeItem("userInfo");
  52. this.$router.push("/login");
  53. },
  54. bindWeiXin(){
  55. //企业微信
  56. if (this.isCorpWX && this.userInfo.corpwxUserid != null) {
  57. return;
  58. }
  59. //微信
  60. else if (this.isWX && this.userInfo.wxOpenid != null) {
  61. return;
  62. }
  63. var appId = "wx749c84daac654e1e";//工时管家公众号
  64. if (this.isCorpWX) {
  65. appId = "ww4e237fd6abb635af"; //企业微信第三方的SUIT ID
  66. }
  67. var url = "http://worktime.ttkuaiban.com/api/wxcorp/bindCorpWeiXin?userId="+this.userInfo.id;//授权回调页面
  68. 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";
  69. window.location.href = weixinUrl;
  70. },
  71. },
  72. create() {
  73. },
  74. mounted() {
  75. var ua = navigator.userAgent.toLowerCase();
  76. if (ua.indexOf("wxwork") > 0) {
  77. this.isCorpWX = true;
  78. } else if (ua.indexOf("micromessenger") > 0) {
  79. this.isWX = true;
  80. }
  81. }
  82. };
  83. </script>
  84. <style lang="less" scoped>
  85. /* 本页公共样式 */
  86. .gray {
  87. color: #797d82;
  88. }
  89. .bott0 {
  90. bottom: 0;
  91. }
  92. .orange {
  93. color: #ff5f16
  94. }
  95. .yellow {
  96. color: #ffb232
  97. }
  98. .bd-gray {
  99. border-bottom: 1px solid #f5f5f5;
  100. }
  101. // 头部图片
  102. .beijin {
  103. background: url(../../../assets/img/personal/head_back.jpg) repeat-y center center;
  104. height: 200px;
  105. background-size: cover;
  106. margin-top: -44px;
  107. }
  108. // 用户名和头像
  109. .users {
  110. top: 55px;
  111. left: 22px;
  112. position: absolute;
  113. // 头像
  114. .imege {
  115. height: 65px;
  116. border-radius: 50%;
  117. }
  118. .fff {
  119. font-size: 22px;
  120. }
  121. }
  122. // 导航
  123. .nav {
  124. height: 75px;
  125. .iconfont {
  126. font-weight: bold;
  127. }
  128. .cit {
  129. height: 26px;
  130. }
  131. }
  132. .logout {
  133. width: 80%;
  134. margin: 50px auto 0;
  135. }
  136. // 主体
  137. main {
  138. .list {
  139. height: 50px;
  140. .image {
  141. height: 20px;
  142. }
  143. }
  144. .foun {
  145. font-size: 12px;
  146. }
  147. }
  148. /* 底部 */
  149. .footer {
  150. height: 50px;
  151. }
  152. </style>