center.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <view class="container">
  3. <view class="head">
  4. <u-navbar :is-fixed="false" :border-bottom="false" :is-back="false" title="个人中心"
  5. :background="{ background: 'transprent' }" title-color="#FFFFFF">
  6. </u-navbar>
  7. <!-- 用户信息 -->
  8. <view class="user-box">
  9. <view class="left" style="width: 60%;">
  10. <view style="display: flex;flex-direction: row;width: 100%;">
  11. <view style="display: flex;flex-direction: column;justify-content: center;">
  12. <image :src="userInfo.avatar" class="avatar" mode=""></image>
  13. <view class="user-name">{{ userInfo.nick_name }}</view>
  14. </view>
  15. </view>
  16. <view style="display: flex;flex-direction: row;width: 100%;color: #F0F0F0;">
  17. {{roleName}}/{{deptName}}
  18. </view>
  19. </view>
  20. <view style="display: flex;flex-direction: column;justify-content: flex-end;">
  21. <view @click="$u.func.route('/pages/user/profile')" class="edit-btn">编辑资料</view>
  22. </view>
  23. </view>
  24. </view>
  25. <!-- 功能列表 -->
  26. <view class="cell-box">
  27. <u-cell-group :border="false">
  28. <u-cell-item title="修改密码" :border-bottom="false" @click="$u.func.route('/pages/user/modify-password')">
  29. <image slot="icon" src="/static/images/user/c8.png" class="icon" mode=""></image>
  30. </u-cell-item>
  31. </u-cell-group>
  32. </view>
  33. <view class="cell-box">
  34. <u-cell-group :border="false">
  35. </u-cell-group>
  36. </view>
  37. <!-- <view class="cell-box">
  38. <u-cell-group :border="false">
  39. <u-cell-item title="检查更新" :border-bottom="false" @click="checkVersion">
  40. <image slot="icon" src="/static/images/news/search.png" class="icon" mode=""></image>
  41. </u-cell-item>
  42. </u-cell-group>
  43. </view> -->
  44. <view class="cell-box">
  45. <u-cell-group :border="false">
  46. <u-cell-item title="关于" :border-bottom="false" @click="$u.func.route('/pages/user/about')">
  47. <image slot="icon" src="/static/images/user/c7.png" class="icon" mode=""></image>
  48. </u-cell-item>
  49. </u-cell-group>
  50. </view>
  51. <u-gap height="50"></u-gap>
  52. <view class="cell-box">
  53. <u-cell-group :border="false">
  54. <button type="warn" @click="logout()">退出登录</button>
  55. </u-cell-group>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import http from '@/http/api.js'
  61. export default {
  62. onLoad() {
  63. console.log(this.userInfo.nick_name)
  64. const that = this;
  65. http.request({
  66. url: '/galaxy-system/dept/detail?id=' + this.userInfo.dept_id,
  67. method: 'GET'
  68. }).then(res => {
  69. console.log(JSON.stringify(res.data))
  70. that.deptName = res.data.deptName;
  71. }).catch(err => {
  72. console.log(err)
  73. })
  74. http.request({
  75. url: '/galaxy-system/role/select?roleId=' + this.userInfo.role_id,
  76. method: 'GET'
  77. }).then(res => {
  78. console.log(JSON.stringify(res.data))
  79. var name = "";
  80. res.data.forEach(info => {
  81. name += name.length > 0 ? ":" : "";
  82. name += info.roleName;
  83. })
  84. that.roleName = name;
  85. }).catch(err => {
  86. console.log(err)
  87. })
  88. },
  89. data() {
  90. return {
  91. roleName: '',
  92. deptName: '',
  93. downloadurl: '',
  94. };
  95. },
  96. methods: {
  97. logout() {
  98. this.$u.func.logout();
  99. },
  100. checkVersion() {
  101. // #ifdef APP-PLUS
  102. let that = this;
  103. let postData = {};
  104. postData['appId'] = plus.runtime.appid;
  105. postData['version'] = plus.runtime.version;
  106. http.request({
  107. url: '/galaxy-business/version/check',
  108. method: 'GET',
  109. data: postData,
  110. }).then(res => {
  111. console.log(JSON.stringify(res))
  112. if (res.data != null) {
  113. if (res.data.updateStatus == 1) {
  114. that.downloadurl = res.data.apkUrl;
  115. uni.showModal({
  116. title: "版本检查",
  117. content: "有新的APP版本需要更新",
  118. success: (res) => {
  119. if (res.confirm) {
  120. that.updateApp();
  121. }
  122. },
  123. })
  124. } else {
  125. uni.showModal({
  126. title: "提示",
  127. content: "当前已是最新版本!",
  128. showCancel: false,
  129. success: (res) => {
  130. }
  131. })
  132. }
  133. }
  134. }).catch(err => {
  135. console.log(err)
  136. })
  137. // #endif
  138. },
  139. updateApp() {
  140. // #ifdef APP-PLUS
  141. let task = plus.downloader.createDownload(this.downloadurl, {},
  142. function(d, status) {
  143. //下载完成
  144. if (status == 200) {
  145. var path = plus.io.convertLocalFileSystemURL(d
  146. .filename);
  147. plus.runtime.install(path, {}, function() {
  148. plus.nativeUI.closeWaiting();
  149. uni.showModal({
  150. title: "更新提示",
  151. content: "安装已完成,APP需重新启动!",
  152. showCancel: false,
  153. success: (res) => {
  154. plus.runtime.restart();
  155. }
  156. })
  157. }, function(e) {
  158. uni.showModal({
  159. title: "更新提示",
  160. content: "版本更新失败[" + e.code + "]:" + e.message,
  161. mask: false,
  162. duration: 1500,
  163. })
  164. })
  165. } else {
  166. uni.showModal({
  167. title: "更新提示",
  168. content: "下载安装包文件失败!",
  169. mask: false,
  170. duration: 1500,
  171. })
  172. }
  173. }
  174. )
  175. task.addEventListener("statechanged", function(download, status) {
  176. switch (download.state) {
  177. case 1:
  178. loadingDig.setTitle("开始下载");
  179. break;
  180. case 2:
  181. loadingDig.setTitle("已连接");
  182. break;
  183. case 3:
  184. //if (undefined != task.downloadedSize && null != task.downloadedSize && parseFloat(task
  185. // .downloadedSize) > 0.0) {
  186. // let prg = parseInt((parseFloat(task
  187. // .downloadedSize) /
  188. // parseFloat(task.totalSize)
  189. // ) *
  190. // 100.0);
  191. // if (undefined != prg && null != prg && (prg >= 0.0 && prg <= 100.0)) {
  192. // loadingDig.setTitle("安装包下载 " + prg + "%");
  193. // }
  194. loadingDig.setTitle("安装包下载中...");
  195. break;
  196. case 4:
  197. plus.nativeUI.closeWaiting();
  198. break;
  199. }
  200. })
  201. task.start();
  202. var loadingDig = plus.nativeUI.showWaiting("开始下载安装包");
  203. // #endif
  204. }
  205. }
  206. };
  207. </script>
  208. <style lang="scss">
  209. .container {
  210. background-color: #f7f7f7;
  211. min-height: 100vh;
  212. overflow: hidden;
  213. }
  214. .head {
  215. position: relative;
  216. top: 0;
  217. left: 0;
  218. z-index: 1;
  219. // min-height: 582rpx;
  220. min-height: 400rpx;
  221. overflow: hidden;
  222. background: #3F9EFF;
  223. .set-icon {
  224. vertical-align: middle;
  225. width: 41rpx;
  226. height: auto;
  227. margin-right: 35rpx;
  228. }
  229. .head-bg {
  230. position: absolute;
  231. left: 0px;
  232. top: 0px;
  233. z-index: -1;
  234. width: 750rpx;
  235. height: 582rpx;
  236. background: #0bb9c8;
  237. }
  238. }
  239. .user-box {
  240. display: flex;
  241. justify-content: space-between;
  242. padding: 0 20rpx 0 64rpx;
  243. margin-top: 36rpx;
  244. .left {
  245. display: flex;
  246. flex-direction: column;
  247. align-items: center;
  248. .avatar {
  249. width: 128rpx;
  250. height: 128rpx;
  251. background: #ffffff;
  252. border-radius: 50%;
  253. }
  254. .user-name {
  255. margin-top: 20rpx;
  256. font-size: 36rpx;
  257. font-family: Source Han Sans CN;
  258. font-weight: 500;
  259. color: #ffffff;
  260. }
  261. .tag {
  262. margin-top: 20rpx;
  263. display: flex;
  264. justify-content: center;
  265. align-items: center;
  266. padding: 5rpx 16rpx;
  267. border: 1px solid #f5f5f5;
  268. border-radius: 7rpx;
  269. font-size: 19rpx;
  270. font-family: Source Han Sans CN;
  271. font-weight: 300;
  272. color: #ffffff;
  273. }
  274. }
  275. .edit-btn {
  276. margin-top: 20rpx;
  277. margin-bottom: 10px;
  278. flex-shrink: 0;
  279. display: flex;
  280. justify-content: center;
  281. align-items: center;
  282. width: 165rpx;
  283. height: 54rpx;
  284. border: 2rpx solid #f5f5f5;
  285. border-radius: 11rpx;
  286. font-size: 27rpx;
  287. font-family: Source Han Sans CN;
  288. font-weight: 400;
  289. color: #ffffff;
  290. }
  291. }
  292. .nav {
  293. display: flex;
  294. //border-top: 2rpx solid #7dcdd6;
  295. margin: 36rpx 38rpx 0;
  296. padding: 36rpx 0 42rpx;
  297. .nav-item {
  298. width: calc(100% / 4);
  299. display: flex;
  300. flex-direction: column;
  301. align-items: center;
  302. justify-content: space-between;
  303. font-size: 25rpx;
  304. font-family: Source Han Sans CN;
  305. font-weight: 400;
  306. color: #ffffff;
  307. &:not(:last-of-type) {
  308. position: relative;
  309. &::after {
  310. position: absolute;
  311. right: 0;
  312. top: 50%;
  313. transform: translateY(-50%);
  314. content: '';
  315. display: block;
  316. width: 2rpx;
  317. background-color: #3ac4d1;
  318. height: 30rpx;
  319. }
  320. }
  321. .icon {
  322. width: 48rpx;
  323. height: 48rpx;
  324. margin-bottom: 6rpx;
  325. }
  326. }
  327. }
  328. .cell-box {
  329. background: #ffffff;
  330. margin: 18rpx;
  331. .icon {
  332. width: 32rpx;
  333. height: 32rpx;
  334. margin-right: 22rpx;
  335. }
  336. }
  337. </style>