qq_41295110
2025-07-22 ed9e939e595003a3044d45b0860ceb2ca77b9723
版本更新功能
5个文件已修改
129 ■■■■■ 已修改文件
README.md 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
manifest.json 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/index/index.vue 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/index/mine.vue 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/index/vers.vue 103 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
README.md
@@ -26,3 +26,4 @@
添加功能模块:
测试数据:生产领料(MATO00048891),
manifest.json
@@ -2,8 +2,8 @@
    "name" : "智云LMES",
    "appid" : "__UNI__B002F49",
    "description" : "",
    "versionName" : "1.0.16",
    "versionCode" : 116,
    "versionName" : "1.0.17",
    "versionCode" : 117,
    "transformPx" : false,
    /* 5+App特有相关 */
    "app-plus" : {
@@ -45,7 +45,8 @@
                    "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
                    "<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
                    "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
                ]
                ],
                "abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ]
            },
            /* ios打包配置 */
            "ios" : {
pages/index/index.vue
@@ -9,11 +9,17 @@
                </view>
            </view>
        </view>
        <vers></vers>
    </view>
</template>
<script>
    import vers from './vers.vue';
    export default {
        components: {
            vers
        },
        data() {
            return {
                serverUrl: uni.getStorageSync('serverUrl') || 'http://47.96.97.237/API',
pages/index/mine.vue
@@ -180,5 +180,17 @@
        font-size: 36rpx;
        text-align: center;
    }
    .vers{
        position: fixed;
        z-index: 99;
        bottom: 0;
        left: 0;
        font-size: 28rpx;
        color: #888;
        margin-bottom: 20rpx;
        text-align: center;
        width: 100%;
    }
}
</style>
pages/index/vers.vue
@@ -20,7 +20,7 @@
export default {
  data() {
    return {
        serverUrl: 'https://api.zj-yonghutong.com',
        serverUrl: uni.getStorageSync('serverUrl')||'http://47.96.97.237/API',
        showTc:false,
        // 版本更新
        loadPercent:0,
@@ -38,83 +38,38 @@
    if(uni.getSystemInfoSync().platform !=='ios'){
        this.update();
    }else if(uni.getSystemInfoSync().platform =='ios'){
        this.updateIOS();
        uni.showToast({
            title:'请使用安卓手机,以免发生兼容性问题',
            icon:'none'
        })
    }
    //#endif
  },
  methods: {
    updateIOS() {
        var _this = this;
        uni.request({
            url: 'https://api.zj-yonghutong.com/v1/config/configKeyObject/APPVersionIOS',
            header: {
                'Authorization': 'Bearer ' + getToken(),
                'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
            },
            method: 'GET',
            success: result => {
                console.log(result)
                if (result.data.code == 200) {
                    uni.setStorageSync('remarkURL',result.data.data.remark)
                    plus.runtime.getProperty(plus.runtime.appid, function(inf) {
                        console.log(inf)
                        uni.setStorageSync('vers',inf.version)
                        _this.vers = result.data.data.configValue
                        if(result.data.data.configValue > inf.versionCode){ //如果线上版本大于当前版本
                            var configType = result.data.data.fieldOne //当前线上最新整包版本
                            _this.fieldTwo = result.data.data.fieldTwo//更新内容
                            if(configType > inf.versionCode ){//如果线上最新整包版本大于当前版本,则整包更新
                                _this.showTc = true
                                console.log(555555)
                            }else{//热更新
                                uni.showLoading({
                                    title:'发现新资源,正在下载中...',
                                    mask:true,
                                })
                                uni.downloadFile({
                                    url: 'https://api.zj-yonghutong.com/profile/kangleju.wgt',
                                    success: (downloadResult) => {
                                        if (downloadResult.statusCode === 200) {
                                            uni.hideLoading()
                                            plus.runtime.install(downloadResult.tempFilePath, {
                                                force: false
                                            }, function() {
                                                console.log('install success...');
                                                plus.runtime.restart();
                                            }, function(e) {
                                                console.error('install fail...');
                                            });
                                        }
                                    }
                                });
                            }
                        }
                    });
                }
            },
        })
    },
    update() {
        var _this = this;
        uni.request({
            url:'https://api.zj-yonghutong.com/v1/config/configKeyObject/APPVersion',
            header: {
                'Authorization': 'Bearer ' +  getToken(),
                // 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
            },
            method: 'GET',
            url:_this.serverUrl + '/LMES/AppUpdate',
            data: { type:'' },
            success: result => {
                if (result.data.code == 200) {
                    // console.log(1111111,result)
                    uni.setStorageSync('remarkURL',result.data.data.remark)
                console.log(1111111,result)
                // "DowloadPath": 整包更新下载地址,
                // "HotDowloadPath": 最新热更新下载地址,
                // "VersionNumber": "最新整包版本",
                // "HotVersionNumber": "最新版本",
                // "Content": ""
                if (result.data.count == 1) {
                    var datas = result.data.data[0]
                    uni.setStorageSync('remarkURL',datas.DowloadPath)
                    plus.runtime.getProperty(plus.runtime.appid, function(inf) {
                        console.log(inf)
                        _this.vers = result.data.data.configValue
                        _this.vers = datas.HotVersionNumber
                        uni.setStorageSync('vers','V' + inf.version)
                        if(result.data.data.configValue > inf.versionCode){ //如果线上版本大于当前版本
                            var configType = result.data.data.fieldOne //当前线上最新整包版本
                            _this.fieldTwo = result.data.data.fieldTwo//更新内容
                            if(configType > inf.versionCode ){//如果线上最新整包版本大于当前版本,则整包更新
                        console.log(datas.HotVersionNumber,inf.versionCode,datas.HotVersionNumber > inf.versionCode)
                        if(datas.HotVersionNumber > inf.versionCode){
                            var configType = datas.VersionNumber
                            _this.fieldTwo = datas.Content
                            if(configType > inf.versionCode ){
                                _this.showTc = true
                                console.log(configType,_this.showTc,_this.fieldTwo)
                            }else{
@@ -123,7 +78,7 @@
                                    mask:true,
                                })
                                uni.downloadFile({
                                    url: 'https://api.zj-yonghutong.com/profile/kangleju.wgt',
                                    url: datas.HotDowloadPath,
                                    success: (downloadResult) => {
                                        if (downloadResult.statusCode === 200) {
                                            uni.hideLoading()
@@ -146,12 +101,8 @@
        })
    },
    upOn(){
        if(uni.getSystemInfoSync().platform !=='ios'){
            this.doUpData();
            this.loadPercent = 0
        }else if(uni.getSystemInfoSync().platform =='ios'){
            plus.runtime.openURL(uni.getStorageSync('remarkURL'));
        }
        this.doUpData();
        this.loadPercent = 0
    },
    doUpData() {
        this.waitLine = true
@@ -236,9 +187,9 @@
        width: 550rpx;
        height: 730rpx;
        position: absolute;
        top: 10vh;
        top: 20vh;
        left: 100rpx;
        background-image: url('../../../static/images/newVer.png');
        background-image: url('/static/images/newVer.png');
        background-position: center;
        background-repeat: no-repeat;
        background-size: cover;