me.vue 3.4 KB

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