| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <template>
- <view>
- <view class="" style="width: 100%;height: 30rpx;background-color: #f7f7f7;">
- </view>
- <!-- <view class="gengxin_box" @click="update">
- <image src="../../static/image/pilianggengxin.png" mode="" class="gengxin"></image>
- <view class="gengxin_box_dian" v-if="newversion">
- </view>
- </view> -->
- <u-collapse>
- <u-collapse-item :title="item.app_version" name="Docs guide" v-for="(item,index) in versionlist"
- :key="item.app_version">
- <text class="u-collapse-content" v-for="items,indexs in item.app_message"
- :key="indexs">{{indexs+1+'、'}}{{items}}</text>
- </u-collapse-item>
- </u-collapse>
- <u-modal title="升级中请勿随意操作" :show-confirm-button="false" :show="showA" :content="contentA">
- <!-- <view class="upgradeBox"> -->
- <u-line-progress active-color="#19be6b" :percentage="percentNum" height="8"></u-line-progress>
- <!-- </view> -->
- </u-modal>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- current_version: plus.runtime.version,
- newversion: false,
- versionlist: [],
- showA: false,
- contentA: "",
- percentNum: 0,
- app_url:""
- }
- },
- watch: {
- showA(newName, oldName) {
- if(newName){
- const webView = this.$scope.$getAppWebview()
- webView.setStyle({
- titleNView: {
- autoBackButton: false
- }
- })
- }else{
- const webView = this.$scope.$getAppWebview()
- webView.setStyle({
- titleNView: {
- autoBackButton: true
- }
- })
- }
- },
- videoData(news, old) {
- console.log('触发了2222222222222222222222')
- console.log(news)
- uni.switchTab({
- url: '../response/index'
- })
- // if (news) {
- // }
- },
- },
- computed: {
- // 视频消息
- videoData() {
- return this.$store.state.video
- },
- },
- onNavigationBarButtonTap(e) {
- uni.$u.toast('更新中请勿操作')
- if (this.showA) {
- uni.$u.toast('更新中请勿操作')
- } else {
- this.update()
- }
- },
- onBackPress(options) {
- if (this.showA) {
- uni.$u.toast('更新中请勿操作')
- return true;
- 0
- }
- },
- methods: {
- async getversions() {
- const res = await this.$myRequest({
- url: '/api/api_gateway?method=app.my.get_app_history',
- data: {
- current_version: this.current_version
- }
- })
- // console.log(this.baseUrl)
- if (res.new_app.app_version) {
- this.app_url = res.new_app.app_url
- var news = res.new_app.app_version.match(/\d+/g).join("")
- var old = this.current_version.match(/\d+/g).join("")
- if (news > old) {
- this.newversion = true
- } else {
- this.newversion = false
- }
- }
- this.versionlist = res.version_list
- },
- update() {
- if (this.newversion) {
- uni.showModal({
- title: '检测到有新版本,是否更新?',
- content: '建议更新,不更新可能会出现部分数据无法获取!',
- confirmText: "更新",
- cancelText: "不更新",
- success: (res) => {
- if (res.confirm) {
- console.log('用户点击确定');
- this.showA = true
- this.upgrade()
- } else if (res.cancel) {
- // plus.runtime.quit();
- console.log('用户点击取消');
- }
- }
- })
- } else {
- uni.showToast({
- title: "当前版本已是最新版本",
- icon: "none"
- })
- }
- },
- upgrade() {
- //标准版
- // this.appName = "big_data"
-
- var url = this.baseUrl + this.app_url
- console.log(url)
- const downloadTask = uni.downloadFile({
- url: url, //仅为示例,并非真实的资源
- success: (res) => {
- console.log(res)
- if (res.statusCode === 200) {
- console.log('下载成功');
- console.log('安装包下载成功,即将安装:' + JSON.stringify(res, null, 4));
- plus.runtime.openFile(res.tempFilePath);
- this.showA = false
- }
- },
- fail: (err) => {
- console.log(err)
- },
- complete: (com) => {
- console.log(com)
- }
- });
- downloadTask.onProgressUpdate((res) => {
- this.percentNum = res.progress
- if (res.progress == 100) {
- console.log('下载完成了')
- plus.runtime.quit();
- }
- });
- }
- },
- onLoad() {
- this.getversions()
- }
- }
- </script>
- <style lang="less" scoped>
- .gengxin_box {
- width: 54rpx;
- height: 54rpx;
- position: absolute;
- top: -70rpx;
- right: 10rpx;
- z-index: 9999;
- display: flex;
- .gengxin {
- width: 44rpx;
- height: 44rpx;
- }
- .gengxin_box_dian {
- width: 10rpx;
- height: 10rpx;
- background-color: red;
- border-radius: 50%;
- margin: 0 5rpx;
- }
- }
- </style>
|