center.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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. userss.createTime[1] >= 10 ? userss.createTime[1] : userss.createTime[1] = '0' + userss.createTime[1]
  171. userss.createTime[2] >= 10 ? userss.createTime[2] : userss.createTime[1] = '0' + userss.createTime[2]
  172. userss.company.expirationDate[2] >= 10 ? userss.company.expirationDate[2] : userss.company.expirationDate[1] = '0' + userss.company.expirationDate[2]
  173. userss.company.expirationDate[1] >= 10 ? userss.company.expirationDate[1] : userss.company.expirationDate[1] = '0' + userss.company.expirationDate[1]
  174. // this.expirationDate = userss.createTime[0] + '-' + userss.createTime[1] + '-' + userss.createTime[2] + ' 至 ' + userss.company.expirationDate[0] + '-' + userss.company.expirationDate[1] + '-' + userss.company.expirationDate[2]
  175. this.expirationDate = userss.company.expirationDate[0] + '-' + userss.company.expirationDate[1] + '-' + userss.company.expirationDate[2]
  176. // 版本
  177. userss.company.packageWorktime == 1 ? this.version = '基础版' : ''
  178. userss.company.packageProject == 1 ? this.version = '专业版' : ''
  179. userss.company.packageEngineering == 1 ? this.version = '建筑工程版' : ''
  180. userss.company.packageOa == 1 ? this.version = '旗舰版' : ''
  181. console.log(this.version)
  182. }
  183. this.getWxManager()
  184. }
  185. };
  186. </script>
  187. <style lang="less" scoped>
  188. .myCenter {
  189. padding-bottom: 50px;
  190. }
  191. /* 本页公共样式 */
  192. .gray {
  193. color: #797d82;
  194. }
  195. .bott0 {
  196. bottom: 0;
  197. }
  198. .orange {
  199. color: #ff5f16
  200. }
  201. .yellow {
  202. color: #ffb232
  203. }
  204. .bd-gray {
  205. border-bottom: 1px solid #f5f5f5;
  206. }
  207. // 头部图片
  208. .beijin {
  209. background: url(../../../assets/img/personal/head_back.jpg) repeat-y center center;
  210. height: 200px;
  211. background-size: cover;
  212. margin-top: -44px;
  213. }
  214. // 用户名和头像
  215. .users {
  216. top: 55px;
  217. left: 22px;
  218. position: absolute;
  219. // 头像
  220. .imege {
  221. height: 65px;
  222. border-radius: 50%;
  223. }
  224. .fff {
  225. font-size: 22px;
  226. }
  227. }
  228. // 导航
  229. .nav {
  230. height: 75px;
  231. .iconfont {
  232. font-weight: bold;
  233. }
  234. .cit {
  235. height: 26px;
  236. }
  237. }
  238. .logout {
  239. width: 80%;
  240. margin: 50px auto;
  241. }
  242. // 主体
  243. main {
  244. .list {
  245. height: 50px;
  246. .image {
  247. height: 20px;
  248. }
  249. }
  250. .foun {
  251. font-size: 12px;
  252. }
  253. }
  254. /* 底部 */
  255. .footer {
  256. height: 50px;
  257. }
  258. // 扫码
  259. .scanCode {
  260. padding: 10px;
  261. }
  262. .scanCode_img img {
  263. width: 100%;
  264. }
  265. </style>