me.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view style="height:calc(100vh - 96px)">
  3. <view style="padding: 20rpx;">
  4. <view
  5. style="width: 100%;height: 20vh;border-radius: 10rpx;box-shadow: 0 0px 20px #b1b1b1;background-color: #fff;">
  6. <view style="display: flex;padding: 60rpx 40rpx 0;">
  7. <u-avatar src="/static/logo.png"></u-avatar>
  8. <view style="margin-left: 40rpx;;">
  9. <view style="font-size: 34rpx;font-weight: bold">
  10. {{userInfo.nickName}}
  11. </view>
  12. <view style="font-size: 30rpx;margin-top: 10rpx;">
  13. {{userInfo.dept.deptName}}
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. <view style="margin-top: 40rpx;background-color: #fff;">
  20. <u-cell-group>
  21. <u-cell icon="reload" title="检查更新" :value="version" isLink :iconStyle="{color:'#409EFF'}"
  22. @click="needUpdateApp(true)"></u-cell>
  23. <!-- <view style="height: 40rpx;background-color: #f5f5f5;"></view> -->
  24. <u-cell icon="arrow-rightward" title="退出登录" isLink :iconStyle="{color:'#409EFF'}" @click="out"></u-cell>
  25. </u-cell-group>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. userInfo: uni.getStorageSync('userInfo'),
  34. version: null
  35. }
  36. },
  37. onLoad() {
  38. this.needUpdateApp(false)
  39. },
  40. methods: {
  41. out() {
  42. uni.showModal({
  43. title: "提示",
  44. content: "是否要退出",
  45. success(res) {
  46. if (res.confirm) {
  47. uni.clearStorageSync()
  48. uni.reLaunch({
  49. url: "/pages/login/login"
  50. })
  51. }
  52. }
  53. })
  54. },
  55. //升级
  56. needUpdateApp(i) {
  57. var _this = this;
  58. console.log(getApp().globalData.updateUrl)
  59. plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
  60. if (i == true) {
  61. uni.showLoading({
  62. title: "检查中...",
  63. mask: true
  64. })
  65. uni.$u.http.post('/app/version/advance/' + wgtinfo.versionCode).then(res => {
  66. if (res.code == 200) {
  67. if (res.data != undefined) {
  68. uni.hideLoading()
  69. uni.showModal({
  70. title: "提示",
  71. content: "有新版本是否进行更新",
  72. success(qwe) {
  73. if (qwe.confirm) {
  74. _this.upgradeApp(getApp().globalData.updateUrl +
  75. res.data.url)
  76. }
  77. }
  78. })
  79. } else {
  80. uni.hideLoading()
  81. uni.showToast({
  82. title: "当前为最新版本",
  83. icon: "none"
  84. })
  85. }
  86. }
  87. }).catch(res => {
  88. uni.hideLoading()
  89. })
  90. } else {
  91. _this.version = wgtinfo.version
  92. }
  93. })
  94. },
  95. upgradeApp(url) {
  96. uni.showLoading({
  97. title: '更新中……'
  98. });
  99. uni.downloadFile({
  100. url: url,
  101. success: downloadResult => {
  102. if (downloadResult.statusCode === 200) {
  103. try {
  104. var filePath = downloadResult.tempFilePath;
  105. var ext = filePath.substring(
  106. filePath.lastIndexOf('.') + 1
  107. );
  108. plus.runtime.install(
  109. downloadResult.tempFilePath, {},
  110. function() {
  111. uni.hideLoading()
  112. plus.runtime.restart();
  113. },
  114. function(e) {
  115. uni.hideLoading()
  116. uni.showToast({
  117. title: "更新失败",
  118. icon: "none"
  119. })
  120. }
  121. );
  122. } catch (e) {
  123. uni.hideLoading()
  124. }
  125. } else {
  126. uni.hideLoading()
  127. uni.showToast({
  128. title: "下载失败",
  129. icon: 'none'
  130. })
  131. }
  132. },
  133. fail: res => {
  134. uni.hideLoading()
  135. uni.showToast({
  136. title: "下载失败",
  137. icon: 'none'
  138. })
  139. }
  140. });
  141. }
  142. }
  143. }
  144. </script>
  145. <style>
  146. </style>