123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- import RequestFun from './request.js'
- import {update_url} from "../config.js"
- const platform = uni.getSystemInfoSync().platform;
- export default {
-
- getServerNo: (version, isPrompt = false, callback) => {
- let httpData = {
- version: version.versionCode,
-
- versionName: version.versionName,
-
- setupPage: isPrompt
- };
- if (platform == "android") {
- httpData.type = 1101;
- } else {
- httpData.type = 1102;
- }
-
-
-
- uni.request({
- url:update_url,
- method:'GET',
- dataType:'text',
- data:httpData,
- success: (res) => {
- let data = JSON.parse(res.data)
-
- if (data && data.downloadUrl && (parseInt(data.versionCode) > parseInt(httpData.version))) {
-
- if(update_url == "http://192.168.20.132:8070/apph5/downLoad/update.txt"){
- data.downloadUrl = data.downloadUrlTest
- data.AndriodUrl = data.AndriodUrlTest
- }
- if(parseInt(data.versionCode.substr(0,2)) > parseInt(httpData.version.substr(0,2))){
- data.downloadUrl = data.AndriodUrl
- }
- if(data.updateType){
- callback && callback(data);
- } else {
- if(data.forceUpdate){
- data.updateType = "forcibly";
- } else {
- data.updateType = "solicit";
- }
- callback && callback(data);
- }
- } else if (isPrompt) {
- uni.showToast({
- title: "暂无新版本",
- icon: "none"
- });
- }
-
- },
- fail: (error) =>{
- try{
- plus.nativeUI.toast(error.errMsg);
- }catch(e){
- plus.nativeUI.toast("连接超时,请检查您的网络~");
- }
- console.log(error)
- reject(error)
- },
- });
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- },
-
- appUpdateColor: "3489ff",
-
- appUpdateIcon: ''
- }
|