Home.vue 39 KB

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