personalCenter.vue 13 KB

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