center.vue 11 KB

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