about.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <view>
  3. <view class="line"></view>
  4. <view class="logo-box">
  5. <image :src="$imageURL+ '/bigdata_app'+'/image/c9b4eb88c03b2f7460e8479e80f40fc.png'" mode="widthFix" v-if="$isneutral"></image>
  6. <view class="version">
  7. <view v-if="$isneutral">
  8. 云飞物联网
  9. </view>
  10. <view>
  11. 当前版本号
  12. </view>
  13. <view>
  14. V{{id}}
  15. </view>
  16. </view>
  17. </view>
  18. <view class="line"></view>
  19. <view class="part" v-if="$isneutral">
  20. <view class="info-item">
  21. <text class="tit">技术支持</text>
  22. <text class="val">河南云飞科技发展有限公司</text>
  23. </view>
  24. <view class="divide"></view>
  25. <view class="info-item">
  26. <text class="tit">关注微信</text>
  27. <text class="val">河南云飞科技发展有限公司</text>
  28. </view>
  29. </view>
  30. <view class="line" v-if="$isneutral"></view>
  31. <view class="part" v-if="$isneutral">
  32. <view class="info-item">
  33. <text class="tit">公司官网</text>
  34. <text class="val">www.hnyfkj.cn</text>
  35. </view>
  36. <view class="divide"></view>
  37. <view class="info-item">
  38. <text class="tit">业务合作</text>
  39. <text class="val">400-690-7990</text>
  40. </view>
  41. <view class="divide"></view>
  42. <view class="info-item">
  43. <text class="tit">公司邮箱</text>
  44. <text class="val">hnyf826@163.com</text>
  45. </view>
  46. </view>
  47. <view class="line"></view>
  48. <view class="part">
  49. <view class="info-item" @click="renewal">
  50. <text class="tit" >版本更新</text>
  51. <p class="update" v-if="updateTF">NEW</p>
  52. <u-icon name="arrow-right"></u-icon>
  53. </view>
  54. </view>
  55. <view class="line" v-if="$isneutral"></view>
  56. <view class="record">
  57. <view class="info-item" @click="record">
  58. <text class="tit">更新记录</text>
  59. <u-icon name="arrow-right"></u-icon>
  60. </view>
  61. </view>
  62. <view class="bottom" v-if="$isneutral">
  63. ©河南云飞科技发展有限公司
  64. </view>
  65. <u-modal title="升级中请勿随意操作" :show-confirm-button="false" v-model="showA" :content="contentA">
  66. <view class="upgradeBox">
  67. <u-line-progress v-show="isShow" active-color="#19be6b" :striped="true" :percent="percentNum" :striped-active="true"></u-line-progress>
  68. </view>
  69. </u-modal>
  70. </view>
  71. </template>
  72. <script>
  73. export default {
  74. data() {
  75. return {
  76. id: '',
  77. versions: '',
  78. showA: false, //
  79. contentA: '',
  80. isShow: false, //进度条
  81. percentNum: 0, //在线下载进度,
  82. apkPath: "", //已下载待安装的更新包路径
  83. value: "",
  84. updateTF:false
  85. }
  86. },
  87. methods: {
  88. async getEquipList() {
  89. const res = await this.$myRequest({
  90. url: '/api/api_gateway?method=home.homes.app_version_record',
  91. data: {
  92. ret: "first"
  93. }
  94. })
  95. console.log(res)
  96. // this.appName = res[0].app_name
  97. this.versions = Number(res[0].app_num.match(/\d+/g).join(""))
  98. var ids = Number(plus.runtime.version.match(/\d+/g).join(""))
  99. if (this.versions > ids) {
  100. this.updateTF = true
  101. } else {
  102. this.updateTF = false
  103. }
  104. },
  105. renewal() {
  106. // this.getEquipList()
  107. var ids = Number(plus.runtime.version.match(/\d+/g).join(""))
  108. if (this.percentNum > 0) {
  109. console.log("更新中")
  110. } else {
  111. if (this.versions > ids) {
  112. this.updateTF = true
  113. uni.showModal({
  114. title: '检测到有新版本,是否更新?',
  115. content: '建议更新,不更新可能会出现部分数据无法获取!',
  116. confirmText: "更新",
  117. cancelText: "不更新",
  118. success: (res) => {
  119. if (res.confirm) {
  120. console.log('用户点击确定');
  121. this.showA = true
  122. this.isShow = true
  123. this.upgrade()
  124. } else if (res.cancel) {
  125. // plus.runtime.quit();
  126. console.log('用户点击取消');
  127. }
  128. }
  129. })
  130. } else {
  131. this.updateTF = false
  132. uni.showToast({
  133. title: "当前版本已是最新版本",
  134. icon: "none"
  135. })
  136. }
  137. }
  138. },
  139. upgrade() {
  140. uni.getStorage({
  141. key: 'http',
  142. success: (res) => {
  143. this.value = res.data
  144. }
  145. })
  146. // console.log(this.appName)
  147. // ---------------------------------------------------------------------------------------------------------------------------
  148. if(this.$isneutral){
  149. this.appName = "big_data"//标准版
  150. }else{
  151. this.appName = "big_data2"//中性版
  152. }
  153. // this.appName = "big_data"
  154. var url = "http://hnyfwlw.com/app/" + this.appName + ".apk"
  155. console.log(url)
  156. const downloadTask = uni.downloadFile({
  157. url: url, //仅为示例,并非真实的资源
  158. success: (res) => {
  159. console.log(res)
  160. if (res.statusCode === 200) {
  161. console.log('安装包下载成功,即将安装:' + res.tempFilePath);
  162. this.installApk(res.tempFilePath)
  163. this.showA = false
  164. this.isShow = false
  165. }
  166. },
  167. fail: (err) => {
  168. console.log(err)
  169. },
  170. complete: (com) => {
  171. console.log(com)
  172. }
  173. });
  174. downloadTask.onProgressUpdate((res) => {
  175. this.percentNum = res.progress
  176. if (res.progress == 100) {
  177. console.log('下载完成了')
  178. }
  179. });
  180. },
  181. // 调起系统安装器安装更新包,失败时引导开启“安装未知应用”后自动重试一次
  182. // fromGuide:从系统设置页返回后的重试,不再引导,直接提示失败原因
  183. installApk(path, fromGuide) {
  184. this.apkPath = '';
  185. plus.runtime.install(path, { force: false }, () => {
  186. console.log('已调起安装')
  187. }, (e) => {
  188. console.log('安装失败:', e)
  189. // Android 8.0 及以上需用户在系统设置中开启“允许安装未知应用”,
  190. // 该权限属于特殊权限,系统不会弹窗申请,只能引导用户到设置页手动开启。
  191. // 注意:不做安装前预检查,部分机型(如小米)已授权时检查接口仍返回未授权
  192. if (!fromGuide && plus.os.name === 'Android' && parseFloat(plus.os.version) >= 8) {
  193. this.apkPath = path;
  194. uni.showModal({
  195. title: '需要安装权限',
  196. content: '请在接下来打开的页面中,允许本应用“安装未知应用”',
  197. showCancel: false,
  198. success: () => {
  199. var main = plus.android.runtimeMainActivity();
  200. var Intent = plus.android.importClass('android.content.Intent');
  201. var Uri = plus.android.importClass('android.net.Uri');
  202. var intent = new Intent('android.settings.MANAGE_UNKNOWN_APP_SOURCES');
  203. intent.setData(Uri.parse('package:' + main.getPackageName()));
  204. main.startActivity(intent);
  205. }
  206. })
  207. } else {
  208. uni.showModal({
  209. title: '安装失败',
  210. content: '若已开启“安装未知应用”仍失败,小米手机请检查系统“纯净模式”等安装限制后重新更新',
  211. showCancel: false
  212. })
  213. }
  214. })
  215. },
  216. record() {
  217. uni.navigateTo({
  218. url: "../record/record"
  219. })
  220. }
  221. },
  222. onShow() {
  223. // 从“安装未知应用”设置页返回后,继续安装已下载的更新包
  224. if (this.apkPath) {
  225. this.installApk(this.apkPath, true)
  226. }
  227. this.id = plus.runtime.version
  228. this.getEquipList()
  229. },
  230. onBackPress(option) {
  231. uni.redirectTo({
  232. url: "../index/index"
  233. })
  234. }
  235. }
  236. </script>
  237. <style lang="scss">
  238. page {
  239. background: $uni-bg-color-grey;
  240. }
  241. .line {
  242. height: 16rpx;
  243. width: 100%;
  244. background: $uni-bg-color-grey;
  245. }
  246. .bottom {
  247. height: 190rpx;
  248. line-height: 190rpx;
  249. font-size: 8px;
  250. text-align: center;
  251. }
  252. .logo-box {
  253. background: #fff;
  254. text-align: center;
  255. padding: 80rpx 0;
  256. image {
  257. width: 150rpx;
  258. }
  259. .version {
  260. font-size: 24rpx;
  261. margin-top: 20rpx;
  262. }
  263. }
  264. .part {
  265. background: #fff;
  266. padding: 0 40rpx;
  267. .divide {
  268. width: 100%;
  269. height: 1px;
  270. background: $uni-bg-color-grey;
  271. }
  272. .info-item {
  273. display: flex;
  274. justify-content: space-between;
  275. line-height: 100rpx;
  276. position: relative;
  277. .tit {
  278. font-size: 14px
  279. }
  280. .val {
  281. font-size: 12px;
  282. color: #666;
  283. }
  284. .update{
  285. position: absolute;
  286. top: 34rpx;
  287. right: 32rpx;
  288. font-size: 16rpx !important;
  289. background-color: #f00;
  290. border-radius: 25rpx;
  291. height: 30rpx;
  292. padding: 2rpx 16rpx;
  293. line-height: 30rpx;
  294. color: #fff;
  295. }
  296. }
  297. }
  298. .record {
  299. background: #fff;
  300. padding: 0 40rpx;
  301. .info-item {
  302. display: flex;
  303. justify-content: space-between;
  304. line-height: 100rpx;
  305. .tit {
  306. font-size: 14px
  307. }
  308. }
  309. }
  310. .upgradeBox {
  311. padding: 15rpx;
  312. }
  313. </style>