You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
3.1 KiB

3 months ago
  1. <template>
  2. <view class="app_update">
  3. <view class="logo_box">
  4. <image :src="urlDomain+'crmebimage/perset/staticImg/crmeb_java.png'"></image>
  5. <view class="title">crmeb</view>
  6. <view class="version">Version {{appUpdate.versionCode}}</view>
  7. </view>
  8. <view class="jiancha" @click="appVersionConfig()">
  9. <text>检查新版本</text>
  10. <text class="iconfont icon-you"></text>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. import {getAppVersion} from '@/api/api.js';
  16. export default {
  17. data() {
  18. return {
  19. urlDomain: this.$Cache.get("imgHost"),
  20. appUpdate:{}
  21. }
  22. },
  23. onLoad() {
  24. let that = this;
  25. plus.runtime.getProperty(plus.runtime.appid,function(inf){
  26. that.$set(that.appUpdate,'versionCode',inf.version);
  27. })
  28. },
  29. methods: {
  30. appVersionConfig(){
  31. var that = this;
  32. //app升级
  33. // 获取本地应用资源版本号
  34. getAppVersion().then(res=>{
  35. that.$set(that.appUpdate,'androidAddress',res.data.androidAddress);
  36. that.$set(that.appUpdate,'appVersion',res.data.appVersion);
  37. that.$set(that.appUpdate,'iosAddress',res.data.iosAddress);
  38. that.$set(that.appUpdate,'openUpgrade',res.data.openUpgrade);
  39. plus.runtime.getProperty(plus.runtime.appid,function(inf){
  40. let nowVersion = (inf.version).split('.').join('');
  41. let appVersion = (res.data.appVersion).split('.').join('');
  42. uni.getSystemInfo({
  43. success:(res) => {
  44. if(appVersion > nowVersion){
  45. uni.showModal({
  46. title: '更新提示',
  47. content: '发现新版本,是否前去下载?',
  48. showCancel:that.appUpdate.openUpgrade == 'false' ? true : false,
  49. cancelColor: '#eeeeee',
  50. confirmColor: '#FF0000',
  51. success(response) {
  52. if (response.confirm) {
  53. switch (res.platform){
  54. case "android":
  55. plus.runtime.openURL(that.appUpdate.androidAddress);
  56. break;
  57. case "ios":
  58. plus.runtime.openURL(encodeURI(that.appUpdate.iosAddress));
  59. break;
  60. }
  61. }
  62. }
  63. });
  64. }else if(appVersion <= nowVersion){
  65. uni.showToast({
  66. title:'已是最新版本',
  67. icon:'none'
  68. })
  69. }
  70. }
  71. })
  72. });
  73. })
  74. },
  75. }
  76. }
  77. </script>
  78. <style>
  79. .app_update{
  80. background-color: #fff;
  81. height: 100vh;
  82. }
  83. .logo_box{
  84. height: 500rpx;
  85. display: flex;
  86. flex-direction: column;
  87. justify-content: center;
  88. align-items: center;
  89. }
  90. .logo_box image{
  91. display: block;
  92. margin-top:80rpx;
  93. width: 120rpx;
  94. height: 120rpx;
  95. border-radius: 50%;
  96. }
  97. .title{
  98. font-size: 34rpx;
  99. font-family: PingFang SC;
  100. font-weight: 600;
  101. color: #333333;
  102. margin: 20rpx auto 20rpx;
  103. }
  104. .version{
  105. font-size: 28rpx;
  106. font-family: PingFang SC;
  107. font-weight: 500;
  108. color: #333333;
  109. }
  110. .jiancha{
  111. width: 690rpx;
  112. margin: 20rpx auto 0;
  113. padding: 0 20rpx 0;
  114. height: 100rpx;
  115. line-height: 100rpx;
  116. color: #333333;
  117. font-size: 30rpx;
  118. border-top:1px solid #f5f5f5;
  119. border-bottom:1px solid #f5f5f5;
  120. display: flex;
  121. justify-content: space-between;
  122. }
  123. </style>