center.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <div class="center myCenter">
  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'"><TranslationOpenDataText type='userName' :openid='userInfo.name'></TranslationOpenDataText></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. <!-- <div v-if="userInfo.companyId == '7'"> -->
  16. <van-cell title="当前版本" :title-style="'flex: 0.5;'" :value="version"></van-cell>
  17. <div style="height: 20px;background: #f4f4f4"></div>
  18. <!-- </div> -->
  19. <van-cell title="账号" v-if="userInfo.userNameNeedTranslate != '1'" :title-style="'flex: 0.5;'" :value="userInfo.phone"></van-cell>
  20. <van-cell title="角色" :title-style="'flex: 0.5;'" :value="userInfo.roleName"></van-cell>
  21. <van-cell title="工号" v-if="userInfo.jobNumber" :title-style="'flex: 0.5;'" :value="userInfo.jobNumber"></van-cell>
  22. <div style="height: 20px;background: #f4f4f4"></div>
  23. <van-cell title="公司" :title-style="'flex: 0.5;'" :value="userInfo.companyName"></van-cell>
  24. <van-cell title="有效日期" :title-style="'flex: 0.5;'" :value="expirationDate"></van-cell>
  25. <div style="height: 20px;background: #f4f4f4"></div>
  26. <!-- <div v-if="userInfo.companyId == '7'"> -->
  27. <van-cell title="使用说明" :title-style="'flex: 1;'" is-link @click="instructions()"></van-cell>
  28. <van-cell title="在线客服" :title-style="'flex: 1;'" is-link @click="tokefu()"></van-cell>
  29. <van-cell title="添加员工" :title-style="'flex: 1;'" is-link @click="addEmployee()" v-if="wxManager"></van-cell>
  30. <!-- </div> -->
  31. <!-- <van-cell title="修改密码" isLink to="/my/set"></van-cell> -->
  32. </div>
  33. <van-cell :title="'绑定'+(isCorpWX?'企业':'')+'微信'" v-if="userInfo.userNameNeedTranslate != '1' && (isCorpWX || isWX)" @click="bindWeiXin" style="margin-top:10px;" :title-style="'flex: 2.5;'" label="绑定微信后可接收工时填报提醒">
  34. <template>
  35. <span v-if="(isCorpWX && userInfo.corpwxUserid == null) || (isWX && userInfo.wxOpenid == null)" style="color:#ff0000;">未绑定</span>
  36. <span v-if="(isCorpWX && userInfo.corpwxUserid != null) || (isWX && userInfo.wxOpenid != null)" style="color:#7CCD7C;">已绑定</span>
  37. </template>
  38. </van-cell>
  39. <van-button class="logout" @click="logout" block round type="danger" v-if="!isCorpWX">退出登录</van-button>
  40. <!-- <van-button class="logout" @click="logout" block round type="danger" >退出登录</van-button> -->
  41. </main>
  42. <Footer page="my" />
  43. </div>
  44. </template>
  45. <script>
  46. import Footer from "@/components/Footer";
  47. import { mapGetters } from "vuex";
  48. export default {
  49. components: {
  50. Footer
  51. },
  52. computed: {
  53. ...mapGetters(["userId", "isLogin"])
  54. },
  55. data() {
  56. return {
  57. userInfo: JSON.parse(localStorage.userInfo),
  58. isCorpWX:false,
  59. isWX:false,
  60. expirationDate: '', // 有效日期
  61. version: '', // 版本
  62. show: false,
  63. wxManager: false,
  64. }
  65. },
  66. methods: {
  67. logout() {
  68. this.$store.commit("updateLogin", false);
  69. localStorage.removeItem("userInfo");
  70. this.$router.push("/login");
  71. },
  72. bindWeiXin(){
  73. //企业微信
  74. if (this.isCorpWX && this.userInfo.corpwxUserid != null) {
  75. return;
  76. }
  77. //微信
  78. else if (this.isWX && this.userInfo.wxOpenid != null) {
  79. return;
  80. }
  81. var appId = "wx749c84daac654e1e";//工时管家公众号
  82. var url = "http://mobworktime.ttkuaiban.com/api/wechat/bindWeiXin2?userId="+this.userInfo.id;//工时管家公众号授权回调页面
  83. if (this.isCorpWX) {
  84. appId = "ww4e237fd6abb635af"; //企业微信第三方的SUIT ID
  85. url = "http://worktime.ttkuaiban.com/api/wxcorp/bindCorpWeiXin?userId="+this.userInfo.id;//授权回调页面
  86. }
  87. 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";
  88. window.location.href = weixinUrl;
  89. },
  90. // 使用说明
  91. instructions() {
  92. let url = 'http://celiang.oss-cn-hangzhou.aliyuncs.com/measurement/2022-01/18/75it6phpocqYFV1642488558220118.pdf'
  93. let name = '使用说明书'
  94. // 将要传过去的值
  95. this.previewPDF(url, name)
  96. },
  97. // 预览pdf
  98. previewPDF(url, name) {
  99. this.$router.push({
  100. path: '/pdf',
  101. query: {
  102. url: '',
  103. name: name
  104. }
  105. })
  106. },
  107. // 添加员工
  108. addEmployee() {
  109. wx.invoke('openAppManage', {}, function(res){
  110. console.log(res, '你在看看')
  111. if(res.err_msg == "openAppManage:ok") {
  112. // 调用成功
  113. }
  114. if(res.err_msg == "openAppManage:fail:no permission") {
  115. // 调用人身份不符合
  116. this.$message({message: '调用人身份不符合',type: "error"});
  117. }
  118. if(res.err_msg == "openAppManage:fail:unknown app") {
  119. // 应用信息获取失败
  120. this.$message({message: '应用信息获取失败',type: "error"});
  121. }
  122. if(res.err_msg == "openAppManage:fail:unsupported app type") {
  123. // 应用类型不符合要求
  124. this.$message({message: '应用类型不符合要求',type: "error"});
  125. }
  126. if(res.err_msg == "openAppManage:fail") {
  127. // 其它错误
  128. this.$message({message: '其它错误',type: "error"});
  129. }
  130. })
  131. },
  132. // 跳转客服
  133. tokefu(){
  134. wx.invoke('openThirdAppServiceChat', {
  135. }, function(res) {
  136. console.log('invoke',res);
  137. if (res.err_msg == "openThirdAppServiceChat:ok" || res.err_msg == "openThirdAppServiceChat:cancel") {
  138. }else{
  139. this.$toast.fail('请联系管理员添加客服');
  140. }
  141. }
  142. );
  143. },
  144. // 判断是否有添加员工的权限
  145. getWxManager() {
  146. this.$axios.post("/user/isManager", {})
  147. .then(res => {
  148. if(res.code == "ok") {
  149. let bur = res.data + ''
  150. this.wxManager = bur == 'true'
  151. } else {
  152. this.$toast.clear();
  153. this.$toast.fail(res.msg);
  154. }
  155. }).catch(err=> {this.$toast.clear();});
  156. }
  157. },
  158. create() {
  159. },
  160. mounted() {
  161. var ua = navigator.userAgent.toLowerCase();
  162. if (ua.indexOf("wxwork") > 0) {
  163. this.isCorpWX = true;
  164. } else if (ua.indexOf("micromessenger") > 0) {
  165. this.isWX = true;
  166. }
  167. // 拼接有效日期 和 版本
  168. if(localStorage.userInfo) {
  169. // 日期
  170. let userss = JSON.parse(localStorage.userInfo)
  171. this.expirationDate = userss.company.expirationDate[0] + '-' +
  172. (userss.company.expirationDate[1] >= 10 ? userss.company.expirationDate[1] : ('0' + userss.company.expirationDate[1]))
  173. + '-' + (userss.company.expirationDate[2] >= 10 ? userss.company.expirationDate[2] : ('0' + userss.company.expirationDate[2]))
  174. // 版本
  175. userss.company.packageWorktime == 1 ? this.version = '基础版' : ''
  176. userss.company.packageProject == 1 ? this.version = '专业版' : ''
  177. userss.company.packageEngineering == 1 ? this.version = '建筑工程版' : ''
  178. userss.company.packageOa == 1 ? this.version = '旗舰版' : ''
  179. console.log(this.version)
  180. }
  181. this.getWxManager()
  182. }
  183. };
  184. </script>
  185. <style lang="less" scoped>
  186. .myCenter {
  187. padding-bottom: 50px;
  188. }
  189. /* 本页公共样式 */
  190. .gray {
  191. color: #797d82;
  192. }
  193. .bott0 {
  194. bottom: 0;
  195. }
  196. .orange {
  197. color: #ff5f16
  198. }
  199. .yellow {
  200. color: #ffb232
  201. }
  202. .bd-gray {
  203. border-bottom: 1px solid #f5f5f5;
  204. }
  205. // 头部图片
  206. .beijin {
  207. background: url(../../../assets/img/personal/head_back.jpg) repeat-y center center;
  208. height: 200px;
  209. background-size: cover;
  210. margin-top: -44px;
  211. }
  212. // 用户名和头像
  213. .users {
  214. top: 55px;
  215. left: 22px;
  216. position: absolute;
  217. // 头像
  218. .imege {
  219. height: 65px;
  220. border-radius: 50%;
  221. }
  222. .fff {
  223. font-size: 22px;
  224. }
  225. }
  226. // 导航
  227. .nav {
  228. height: 75px;
  229. .iconfont {
  230. font-weight: bold;
  231. }
  232. .cit {
  233. height: 26px;
  234. }
  235. }
  236. .logout {
  237. width: 80%;
  238. margin: 50px auto;
  239. }
  240. // 主体
  241. main {
  242. .list {
  243. height: 50px;
  244. .image {
  245. height: 20px;
  246. }
  247. }
  248. .foun {
  249. font-size: 12px;
  250. }
  251. }
  252. /* 底部 */
  253. .footer {
  254. height: 50px;
  255. }
  256. // 扫码
  257. .scanCode {
  258. padding: 10px;
  259. }
  260. .scanCode_img img {
  261. width: 100%;
  262. }
  263. </style>