Home.vue 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801
  1. <template>
  2. <el-row class="container">
  3. <el-col :span="24" class="header">
  4. <el-col :span="10" class="logo" :class="collapsed?'logo-collapse-width':'logo-width'" :style="collapsed?'padding:0':''">
  5. <img v-if="collapsed" class="headImg" src="../assets/image/head_logo.png" />
  6. <div v-else class="logo-sys">
  7. <img class="headImg" src="../assets/image/head_logo.png" />
  8. <span>{{$t('workingHoursHousekeeper')}}</span>
  9. </div>
  10. </el-col>
  11. <el-col :span="4">
  12. <div class="tools" @click.prevent="collapse" style="position: relative;">
  13. <i class="fa fa-align-justify"></i>
  14. <span style="position: absolute;width: 350px;left: 60px;">
  15. {{user.companyName}}
  16. </span>
  17. </div>
  18. </el-col>
  19. <el-col :span="10" class="userinfo">
  20. <!-- 中英文切换入口 -->
  21. <!-- <el-dropdown trigger="click" @command="langChange" style="margin-right:30px;">
  22. <span class="el-dropdown-link userinfo-inner">
  23. {{language}} <i class="el-icon-caret-bottom"></i>
  24. </span>
  25. <el-dropdown-menu slot="dropdown">
  26. <el-dropdown-item divided command="zh">中文</el-dropdown-item>
  27. <el-dropdown-item divided command="en">English</el-dropdown-item>
  28. </el-dropdown-menu>
  29. </el-dropdown> -->
  30. <el-dropdown trigger="hover" style="margin-right:30px;">
  31. <span class="el-dropdown-link userinfo-inner">
  32. <i class="el-icon-user" style="font-size:18px" ></i>
  33. {{$t('other.customerService')}}
  34. </span>
  35. <el-dropdown-menu slot="dropdown">
  36. <el-dropdown-item >
  37. <div>
  38. <div>{{$t('other.sweepWeChatYards')}}</div>
  39. <img
  40. style="width: 120px; height: 120px"
  41. src="../assets/image/code.jpg" />
  42. </div>
  43. </el-dropdown-item>
  44. </el-dropdown-menu>
  45. </el-dropdown>
  46. {{$t('time.dueDate')}}:{{remainingTime}}
  47. <el-badge class="itemNew" :value="num" :hidden="num == 0">
  48. <i class="el-icon-message-solid" style="font-size:24px" v-popover:popover1 @click="drawer = true"></i>
  49. </el-badge>
  50. <el-drawer :title="$t('other.messageCenter')" :visible.sync="drawer" direction="rtl" :with-header="false" size="35%">
  51. <el-table :data="popoverData" :height="tableHeight" size="small">
  52. <el-table-column property="type" :label="$t('other.messageContent')" align="left">
  53. <template slot-scope="scope">
  54. <el-link type="primary" :underline="false" @click="locationHerf(scope.row.id,scope.row.content, scope.row.type)">
  55. <span style="font-size:13px;">
  56. <span v-if="scope.row.msg == null">
  57. {{msgTypeTxt[scope.row.type]}}
  58. </span>
  59. <span v-else>
  60. <span v-if="user.userNameNeedTranslate != 1">
  61. {{scope.row.msg}}
  62. </span>
  63. <span v-if="user.userNameNeedTranslate == 1">
  64. {{scope.row.omg.textOne}}
  65. <ww-open-data type='userName' :openid='scope.row.omg.textTwo'></ww-open-data>
  66. {{scope.row.omg.textThree}}
  67. </span>
  68. </span>
  69. <!-- {{scope.row.msg==null?msgTypeTxt[scope.row.type]:scope.row.msg}} -->
  70. </span>
  71. </el-link>
  72. </template>
  73. </el-table-column>
  74. <el-table-column property="type" :label="$t('state.states')" align="center" width="60">
  75. <template slot-scope="scope">
  76. <span v-if="scope.row.checked == 0" style="color:red">{{$t('other.unread')}}</span>
  77. <span v-else style="color:green">{{$t('other.read')}}</span>
  78. </template>
  79. </el-table-column>
  80. <el-table-column property="time" :label="$t('time.times')" align="center" width="120"></el-table-column>
  81. </el-table>
  82. </el-drawer>
  83. <el-dropdown trigger="hover" style="margin-left:10px;">
  84. <span class="el-dropdown-link userinfo-inner">
  85. <img src="../assets/image/userHead.png" />
  86. <span v-if="user.userNameNeedTranslate == 1">
  87. <ww-open-data type='userName' :openid='sysUserName'></ww-open-data>
  88. </span>
  89. <span v-if="user.userNameNeedTranslate != 1">
  90. {{sysUserName}}
  91. </span>
  92. <!-- {{sysUserName}} -->
  93. </span>
  94. <el-dropdown-menu slot="dropdown">
  95. <!-- <el-dropdown-item disabled ><span style="font-size:12px;"><i class="el-icon-view" ></i>{{roleArray[user.role]}}</span></el-dropdown-item> -->
  96. <el-dropdown-item disabled ><span style="font-size:12px;"><i class="el-icon-view" ></i>{{user.roleName}}</span></el-dropdown-item>
  97. <el-dropdown-item disabled ><span style="font-size:12px;"><i class="el-icon-medal" ></i>{{user.jobNumber}}</span></el-dropdown-item>
  98. <el-dropdown-item @click.native="reset">{{$t('other.changeThePassword')}}</el-dropdown-item>
  99. <!-- <el-dropdown-item @click.native="editInfoOpen">修改信息</el-dropdown-item> -->
  100. <el-dropdown-item divided @click.native="logout">{{$t('other.launchTheLogin')}}</el-dropdown-item>
  101. </el-dropdown-menu>
  102. </el-dropdown>
  103. </el-col>
  104. </el-col>
  105. <el-col :span="24" class="main">
  106. <aside :class="collapsed?'menu-collapsed':'menu-expanded'">
  107. <el-scrollbar style="height:100%">
  108. <!--导航菜单-->
  109. <el-menu :default-active="$route.path" class="el-menu-vertical-demo" unique-opened router v-if="!collapsed">
  110. <template v-for="(item, index) in $router.options.routes" v-if="!item.hidden">
  111. <el-submenu :index="index+''" v-if="!item.leaf">
  112. <template slot="title">
  113. <i :class="item.iconCls"></i>
  114. <!-- <span class="itemName">{{item.name}}</span> -->
  115. <span class="itemName bosx" v-if="$t(item.meta.text).length < 16">{{$t(item.meta.text)}}</span>
  116. <el-tooltip class="itemName bosx" v-if="$t(item.meta.text).length > 16" effect="dark" :content="$t(item.meta.text)" placement="top">
  117. <span>{{$t(item.meta.text)}}</span>
  118. </el-tooltip>
  119. </template>
  120. <el-menu-item v-for="child in item.children" :index="child.path" :key="child.path" v-if="!child.hidden"><i :class="child.iconCls"></i>
  121. <!-- {{child.name}} -->
  122. <span class="bosx" v-if="$t(child.meta.text).length < 16">{{$t(child.meta.text)}}</span>
  123. <el-tooltip class="bosx" v-if="$t(child.meta.text).length > 16" effect="dark" :content="$t(child.meta.text)" placement="top">
  124. <span>{{$t(child.meta.text)}}</span>
  125. </el-tooltip>
  126. </el-menu-item>
  127. </el-submenu>
  128. <el-menu-item v-if="item.leaf && item.children.length > 0" :index="item.children[0].path">
  129. <i :class="item.iconCls"></i>
  130. <!-- {{item.children[0].name}} -->
  131. <span class="bosx" v-if="$t(item.meta.text).length < 16">{{$t(item.meta.text)}}</span>
  132. <el-tooltip class="itemName bosx" v-if="$t(item.meta.text).length > 16" effect="dark" :content="$t(item.meta.text)" placement="top">
  133. <span>{{$t(item.meta.text)}}</span>
  134. </el-tooltip>
  135. <!-- {{$t('navigation.reports')}} -->
  136. <!-- this.$t('navigation.reports')  // js-->
  137. </el-menu-item>
  138. </template>
  139. </el-menu>
  140. <!--导航菜单-折叠后-->
  141. <ul class="el-menu el-menu-vertical-demo collapsed" v-if="collapsed" ref="menuCollapsed">
  142. <li v-for="(item,index) in $router.options.routes" v-if="!item.hidden" class="el-submenu item" :style="{overflow:!item.leaf?'':'hidden'}">
  143. <template v-if="!item.leaf">
  144. <div class="el-submenu__title" style="padding-left: 20px;" @mouseover="showMenu(index,true)" @mouseout="showMenu(index,false)">
  145. <i :class="item.iconCls"></i>
  146. </div>
  147. <ul class="el-menu submenu" :class="'submenu-hook-'+index" @mouseover="showMenu(index,true)" @mouseout="showMenu(index,false)">
  148. <li v-for="child in item.children" v-if="!child.hidden" :key="child.path" class="el-menu-item" style="padding-left: 40px;" :class="$route.path==child.path?'is-active':''" @click="$router.push(child.path)">
  149. {{child.name}}
  150. </li>
  151. </ul>
  152. </template>
  153. <template v-else>
  154. <li class="el-submenu">
  155. <div class="el-submenu__title el-menu-item" :class="$route.path==item.children[0].path?'is-active':''" @click="$router.push(item.children[0].path)"
  156. style="padding-left: 20px;height: 56px;line-height: 56px;padding: 0 20px;">
  157. <i :class="item.iconCls"></i>
  158. </div>
  159. </li>
  160. </template>
  161. </li>
  162. </ul>
  163. </el-scrollbar>
  164. </aside>
  165. <section class="content-container">
  166. <div class="grid-content bg-purple-light">
  167. <el-col :span="24" class="content-wrapper">
  168. <transition name="fade" mode="out-in">
  169. <router-view></router-view>
  170. </transition>
  171. </el-col>
  172. </div>
  173. <!--修改密码-->
  174. <el-dialog :title="$t('other.changeThePassword')" width='450px' v-if="editPassWord" :visible.sync="editPassWord" :close-on-click-modal="false" customClass="customWidth">
  175. <el-form :model="addForm" label-width="auto" :rules="passRule" ref="addForm">
  176. <el-form-item :label="$t('lable.originalPassword')" prop="originPassword">
  177. <el-input v-model="addForm.originPassword" autocomplete="off" :placeholder="$t('defaultText.pleaseEnterTheOldPassword')" show-password></el-input>
  178. </el-form-item>
  179. <el-form-item :label="$t('lable.newPassword')" prop="newPassword">
  180. <el-input v-model="addForm.newPassword" autocomplete="off" :placeholder="$t('defaultText.pleaseEnterTheNewPassword')" show-password></el-input>
  181. </el-form-item>
  182. </el-form>
  183. <div slot="footer" class="dialog-footer">
  184. <el-button @click.native="editPassWord = false">{{$t('btn.cancel')}}</el-button>
  185. <el-button type="primary" @click.native="resetPwd" :loading="editLoading">{{$t('btn.submit')}}</el-button>
  186. </div>
  187. </el-dialog>
  188. <!--修改信息-->
  189. <el-dialog :title="$t('title.modifyTheInformation')" width='450px' v-if="editInformation" :visible.sync="editInformation" :close-on-click-modal="false" customClass="customWidth">
  190. <el-form :model="editInfoForm" label-width="auto" :rules="passRule" ref="editInfoForm">
  191. <el-form-item :label="$t('lable.name')" prop="username">
  192. <el-input v-model="editInfoForm.username" autocomplete="off" :placeholder="$t('defaultText.PleaseEnterYourName')"></el-input>
  193. </el-form-item>
  194. </el-form>
  195. <el-form :model="editInfoForm" label-width="auto" :rules="passRule" ref="editInfoForm">
  196. <el-form-item :label="$t('lable.phone')" prop="mobile">
  197. <el-input v-model="editInfoForm.mobile" autocomplete="off" :placeholder="$t('defaultText.PleaseEnterYourPhone')" :disabled="true"></el-input>
  198. </el-form-item>
  199. </el-form>
  200. <div slot="footer" class="dialog-footer">
  201. <el-button @click.native="editInformation = false">{{$t('btn.cancel')}}</el-button>
  202. <el-button type="primary" @click.native="editInfo" :loading="editLoading2">{{$t('btn.submit')}}</el-button>
  203. </div>
  204. </el-dialog>
  205. </section>
  206. </el-col>
  207. </el-row>
  208. </template>
  209. <script>
  210. import util from "../common/js/util";
  211. export default {
  212. // 引用 app.vue reloads 方法
  213. inject:['reloads'],
  214. data() {
  215. return {
  216. // roleArray:["普通员工","超级管理员", "系统管理员", "公司高层","财务管理员", "项目管理员","公司领导"],
  217. roleArray:[this.$t('role.ordinaryEmployees'),this.$t('role.superAdministrator'),this.$t('role.systemAdministrator'),this.$t('role.companyTop'),this.$t('role.financialAdministrator'),this.$t('role.projectManager'),this.$t('role.companyLeadership')],
  218. helpImg: '../assets/image/userHead.png',
  219. user: sessionStorage.getItem("user"),
  220. collapsed: sessionStorage.collapsed!=null?(sessionStorage.collapsed=='true'?true:false):false,
  221. sysUserName: "",
  222. menu: [],
  223. // msgTypeTxt:["审批未通过","有新任务啦","任务有新进展","项目日报审核通过"],
  224. msgTypeTxt:[this.$t('state.notApproved'),this.$t('state.ThereIsAnewTask'),this.$t('state.TheresBeen'),this.$t('state.approvedProject')],
  225. editInformation: false,
  226. editPassWord: false,
  227. editLoading: false,
  228. editLoading2: false,
  229. addForm: {
  230. id: "",
  231. originPassword: "",
  232. newPassword: ""
  233. },
  234. editInfoForm: {
  235. id: "",
  236. username: "",
  237. mobile: "",
  238. companyName: ""
  239. },
  240. passRule: {
  241. originPassword: [{ required: true, message: this.$t('defaultText.pleaseEnterTheOldPassword'), trigger: "blur" }],
  242. newPassword: [{ required: true, message: this.$t('defaultText.pleaseEnterTheNewPassword'), trigger: "blur" }],
  243. username: [{ required: true, message: this.$t('defaultText.PleaseEnterYourName'), trigger: "blur" }]
  244. },
  245. //时间
  246. activeDate: new Date(),
  247. timer: null,
  248. remainingTime: '',
  249. drawer: false,
  250. tableHeight: 0,
  251. popoverData: [],
  252. num: 0,
  253. language: ''
  254. };
  255. },
  256. methods: {
  257. // 中英文切换
  258. langChange(command) {
  259. let flg = this.language
  260. this.$i18n.locale = command
  261. localStorage.setItem("lang", command)
  262. if(command == 'en') {
  263. this.language = 'English'
  264. } else if (command == 'zh') {
  265. this.language = '中文'
  266. }
  267. if(flg != this.language) {
  268. this.reloads()
  269. }
  270. },
  271. //退出登录
  272. logout: function() {
  273. var _this = this;
  274. this.$confirm(this.$t('other.confirmExit') + '?', this.$t('other.prompts'), {
  275. //type: 'warning'
  276. confirmButtonText: this.$t('btn.submit'),
  277. cancelButtonText: this.$t('btn.cancel'),
  278. }).then(() => {
  279. sessionStorage.removeItem("user");
  280. location.reload();
  281. _this.$router.push("/login");
  282. });
  283. },
  284. //折叠导航栏
  285. collapse: function() {
  286. this.collapsed = !this.collapsed;
  287. sessionStorage.collapsed = this.collapsed;
  288. },
  289. showMenu(i, status) {
  290. this.$refs.menuCollapsed.getElementsByClassName(
  291. "submenu-hook-" + i
  292. )[0].style.display = status ? "block" : "none";
  293. },
  294. //打开编辑信息界面
  295. editInfoOpen() {
  296. this.editInformation = true;
  297. this.editInfoForm.id = JSON.parse(sessionStorage.getItem("user")).id;
  298. this.editInfoForm.username = JSON.parse(
  299. sessionStorage.getItem("user")
  300. ).username;
  301. this.editInfoForm.mobile = JSON.parse(
  302. sessionStorage.getItem("user")
  303. ).account;
  304. this.editInfoForm.companyName = JSON.parse(
  305. sessionStorage.getItem("user")
  306. ).companyName;
  307. },
  308. //编辑信息
  309. editInfo() {
  310. this.$refs.editInfoForm.validate(valid => {
  311. if (valid) {
  312. this.editLoading2 = true;
  313. this.http.post(
  314. this.port.pwd.resetPwd,
  315. { id: this.editInfoForm.id, username: this.editInfoForm.username },
  316. res => {
  317. this.editLoading2 = false;
  318. this.editInformation = false;
  319. if (res.code == "ok") {
  320. this.$message({
  321. message: this.$t('message.modifyTheSuccess'),
  322. type: "success"
  323. });
  324. //读取并覆盖session storage
  325. var userObject = JSON.parse(sessionStorage.getItem("user"));
  326. userObject.username = this.editInfoForm.username;
  327. sessionStorage.setItem("user", JSON.stringify(userObject));
  328. this.sysUserName = this.editInfoForm.username;
  329. } else {
  330. this.$message({
  331. message: res.msg,
  332. type: "error"
  333. });
  334. }
  335. },
  336. error => {
  337. this.editLoading2 = false;
  338. this.editInformation = false;
  339. this.$message({
  340. message: error,
  341. type: "error"
  342. });
  343. }
  344. );
  345. }
  346. });
  347. },
  348. reset() {
  349. this.editPassWord = true;
  350. this.addForm.id = JSON.parse(sessionStorage.getItem("user")).id;
  351. this.addForm.account = JSON.parse(sessionStorage.getItem("user")).account;
  352. },
  353. resetPwd() {
  354. this.$refs.addForm.validate(valid => {
  355. if (valid) {
  356. this.editLoading = true;
  357. this.http.post( this.port.manage.editPassword, this.addForm,
  358. res => {
  359. this.editLoading = false;
  360. this.editPassWord = false;
  361. if (res.code == "ok") {
  362. this.$message({
  363. // message: "修改成功,请重新登录",
  364. message: this.$t('message.logAganin'),
  365. type: "success"
  366. });
  367. this.$router.push("/login");
  368. } else {
  369. this.$message({
  370. message: res.msg,
  371. type: "error"
  372. });
  373. }
  374. },
  375. error => {
  376. this.editLoading = false;
  377. this.editPassWord = false;
  378. this.$message({
  379. message: error,
  380. type: "error"
  381. });
  382. });
  383. }
  384. });
  385. },
  386. setTime() {
  387. var d = util.formatDate.cdTime(new Date(new Date().getTime() + this.user.remainingTime), new Date(), 'd');
  388. var h = util.formatDate.cdTime(new Date(new Date().getTime() + this.user.remainingTime), new Date(), 'h');
  389. var m = util.formatDate.cdTime(new Date(new Date().getTime() + this.user.remainingTime), new Date(), 'm');
  390. var s = util.formatDate.cdTime(new Date(new Date().getTime() + this.user.remainingTime), new Date(), 's');
  391. this.remainingTime = d+'天'+h+'时'+m+'分'+s+'秒';
  392. },
  393. // 加载消息
  394. loadNotice() {
  395. this.http.post( this.port.manage.msgList, {},
  396. res => {
  397. if (res.code == "ok") {
  398. var list = res.data;
  399. if(this.user.userNameNeedTranslate == 1) {
  400. let msgArr = res.data
  401. for(var i in msgArr) {
  402. if(msgArr[i].msg) {
  403. let caozuo = JSON.parse(JSON.stringify(msgArr[i].msg))
  404. let textOne = caozuo.split('$userName=')[0]
  405. let textTwo = caozuo.split('$userName=')[1].split('$')[0]
  406. let textThree = caozuo.split('$userName=')[1].split('$')[1]
  407. msgArr[i].omg = {
  408. textOne: textOne,
  409. textTwo: textTwo,
  410. textThree: textThree
  411. }
  412. } else {
  413. msgArr[i].omg = {
  414. textOne: '',
  415. textTwo: '',
  416. textThree: ''
  417. }
  418. }
  419. }
  420. }
  421. this.popoverData = res.data;
  422. var num = 0;
  423. for(var i in list) {
  424. if(list[i].checked != 1) {
  425. num ++;
  426. }
  427. }
  428. this.num = num;
  429. } else {
  430. this.$message({
  431. message: res.msg,
  432. type: "error"
  433. });
  434. }
  435. },
  436. error => {
  437. this.$message({
  438. message: error,
  439. type: "error"
  440. });
  441. });
  442. },
  443. //点击消息的跳转
  444. locationHerf(id, date, type) {
  445. this.http.post( this.port.manage.check, { id: id },
  446. res => {
  447. if (res.code == "ok") {
  448. this.loadNotice();
  449. if (type == 0 || type == 3) {
  450. //审批未通过的消息, 也包括审批通过的通知
  451. sessionStorage.msg = date;
  452. sessionStorage.from = 1;
  453. //本页面再点的话强制转移一下
  454. var currentRoute = this.$route.path.split("/");
  455. if (currentRoute[1] == "daily") {
  456. this.$router.go(0);
  457. this.drawer = false;
  458. return false;
  459. }
  460. this.$router.push("/daily");
  461. this.drawer = false;
  462. } else if (type == 1) {
  463. //1- 有新任务待执行
  464. this.$router.push("/projectInside/"+date);
  465. this.drawer = false;
  466. } else if (type == 2) {
  467. //2- 任务有新进展
  468. this.$router.push("/projectInside/"+date);
  469. this.drawer = false;
  470. }
  471. } else {
  472. this.$message({
  473. message: res.msg,
  474. type: "error"
  475. });
  476. }
  477. },
  478. error => {
  479. this.$message({
  480. message: error,
  481. type: "error"
  482. });
  483. });
  484. },
  485. // 获取企业微信的参数
  486. agentConfig() {
  487. var curUrl = location.href.split("#")[0];
  488. this.http.post("/wxcorp/getCorpWXConfig", {url: curUrl, token: this.user.id}, (res) => {
  489. if (res.code == "ok") {
  490. wx.config({
  491. beta: true,
  492. debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  493. appId: res.data.appid, // 必填,公众号的唯一标识
  494. timestamp: res.data.timestamp, // 必填,生成签名的时间戳
  495. nonceStr: res.data.noncestr, // 必填,生成签名的随机串
  496. signature: res.data.sign, // 必填,签名,见附录1
  497. jsApiList: ['chooseImage','previewImage','uploadImage','downloadImage','previewFile','getLocation','agentConfig']
  498. });
  499. var that = this;
  500. wx.ready(function(){
  501. // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
  502. that.http.post("/wxcorp/getCorpWXAgentConfig", {url: curUrl, token: that.user.id}, (res) => {
  503. if (res.code == "ok") {
  504. console.log()
  505. wx.agentConfig({
  506. corpid: res.data.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致
  507. agentid: res.data.agentid, // 必填,企业微信的应用id (e.g. 1000247)
  508. timestamp: res.data.timestamp, // 必填,生成签名的时间戳
  509. nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
  510. signature: res.data.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
  511. jsApiList: ['selectExternalContact'], //必填,传入需要使用的接口名称
  512. success: function (result) {
  513. console.log(result, '请求微信成功')
  514. console.log(window, 'window')
  515. // wx.agentConfig成功回调后,WWOpenData 才会注入到 window 对象上面
  516. window.WWOpenData.bind(document.querySelector('ww-open-data'))
  517. if (WWOpenData.initCanvas) {
  518. WWOpenData.initCanvas()
  519. console.log('我企业微信 canvas 应该执行了吧')
  520. }
  521. },
  522. fail: function (res) {
  523. console.log('查看错误信息', res)
  524. if (res.errMsg.indexOf('function not exist') > -1) {
  525. alert('版本过低请升级')
  526. }
  527. },
  528. })
  529. }
  530. }, (error) => {
  531. console.log('查看错误信息' + res)
  532. if (error.errMsg.indexOf('function not exist') > -1) {
  533. alert('版本过低请升级')
  534. }
  535. })
  536. });
  537. }
  538. }, (error) => {
  539. console.log(error, '哦耶')
  540. })
  541. },
  542. },
  543. mounted() {
  544. // console.log(this.$router.options.routes, '看看')
  545. console.log(this.$router.options.routes, '路由')
  546. let langse = localStorage.getItem("lang") || 'zh'
  547. if(langse == 'en') {
  548. this.language = 'English'
  549. } else if (langse == 'zh') {
  550. this.language = '中文'
  551. }
  552. let height = window.innerHeight;
  553. this.tableHeight = height - 15;
  554. const that = this;
  555. window.onresize = function temp() {
  556. that.tableHeight = window.innerHeight - 15;
  557. };
  558. if (this.user) {
  559. var user = JSON.parse(this.user);
  560. this.user = user;
  561. this.sysUserName = user.name || "";
  562. this.loadNotice();
  563. if(this.user.remainingTime != "" && this.user.remainingTime != 0) {
  564. this.remainingTime = util.formatDate.format(new Date(new Date().getTime() + this.user.remainingTime), "yyyy-MM-dd")
  565. } else {
  566. this.remainingTime = this.$t('other.expired');
  567. clearInterval(this.timer);
  568. }
  569. } else {
  570. this.$router.push("/login");
  571. }
  572. // console.log('啊,我被触发了呀')
  573. // 获取企业微信参数
  574. if(this.user.userNameNeedTranslate == '1') {
  575. this.agentConfig()
  576. }
  577. },
  578. };
  579. </script>
  580. <style scoped lang="scss">
  581. .el-menu-vertical-demo i {
  582. margin-right: 10px;
  583. }
  584. .container {
  585. position: absolute;
  586. top: 0px;
  587. bottom: 0px;
  588. width: 100%;
  589. .header {
  590. height: 60px;
  591. line-height: 60px;
  592. background: #20a0ff;
  593. color: #fff;
  594. .userinfo {
  595. text-align: right;
  596. padding-right: 35px;
  597. float: right;
  598. .userinfo-inner {
  599. cursor: pointer;
  600. color: #fff;
  601. img {
  602. width: 40px;
  603. height: 40px;
  604. border-radius: 20px;
  605. margin: 10px 10px 10px 10px;
  606. float: left;
  607. }
  608. }
  609. .itemNew {
  610. height: 25px;
  611. margin: 0 0 0 10px;
  612. i {
  613. vertical-align: top;
  614. }
  615. }
  616. }
  617. .logo {
  618. height: 60px;
  619. font-size: 21px;
  620. padding-left: 20px;
  621. padding-right: 20px;
  622. border-color: rgba(238, 241, 146, 0.3);
  623. border-right-width: 1px;
  624. border-right-style: solid;
  625. img {
  626. width: 40px;
  627. float: left;
  628. margin: 10px 10px 10px 18px;
  629. }
  630. img.headImg {
  631. margin: 0;
  632. width: 40px;
  633. height: 40px;
  634. margin: 10px 0 0 10px;
  635. }
  636. .logo-sys {
  637. height: 100%;
  638. line-height: 100%;
  639. img.headImg {
  640. width: 40px;
  641. height: 40px;
  642. margin: 10px 0 0 10px;
  643. vertical-align: middle;
  644. }
  645. span {
  646. display: inline-block;
  647. height: 100%;
  648. line-height: 60px;
  649. margin-left: 15px;
  650. font-size: 18px;
  651. // margin: 20px 0 0 15px;
  652. vertical-align: middle;
  653. }
  654. }
  655. .txt {
  656. color: #fff;
  657. }
  658. }
  659. .logo-width {
  660. width: 200px;
  661. }
  662. .logo-collapse-width {
  663. width: 60px;
  664. }
  665. .tools {
  666. padding: 0px 23px;
  667. width: 14px;
  668. height: 60px;
  669. line-height: 60px;
  670. cursor: pointer;
  671. }
  672. }
  673. .main {
  674. display: flex;
  675. position: absolute;
  676. top: 60px;
  677. bottom: 0px;
  678. overflow: hidden;
  679. aside {
  680. flex: 0 0 230px;
  681. width: 230px;
  682. .el-menu {
  683. height: 100%;
  684. }
  685. .collapsed {
  686. width: 60px;
  687. .item {
  688. position: relative;
  689. }
  690. .submenu {
  691. position: absolute;
  692. top: 0px;
  693. left: 60px;
  694. z-index: 99999;
  695. height: auto;
  696. display: none;
  697. box-shadow: 5px 5px 10px #ddd;
  698. }
  699. }
  700. }
  701. .menu-collapsed {
  702. flex: 0 0 60px;
  703. width: 60px;
  704. }
  705. .menu-expanded {
  706. flex: 0 0 200px;
  707. width: 200px;
  708. }
  709. .content-container {
  710. flex: 1;
  711. width: 80%;
  712. overflow-y: auto;
  713. overflow-x: hidden;
  714. .breadcrumb-container {
  715. .title {
  716. width: 200px;
  717. float: left;
  718. color: #475669;
  719. }
  720. .breadcrumb-inner {
  721. float: right;
  722. }
  723. }
  724. .content-wrapper {
  725. background-color: #fff;
  726. box-sizing: border-box;
  727. }
  728. }
  729. }
  730. }
  731. .popover-item {
  732. padding: 10px;
  733. border-bottom: 1px #eee solid;
  734. }
  735. .popover-item > div > p {
  736. margin: 0;
  737. line-height: 18px;
  738. }
  739. .popover-title {
  740. color: #409eff;
  741. padding-bottom: 8px;
  742. }
  743. .popover-type {
  744. color: #aaa;
  745. font-size: 8px;
  746. float: right;
  747. }
  748. .popover-button {
  749. font-weight: 900;
  750. padding: 10px;
  751. text-align: center;
  752. cursor: pointer;
  753. }
  754. .isRead {
  755. color: #999 !important;
  756. }
  757. .bosx {
  758. width: 110px;
  759. display: inline-block;
  760. overflow: hidden;
  761. white-space: nowrap;
  762. text-overflow: ellipsis;
  763. }
  764. </style>