personalCenter.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. <template>
  2. <view class="personalCenter">
  3. <view class="p_header">
  4. 个人信息
  5. </view>
  6. <view class="orderDetail_info">
  7. <scroll-view scroll-y class="orderDetail_infoItem">
  8. <view class="orderDetail_infoItem_header">
  9. <view class="orderDetail_infoItem_header_title">
  10. <view class="taskNameAndWorkerName">
  11. <text class="taskName">姓名:{{loginInfo.user?loginInfo.user.name:'暂无'}}</text>
  12. </view>
  13. </view>
  14. <text class="orderDetail_infoItem_header_more green">工号:{{loginInfo.user?loginInfo.user.account:'暂无'}}</text>
  15. </view>
  16. <view class="orderDetail_infoItem_item">
  17. <view class="orderDetail_infoItem_item_content">
  18. <text class="orderDetail_infoItem_item_name">所属院区</text>
  19. <text
  20. class="orderDetail_infoItem_item_value">{{loginInfo.user?(loginInfo.user.currentHospital?loginInfo.user.currentHospital.hosName:'暂无'):'暂无'}}</text>
  21. </view>
  22. <view class="orderDetail_infoItem_item_content">
  23. <text class="orderDetail_infoItem_item_name">所属科室</text>
  24. <text
  25. class="orderDetail_infoItem_item_value">{{loginInfo.user?(deptDisplay == 2?loginInfo.user.dept.deptalias:loginInfo.user.dept.dept):'暂无'}}</text>
  26. </view>
  27. </view>
  28. </scroll-view>
  29. </view>
  30. <view class="changeDept">
  31. <button type="primary" @click="showDeptModel">切换科室</button>
  32. <button type="primary" @click="checkUpdate">检测更新</button>
  33. <button type="primary" @click="changePwd">修改密码</button>
  34. <button type="primary" @click="logout">退出登录</button>
  35. </view>
  36. <seiminFooterNav></seiminFooterNav>
  37. <seiminModel ref="seiminModel"></seiminModel>
  38. <seiminPicker ref="sPicker" :title="pickerTitle" titleColor="#808080" titleFontSize="28rpx" confirmColor="#333"
  39. confirmFontSize="38rpx" confirmFontWeight="500" itemFontSize="32rpx" @onClose="closePicker"
  40. @onConfirm="confirmPicker" :pickerList="hospitalList">
  41. </seiminPicker>
  42. </view>
  43. </template>
  44. <script>
  45. import {
  46. backPress
  47. } from '../../utils/index.js';
  48. import config from "../../request/config.js";
  49. import {
  50. mapState,
  51. mapMutations
  52. } from "vuex";
  53. import {
  54. reqLogout2,
  55. reqUppwd,
  56. reqFetchDataList,
  57. } from "../../request/api.js";
  58. export default {
  59. onBackPress() {
  60. backPress();
  61. },
  62. data() {
  63. return {
  64. reFresh: '',
  65. hospitalList: [], //当前用户权限中的院区列表
  66. pickerTitle: "", //选择院区picker的title
  67. };
  68. },
  69. computed: {
  70. ...mapState("login", ["loginInfo"]),
  71. ...mapState("other", ["deptDisplay"]),
  72. },
  73. mounted() {
  74. //选择院区picker的title
  75. this.pickerTitle = `您当前所属科室为<b class="green">${this.loginInfo.user.dept.dept}</b>,请您先选择院区`;
  76. //权限中的院区修改数据结构
  77. this.hospitalList = this.loginInfo.infoPermission.hospitals.map((v) => ({
  78. value: v.id,
  79. label: v.hosName,
  80. }));
  81. },
  82. methods: {
  83. ...mapMutations('other', [
  84. "changeSearchDeptParams",
  85. ]),
  86. // 切换科室弹窗
  87. showDeptModel() {
  88. const {
  89. user, //当前登录用户
  90. } = this.loginInfo;
  91. const userDept =
  92. user && user.dept ?
  93. this.deptDisplay == 1 ?
  94. user.dept.dept :
  95. user.dept.deptalias :
  96. "";
  97. this.$refs.seiminModel.showChangeDept({
  98. content: `您当前所属科室为<text class="green">${userDept}</text>,如与您实际科室不符点击<text class="red">切换科室</text>。`,
  99. btns: [{
  100. name: "知道了",
  101. textColor: "#49B856",
  102. flex: 2,
  103. },
  104. {
  105. name: "前往切换科室",
  106. textColor: "#666",
  107. flex: 3,
  108. click: (e) => {
  109. this.$refs.seiminModel.close();
  110. this.openPicker();
  111. },
  112. },
  113. ],
  114. });
  115. },
  116. //关闭
  117. closePicker() {
  118. this.$refs.sPicker._close();
  119. },
  120. //打开
  121. openPicker() {
  122. this.$refs.sPicker._open();
  123. let index = this.hospitalList.findIndex(v => v.value == this.loginInfo.user.currentHospital.id);
  124. this.$refs.sPicker._changeValue(index);
  125. },
  126. //确定:接收子组件传来的参数
  127. confirmPicker(checkedObj) {
  128. this.changeSearchDeptParams({
  129. backUrl: "/pages/personalCenter/personalCenter", //返回的url
  130. type: "changeDept_index", //首页切换科室
  131. hospital: checkedObj, //先选择院区
  132. });
  133. uni.navigateTo({
  134. url: "/pages/searchDept/searchDept",
  135. });
  136. },
  137. // 退出登录
  138. logout() {
  139. this.$refs.seiminModel.show({
  140. icon: "warn",
  141. content: '确定退出登录?',
  142. btns: [{
  143. click: () => {
  144. this.$refs.seiminModel.close();
  145. },
  146. }, {
  147. click: () => {
  148. // 在同济后端的退出接口调不通,先用假退出,后期后端调整后自行修改
  149. this.$refs.seiminModel.close();
  150. this.$refs.seiminModel.show({
  151. skin: "toast",
  152. icon: "success",
  153. content: "退出成功",
  154. btns: [{
  155. click: () => {
  156. uni.reLaunch({
  157. url: '/pages/login/login'
  158. })
  159. }
  160. }]
  161. });
  162. // uni.showLoading({
  163. // mask: true,
  164. // title: '加载中'
  165. // })
  166. // reqLogout2()
  167. // .then((data) => {
  168. // uni.hideLoading();
  169. // if (data.status == 200) {
  170. // this.$refs.seiminModel.close();
  171. // this.$refs.seiminModel.show({
  172. // skin: "toast",
  173. // icon: "success",
  174. // content: "退出成功",
  175. // btns: [{
  176. // click: () => {
  177. // uni.reLaunch({
  178. // url: '/pages/login/login'
  179. // })
  180. // }
  181. // }]
  182. // });
  183. // } else {
  184. // this.$refs.seiminModel.show({
  185. // skin: "toast",
  186. // icon: "error",
  187. // content: data.error || "退出失败",
  188. // });
  189. // }
  190. // });
  191. },
  192. }, ],
  193. })
  194. },
  195. // 修改密码
  196. changePwd() {
  197. this.$refs.seiminModel.show({
  198. skin: 'changePwd',
  199. title: '修改密码',
  200. btns: [{
  201. click: () => {
  202. this.$refs.seiminModel.close();
  203. },
  204. }, {
  205. click: () => {
  206. uni.showLoading({
  207. mask: true,
  208. title: '加载中'
  209. })
  210. console.log(this)
  211. let postData = {
  212. "userid": this.loginInfo.user.id,
  213. "pwdOld": this.$refs.seiminModel.pwdOld,
  214. "newPwd": this.$refs.seiminModel.newPwd,
  215. "newPwd2": this.$refs.seiminModel.newPwd2,
  216. };
  217. reqUppwd(postData)
  218. .then((data) => {
  219. uni.hideLoading();
  220. if (data.status == 200) {
  221. this.$refs.seiminModel.close();
  222. this.$refs.seiminModel.show({
  223. skin: "toast",
  224. icon: "success",
  225. content: "修改密码成功",
  226. btns: [{
  227. click: () => {
  228. uni.navigateTo({
  229. url: '/pages/login/login'
  230. })
  231. }
  232. }]
  233. });
  234. } else {
  235. this.$refs.seiminModel.show({
  236. skin: "toast",
  237. icon: "error",
  238. content: data.error || "修改密码失败",
  239. });
  240. }
  241. });
  242. },
  243. }, ],
  244. })
  245. },
  246. // 检测更新
  247. checkUpdate() {
  248. uni.showLoading({
  249. mask: true,
  250. title: '加载中'
  251. })
  252. let postData = {
  253. "idx": 0,
  254. "sum": 1,
  255. "systemConfiguration": {
  256. "keyconfig": "pdaVersion"
  257. }
  258. };
  259. reqFetchDataList('simple/data', 'systemConfiguration', postData)
  260. .then((data) => {
  261. uni.hideLoading();
  262. if (data.status == 200) {
  263. const version = data.list[0].valueconfig;
  264. // #ifdef APP-PLUS
  265. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  266. console.log(wgtinfo.version); //应用版本号
  267. if (wgtinfo.version === version) {
  268. this.$refs.seiminModel.show({
  269. skin: "toast",
  270. icon: "success",
  271. content: "您所使用的已是最新版本",
  272. });
  273. } else {
  274. this.$refs.seiminModel.show({
  275. icon: 'warn',
  276. content: `发现新版本Version ${version}`,
  277. btns: [{},
  278. {
  279. name: '立即下载更新',
  280. click: () => {
  281. this.downloadUrl(`${config.pdaDownloadUrl}/pda-v${version}.apk`);
  282. }
  283. }
  284. ]
  285. });
  286. }
  287. })
  288. // #endif
  289. // #ifndef APP-PLUS
  290. this.$refs.seiminModel.show({
  291. skin: "toast",
  292. icon: "error",
  293. content: "当前不是APP端",
  294. });
  295. // #endif
  296. } else {
  297. this.$refs.seiminModel.show({
  298. skin: "toast",
  299. icon: "error",
  300. content: data.error || "获取版本失败",
  301. });
  302. }
  303. });
  304. },
  305. // 下载更新
  306. downloadUrl(Url = '') {
  307. uni.showLoading({
  308. title: '更新中……',
  309. mask: true,
  310. })
  311. const downloadTask = uni.downloadFile({ //执行下载
  312. url: Url, //下载地址
  313. timeout: 1000 * 30, //30秒超时时间
  314. success: downloadResult => { //下载成功
  315. console.log(downloadResult)
  316. uni.hideLoading();
  317. if (downloadResult.statusCode == 200) {
  318. plus.runtime.install( //安装软件
  319. downloadResult.tempFilePath, {
  320. force: true
  321. },
  322. function(res) {
  323. plus.runtime.restart();
  324. }
  325. );
  326. } else {
  327. this.$refs.seiminModel.show({
  328. skin: "toast",
  329. icon: "error",
  330. content: "下载失败",
  331. });
  332. }
  333. },
  334. fail: err => {
  335. uni.hideLoading();
  336. this.$refs.seiminModel.show({
  337. skin: "toast",
  338. icon: "error",
  339. content: "更新失败",
  340. });
  341. console.log(err)
  342. },
  343. });
  344. },
  345. }
  346. }
  347. </script>
  348. <style lang="scss" scoped>
  349. .personalCenter {
  350. ::v-deep uni-button[type=primary] {
  351. background-color: $defaultColor;
  352. }
  353. .p_header {
  354. height: 88rpx;
  355. font-size: 46rpx;
  356. color: #333;
  357. font-weight: bold;
  358. @include flex(center, center);
  359. }
  360. .changeDept {
  361. margin: 24rpx 24rpx 0;
  362. button {
  363. margin-bottom: 16rpx;
  364. }
  365. }
  366. .orderDetail_info {
  367. padding: 0 24rpx;
  368. .orderDetail_infoItem {
  369. width: 702rpx;
  370. height: 25vh;
  371. background-color: #fff;
  372. border-radius: 8rpx;
  373. position: relative;
  374. padding: 0 24rpx 24rpx;
  375. font-size: 32rpx;
  376. @include border;
  377. @include semicircle(#f9fafb, 82rpx);
  378. @include flex(flex-start, stretch, column);
  379. .ji,
  380. .jiaji {
  381. width: 60rpx;
  382. position: absolute;
  383. right: 0;
  384. top: 0;
  385. }
  386. .orderDetail_infoItem_header {
  387. height: 86rpx;
  388. @include border($directive:bottom, $style:dashed);
  389. @include flex(space-between, center);
  390. .orderDetail_infoItem_header_title {
  391. color: #333;
  392. @include flex(flex-start, center);
  393. .taskNameAndWorkerName {
  394. flex: 1;
  395. @include flex;
  396. .taskName {
  397. max-width: 10em;
  398. font-size: 38rpx;
  399. font-weight: bold;
  400. @include clamp;
  401. }
  402. }
  403. }
  404. .orderDetail_infoItem_header_more {
  405. color: #333;
  406. font-weight: bold;
  407. font-size: 38rpx;
  408. @include clamp;
  409. }
  410. }
  411. .orderDetail_infoItem_item {
  412. padding-top: 12rpx;
  413. padding-bottom: 12rpx;
  414. color: #333;
  415. font-size: 30rpx;
  416. flex: 1;
  417. @include border(bottom);
  418. @include flex(flex-start, stretch, column);
  419. &.process {
  420. padding-top: 90rpx;
  421. padding-bottom: 90rpx;
  422. }
  423. &:last-of-type {
  424. border-bottom: none;
  425. }
  426. // 工单信息
  427. .orderDetail_infoItem_item_content {
  428. margin-top: 20rpx;
  429. @include flex(space-between, stretch);
  430. .orderDetail_infoItem_item_name {
  431. font-size: 34rpx;
  432. color: #666;
  433. max-width: 4em;
  434. }
  435. .orderDetail_infoItem_item_value {
  436. font-size: 38rpx;
  437. color: #333;
  438. font-weight: bold;
  439. max-width: 420rpx;
  440. text-align: justify;
  441. word-break: break-all;
  442. }
  443. }
  444. }
  445. }
  446. }
  447. }
  448. </style>