personalCenter.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  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. uni.showLoading({
  149. mask: true,
  150. title: '加载中'
  151. })
  152. reqLogout2()
  153. .then((data) => {
  154. uni.hideLoading();
  155. if (data.status == 200) {
  156. this.$refs.seiminModel.close();
  157. this.$refs.seiminModel.show({
  158. skin: "toast",
  159. icon: "success",
  160. content: "退出成功",
  161. btns: [{
  162. click: () => {
  163. uni.navigateTo({
  164. url: '/pages/login/login'
  165. })
  166. }
  167. }]
  168. });
  169. } else {
  170. this.$refs.seiminModel.show({
  171. skin: "toast",
  172. icon: "error",
  173. content: data.error || "退出失败",
  174. });
  175. }
  176. });
  177. },
  178. }, ],
  179. })
  180. },
  181. // 修改密码
  182. changePwd() {
  183. this.$refs.seiminModel.show({
  184. skin: 'changePwd',
  185. title: '修改密码',
  186. btns: [{
  187. click: () => {
  188. this.$refs.seiminModel.close();
  189. },
  190. }, {
  191. click: () => {
  192. uni.showLoading({
  193. mask: true,
  194. title: '加载中'
  195. })
  196. console.log(this)
  197. let postData = {
  198. "userid": this.loginInfo.user.id,
  199. "pwdOld": this.$refs.seiminModel.pwdOld,
  200. "newPwd": this.$refs.seiminModel.newPwd,
  201. "newPwd2": this.$refs.seiminModel.newPwd2,
  202. };
  203. reqUppwd(postData)
  204. .then((data) => {
  205. uni.hideLoading();
  206. if (data.status == 200) {
  207. this.$refs.seiminModel.close();
  208. this.$refs.seiminModel.show({
  209. skin: "toast",
  210. icon: "success",
  211. content: "修改密码成功",
  212. btns: [{
  213. click: () => {
  214. uni.navigateTo({
  215. url: '/pages/login/login'
  216. })
  217. }
  218. }]
  219. });
  220. } else {
  221. this.$refs.seiminModel.show({
  222. skin: "toast",
  223. icon: "error",
  224. content: data.error || "修改密码失败",
  225. });
  226. }
  227. });
  228. },
  229. }, ],
  230. })
  231. },
  232. // 检测更新
  233. checkUpdate() {
  234. uni.showLoading({
  235. mask: true,
  236. title: '加载中'
  237. })
  238. let postData = {
  239. "idx": 0,
  240. "sum": 1,
  241. "systemConfiguration": {
  242. "keyconfig": "pdaVersion"
  243. }
  244. };
  245. reqFetchDataList('simple/data', 'systemConfiguration', postData)
  246. .then((data) => {
  247. uni.hideLoading();
  248. if (data.status == 200) {
  249. const version = data.list[0].valueconfig;
  250. // #ifdef APP-PLUS
  251. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  252. console.log(wgtinfo.version); //应用版本号
  253. if (wgtinfo.version === version) {
  254. this.$refs.seiminModel.show({
  255. skin: "toast",
  256. icon: "success",
  257. content: "您所使用的已是最新版本",
  258. });
  259. } else {
  260. this.$refs.seiminModel.show({
  261. icon: 'warn',
  262. content: `发现新版本Version ${version}`,
  263. btns: [{},
  264. {
  265. name: '立即下载更新',
  266. click: () => {
  267. this.downloadUrl(`${config.pdaDownloadUrl}/pda-v${version}.apk`);
  268. }
  269. }
  270. ]
  271. });
  272. }
  273. })
  274. // #endif
  275. // #ifndef APP-PLUS
  276. this.$refs.seiminModel.show({
  277. skin: "toast",
  278. icon: "error",
  279. content: "当前不是APP端",
  280. });
  281. // #endif
  282. } else {
  283. this.$refs.seiminModel.show({
  284. skin: "toast",
  285. icon: "error",
  286. content: data.error || "获取版本失败",
  287. });
  288. }
  289. });
  290. },
  291. // 下载更新
  292. downloadUrl(Url = '') {
  293. uni.showLoading({
  294. title: '更新中……',
  295. mask: true,
  296. })
  297. const downloadTask = uni.downloadFile({ //执行下载
  298. url: Url, //下载地址
  299. timeout: 1000 * 30, //30秒超时时间
  300. success: downloadResult => { //下载成功
  301. console.log(downloadResult)
  302. uni.hideLoading();
  303. if (downloadResult.statusCode == 200) {
  304. plus.runtime.install( //安装软件
  305. downloadResult.tempFilePath, {
  306. force: true
  307. },
  308. function(res) {
  309. plus.runtime.restart();
  310. }
  311. );
  312. } else {
  313. this.$refs.seiminModel.show({
  314. skin: "toast",
  315. icon: "error",
  316. content: "下载失败",
  317. });
  318. }
  319. },
  320. fail: err => {
  321. uni.hideLoading();
  322. this.$refs.seiminModel.show({
  323. skin: "toast",
  324. icon: "error",
  325. content: "更新失败",
  326. });
  327. console.log(err)
  328. },
  329. });
  330. },
  331. }
  332. }
  333. </script>
  334. <style lang="scss" scoped>
  335. .personalCenter {
  336. ::v-deep uni-button[type=primary] {
  337. background-color: $defaultColor;
  338. }
  339. .p_header {
  340. height: 88rpx;
  341. font-size: 46rpx;
  342. color: #333;
  343. font-weight: bold;
  344. @include flex(center, center);
  345. }
  346. .changeDept {
  347. margin: 24rpx 24rpx 0;
  348. button {
  349. margin-bottom: 16rpx;
  350. }
  351. }
  352. .orderDetail_info {
  353. padding: 0 24rpx;
  354. .orderDetail_infoItem {
  355. width: 702rpx;
  356. height: 25vh;
  357. background-color: #fff;
  358. border-radius: 8rpx;
  359. position: relative;
  360. padding: 0 24rpx 24rpx;
  361. font-size: 32rpx;
  362. @include border;
  363. @include semicircle(#f9fafb, 82rpx);
  364. @include flex(flex-start, stretch, column);
  365. .ji,
  366. .jiaji {
  367. width: 60rpx;
  368. position: absolute;
  369. right: 0;
  370. top: 0;
  371. }
  372. .orderDetail_infoItem_header {
  373. height: 86rpx;
  374. @include border($directive:bottom, $style:dashed);
  375. @include flex(space-between, center);
  376. .orderDetail_infoItem_header_title {
  377. color: #333;
  378. @include flex(flex-start, center);
  379. .taskNameAndWorkerName {
  380. flex: 1;
  381. @include flex;
  382. .taskName {
  383. max-width: 10em;
  384. font-size: 38rpx;
  385. font-weight: bold;
  386. @include clamp;
  387. }
  388. }
  389. }
  390. .orderDetail_infoItem_header_more {
  391. color: #333;
  392. font-weight: bold;
  393. font-size: 38rpx;
  394. @include clamp;
  395. }
  396. }
  397. .orderDetail_infoItem_item {
  398. padding-top: 12rpx;
  399. padding-bottom: 12rpx;
  400. color: #333;
  401. font-size: 30rpx;
  402. flex: 1;
  403. @include border(bottom);
  404. @include flex(flex-start, stretch, column);
  405. &.process {
  406. padding-top: 90rpx;
  407. padding-bottom: 90rpx;
  408. }
  409. &:last-of-type {
  410. border-bottom: none;
  411. }
  412. // 工单信息
  413. .orderDetail_infoItem_item_content {
  414. margin-top: 20rpx;
  415. @include flex(space-between, stretch);
  416. .orderDetail_infoItem_item_name {
  417. font-size: 34rpx;
  418. color: #666;
  419. max-width: 4em;
  420. }
  421. .orderDetail_infoItem_item_value {
  422. font-size: 38rpx;
  423. color: #333;
  424. font-weight: bold;
  425. max-width: 420rpx;
  426. text-align: justify;
  427. word-break: break-all;
  428. }
  429. }
  430. }
  431. }
  432. }
  433. }
  434. </style>