about.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <view class="box">
  3. <cu-custom bgColor="bg-blue" :isBack="true">
  4. <block slot="backText">系统设置</block>
  5. <block slot="content"></block>
  6. <block slot="right">
  7. <view class=" flex justify-center">
  8. <!-- <button class="margin-top-ssm cu-btn round bg-blue text-blue"><text class="cuIcon-add"></text></button> -->
  9. </view>
  10. </block>
  11. </cu-custom>
  12. <view class="">
  13. <view class="cu-form-group_1">
  14. <view class="title">软件版本</view>
  15. <input placeholder="软件版本" placeholder-style="color:#AEAEAE;font-size:30rpx" disabled="true" v-model="widgetInfo.version"
  16. name="input"></input>
  17. </view>
  18. <!-- #ifdef APP-PLUS -->
  19. <view class="cu-list menu">
  20. <!-- 菜单-->
  21. <view class="cu-item arrow" >
  22. <view class="content" @click="showModel">
  23. <text class="text-black ">新版本检测</text>
  24. <!-- <view v-if="tabberData.newVersion" class="cu-tag badge bg-red" style="top:8rpx;left: 2rpx;">
  25. </view> -->
  26. </view>
  27. <text style="color: red;" v-if="tabberData.newVersion">有新版</text>
  28. </view>
  29. </view>
  30. <!-- <view>
  31. cid:<input v-model="cid" />
  32. </view> -->
  33. <uni-popup ref="popup" type="center">
  34. <view class="cu-dialog">
  35. <view class="cu-bar bg-white justify-end">
  36. <view class="content">
  37. 发现新版本
  38. <text class="text-sm ">(v{{versionInfo.version}})</text>
  39. </view>
  40. <view class="action" @click="hideModel">
  41. <text class="cuIcon-close text-red"></text>
  42. </view>
  43. </view>
  44. <view class="padding-xl bg-white" style="white-space: pre-line;text-align: left;">
  45. {{versionInfo.remark}}
  46. </view>
  47. <view class="cu-bar bg-white text-center">
  48. <view class=" margin-0 flex-sub" @click="hideModel">下次再说</view>
  49. <view class=" margin-0 flex-sub solid-left text-blue" @click="toUpdate">立即更新</view>
  50. </view>
  51. </view>
  52. </uni-popup>
  53. <!-- #endif -->
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import config from "../../../core/api.js"
  59. export default {
  60. data() {
  61. return {
  62. widgetInfo:{},
  63. versionInfo:{
  64. version:'',
  65. remark:'',
  66. },
  67. cid:'',
  68. }
  69. },
  70. onLoad() {
  71. // #ifdef APP-PLUS
  72. plus.runtime.getProperty(plus.runtime.appid,(widgetInfo)=>{
  73. //console.log(widgetInfo)
  74. this.widgetInfo = widgetInfo;
  75. })
  76. // console.log("异步获取客户端推送标识信息");
  77. // plus.push.getClientInfoAsync((info)=>{
  78. // console.log('Success');
  79. // console.log(JSON.stringify(info));
  80. // this.cid = info.clientid;
  81. // }, function(e){
  82. // console.log('Failed');
  83. // console.log(JSON.stringify(e));
  84. // })
  85. // #endif
  86. },
  87. methods: {
  88. toUpdate(){
  89. // #ifdef APP-PLUS
  90. let that = this;
  91. //console.log(plus.os.name)
  92. this.http.request("/app/appversion/update",{name:this.widgetInfo.name,version:this.widgetInfo.version,platform:plus.os.name}).then((res)=>{
  93. if(res.update){
  94. //检查是否有新版本
  95. if(res.wgtUrl){
  96. //console.log(config.api)
  97. let path ='';
  98. if(res.wgtUrl.indexOf('http://') > -1 || res.wgtUrl.indexOf('https://') > -1){
  99. path = res.wgtUrl;
  100. }else{
  101. path = res.domain + '/' + res.wgtUrl;
  102. }
  103. console.log(path)
  104. //资源升级包
  105. uni.showLoading({
  106. title: '下载更新中'
  107. });
  108. uni.downloadFile({
  109. url: path,
  110. success: (downloadResult) => {
  111. if (downloadResult.statusCode === 200) {
  112. plus.runtime.install(downloadResult.tempFilePath, {
  113. force: false
  114. }, function() {
  115. uni.hideLoading();
  116. console.log('install success...');
  117. //that.$prompt.none('更新成功,软件重启');
  118. plus.runtime.restart();
  119. }, function(e) {
  120. uni.hideLoading();
  121. that.$prompt.none('更新失败');
  122. //console.error('install fail...');
  123. });
  124. }else{
  125. uni.hideLoading();
  126. that.$prompt.none('资源包状态错误');
  127. }
  128. },
  129. fail:()=>{
  130. uni.hideLoading();
  131. that.$prompt.none('下载失败');
  132. }
  133. });
  134. }else if(res.pkgUrl){
  135. let path ='';
  136. if(res.pkgUrl.indexOf('http://') > -1 ||res.pkgUrl.indexOf('https://') > -1
  137. || res.pkgUrl.indexOf('itms-apps://') > -1){
  138. path = res.pkgUrl;
  139. }else{
  140. path = config.api + "/app/appversion/download?url=" + res.pkgUrl;
  141. }
  142. //console.log(path)
  143. //整包更新
  144. if(plus.os.name=="Android"){
  145. //安卓下载更新包更新
  146. plus.runtime.openURL(path);
  147. }else if(plus.os.name=="iOS"){
  148. //iOS
  149. //this.$prompt.none('请前往App Store进行更新');
  150. plus.runtime.openURL(path)
  151. //plus.runtime.openURL(res.pkgUrl);
  152. }else{
  153. this.$prompt.none('暂无对应版本的更新包');
  154. }
  155. }
  156. }else{
  157. this.$prompt.none('已经是最新版本');
  158. }
  159. });
  160. // #endif
  161. },
  162. showModel(){
  163. // #ifdef APP-PLUS
  164. this.http.request("/app/appversion/update",{name:this.widgetInfo.name,version:this.widgetInfo.version,platform:plus.os.name}).then((res)=>{
  165. if(res.update){
  166. //console.log(res)
  167. this.versionInfo = res;
  168. this.$refs.popup.open();
  169. }else{
  170. this.$prompt.none('已经是最新版本');
  171. }
  172. });
  173. // #endif
  174. },
  175. hideModel(){
  176. //console.log('hide')
  177. this.$refs.popup.close();
  178. }
  179. }
  180. }
  181. </script>
  182. <style>
  183. .cu-form-group .title {
  184. min-width: calc(4em + 15px);
  185. }
  186. .cont {
  187. display: flex;
  188. flex-direction: row;
  189. align-items: center;
  190. justify-content: flex-end;
  191. }
  192. .login-img {
  193. width: 60rpx;
  194. height: 60rpx;
  195. }
  196. .text-black {
  197. color: #101010;
  198. }
  199. .cu-form-group_top{background-color: #fff;display: flex;align-items: center;justify-content: space-between;padding: 30rpx 24rpx;}
  200. .cu-form-group_top_right{display: flex;align-items: center;}
  201. .cu-form-group_1 {
  202. display: flex;
  203. align-items: center;
  204. padding: 0 24rpx;
  205. border-bottom: 2rpx solid #E3E1E1;
  206. height: 88rpx;
  207. background-color: #fff;
  208. }
  209. .cu-form-group_1 .title {
  210. width: 148rpx;
  211. font-size: 30rpx;
  212. color: #101010;
  213. }
  214. .cu-form-group_1 input {
  215. width: 554rpx;
  216. color: #8a8a8a;
  217. font-size: 30rpx;
  218. }
  219. .cu-form-group_2 {
  220. display: flex;
  221. background-color: #fff;
  222. padding: 22rpx 24rpx;
  223. }
  224. .cu-form-group_2 .title {
  225. width: 148rpx;
  226. font-size: 30rpx;
  227. color: #101010;
  228. }
  229. .cu-form-group_2 textarea {
  230. width: 554rpx;
  231. color: #8a8a8a;
  232. font-size: 30rpx;
  233. height: 130rpx;
  234. }
  235. .cu-list.menu>.cu-item.arrow{
  236. padding-right: 70rpx;
  237. }
  238. </style>