Browse Source

更新部分

hi 3 ngày trước cách đây
mục cha
commit
e1501495f7
6 tập tin đã thay đổi với 125 bổ sung36 xóa
  1. 1 2
      App.vue
  2. 4 0
      common/request/apis/index.js
  3. 48 30
      common/store/modules/update.js
  4. 1 1
      env.js
  5. 1 1
      pages/index/app-update.vue
  6. 70 2
      pages/index/index.vue

+ 1 - 2
App.vue

@@ -4,13 +4,12 @@
 export default {
 	onLaunch(options) {
 		
-	
+		console.log('onLaunch')
 		// 检测客户端更新
 		this.$store.dispatch('update/update', 0)
 	},
 	onShow() {
 		// #ifdef APP-PLUS
-		console.log('initScan')
 		this.initScan();
 		this.startScan();
 		this.setBROADCAST()

+ 4 - 0
common/request/apis/index.js

@@ -2,5 +2,9 @@
 export const bannerList = (params, config = {}) => uni.$u.http.get(`/1`, {params, config, custom: { auth: false }})
 // 
 export const Openid = (params, config = {custom: { auth: true }}) => uni.$u.http.post(`/2`, params, config)
+// 监测更新
+export const selectVersion = (params, config) => uni.$u.http.get(`/pda/selectVersion`, params, )
+// 下载apk包
+export const downloadApk = (params, config = {custom: { auth: false }}) => uni.$u.http.post(`/pda/downloadApk`, params, config)
 
 

+ 48 - 30
common/store/modules/update.js

@@ -2,6 +2,8 @@
  * 系统更新 - 后续版本更新
  **/
 import Vue from 'vue';
+
+import { selectVersion } from '@/common/request/apis/index'
 // import { getappdownload } from '@/common/request/apis/h5'
 // import { checkUpdate } from '@/common/utils/app-update-check';
 
@@ -9,7 +11,7 @@ export default {
 	namespaced: true,
 	// 储存数据
 	state: {
-		update: false,
+		update: uni.getStorageSync("update") || false,
 		data: {},
 		link: {},
 		download: {
@@ -20,13 +22,19 @@ export default {
 			totalBytesWritten: 0,
 			totalBytesExpectedToWrite: 0,
 		},
-		task: null
+		task: null,
+		isUpdate:false
 	},
 	// 修改数据
 	mutations: {
 		edit(state, {data, index}){
 			state[index] = data;
-		}
+		},
+		// 检查更新
+		setUpdate(state, data) {
+			state.update = data;
+			uni.setStorageSync('update', data);
+		},
 	},
 	actions: {
 		async update({commit, dispatch}, type) {
@@ -56,38 +64,48 @@ export default {
 			
 			// #ifdef APP-PLUS
 			const system_info = uni.getSystemInfoSync();
+			console.log(system_info,'system')
+			console.log(system_info.appVersion,'appVersion')
 			let params = {
 				os: system_info.platform //本机设备操作系统  (android || ios)
 			};
 			if (params.os != 'ios' && params.os != 'android') false; //如果不是安卓或ios 返回false
-					
+			selectVersion()
+			.then(res=>{
+				if(system_info.appVersion != res.data.version) {
+					commit('setUpdate',true)
+					console.log(state.update,'res')
+				}else {
+					commit('setUpdate',false)
+				}
+			})
 			//这里自行请求API获取版本信息 建议传入操作系统标识,返回本机对应的操作系统最新版本信息,也就是安卓的返回就是安卓的版本信息  ios返回就是ios的版本信息
-			getappdownload()
-				.then(res => {
-					let versionInfo = res.data.version;
-					if (versionInfo&&versionInfo.downloadurl) {
-						let update_info = {
-							version: params.os == 'ios' ? versionInfo.newversion : versionInfo.newversion, //线上版本
-							now_url: params.os == 'ios' ? versionInfo.downloadurl : versionInfo.downloadurl, //更新链接
-							silent: versionInfo.silent ? versionInfo.silent : 0, //是否是静默更新
-							force: versionInfo.enforce, //是否是强制更新
-							net_check: versionInfo.net_check ? versionInfo.net_check : 1, //非WIfi是否提示
-							note: versionInfo.content //更新内容
-						};
-						checkUpdate(update_info, type).then(res => {
-							if (res.msg) {
-								if(type){
-									uni.$u.toast(res.msg)
-								}
-							}
-						}); ///检查更新
-					}
-					//checkUpdate 这个方法会做什么?:线上版本号 与 本地版本号做对比 ,如果需要更新  根据静默,强制、wifi等信息执行静默更新或跳转到升级页面
-					//跳转升级页面的前提是,需要新建并在pages.json中配置升级页面,配置方法请查看插件详情
-				})
-				.catch(err => {
-					uni.$u.toast(err.msg);
-				});
+			// getappdownload()
+			// 	.then(res => {
+			// 		let versionInfo = res.data.version;
+			// 		if (versionInfo&&versionInfo.downloadurl) {
+			// 			let update_info = {
+			// 				version: params.os == 'ios' ? versionInfo.newversion : versionInfo.newversion, //线上版本
+			// 				now_url: params.os == 'ios' ? versionInfo.downloadurl : versionInfo.downloadurl, //更新链接
+			// 				silent: versionInfo.silent ? versionInfo.silent : 0, //是否是静默更新
+			// 				force: versionInfo.enforce, //是否是强制更新
+			// 				net_check: versionInfo.net_check ? versionInfo.net_check : 1, //非WIfi是否提示
+			// 				note: versionInfo.content //更新内容
+			// 			};
+			// 			checkUpdate(update_info, type).then(res => {
+			// 				if (res.msg) {
+			// 					if(type){
+			// 						uni.$u.toast(res.msg)
+			// 					}
+			// 				}
+			// 			}); ///检查更新
+			// 		}
+			// 		//checkUpdate 这个方法会做什么?:线上版本号 与 本地版本号做对比 ,如果需要更新  根据静默,强制、wifi等信息执行静默更新或跳转到升级页面
+			// 		//跳转升级页面的前提是,需要新建并在pages.json中配置升级页面,配置方法请查看插件详情
+			// 	})
+			// 	.catch(err => {
+			// 		uni.$u.toast(err.msg);
+			// 	});
 			// #endif
 		},
 	}

+ 1 - 1
env.js

@@ -1,7 +1,7 @@
 /**
  *  全局配置文件
  */
-export const BASE_URL = process.env.NODE_ENV === "development" ? 'https://erp.xianglitech.com.cn/prod-api' : 'https://erp.xianglitech.com.cn/prod-api'
+export const BASE_URL = process.env.NODE_ENV === "development" ? 'http://192.168.168.40:8080' : 'https://erp.xianglitech.com.cn/prod-api'
 // https://erp.xianglitech.com.cn/prod-api
 // https://test-erp.xianglitech.com.cn/stage-api
 

+ 1 - 1
pages/index/app-update.vue

@@ -9,7 +9,7 @@
 							<view class="content">
 								<text class="title">发现新版本V{{update_info.version}}</text>
 								<!-- 升级描述 -->
-								<view class="title-sub" v-html="update_info.note"></view>
+								<view class="title-sub" v-html="update_info.note1"></view>
 								<!-- 升级按钮 -->
 								<button class="btn" v-if="downstatus < 1" @click="onUpdate()">立即升级</button>
 								<!-- 下载进度 -->

+ 70 - 2
pages/index/index.vue

@@ -25,11 +25,24 @@
 		</view>
 		<!-- 菜单弹框 -->
 		<use-pop :userInfo="userInfo" v-model="meunShow" @close="meunShow = false"></use-pop>
+	
+		<!-- 今日任务有未读 -->
+		<u-popup :show="updateShow" :closeOnClickOverlay="false" :safeAreaInsetBottom="false" mode="center" :round="16"  @close="state.taskNumShow = false">
+			<view class="reason-box">
+				<image class="icon-img" src="https://qiuyu-shuzhi.oss-cn-beijing.aliyuncs.com/image/task-pop-img.png" mode=""></image>
+				<view class="reason-box-title">象力WMS邀请你升级至新版本</view>
+				<view class="btn-box">
+					<button class="reset-button cancel-btn" @click="updateShow = false">稍后再说</button>
+					<button class="reset-button confirm-btn" @click="toUpdate">下载更新</button>
+				</view>
+			</view>
+		</u-popup>
 	</view>
 </template>
 
 <script>
 	import usePop from './components/use-pop.vue'
+	import { downloadApk } from '@/common/request/apis/index'
 	// const Base64 = require('js-base64').Base64
 	import {
 		mapGetters
@@ -67,13 +80,18 @@
 					}
 				],
 				meunShow:false,
-				noticeShow:true
+				noticeShow:true,
+				updateShow:true
 			}
 		},
 		onLoad() {
 			// JSON.parse(Base64.decode(that.$Route.query.classData))
 		},
 		onShow() {
+			if(this.$store.state.update.update) {
+				console.log('需要更新')
+				this.updateShow = true
+			}
 			if(!this.isLogin) {
 				uni.$u.toast("请先登录!");
 				setTimeout(()=>{
@@ -86,7 +104,12 @@
 		computed: {
 			...mapGetters(['isLogin','userInfo'])
 		},
+		watch: {
+		},
 		methods: {
+			toUpdate() {
+				
+			},
 			meunClick() {
 				if(!this.isLogin) {
 					uni.$u.toast("请先登录!");
@@ -173,5 +196,50 @@
 
 	}
 	
-	
+	.reason-box {
+		width: 700rpx;
+		background: url('https://qiuyu-shuzhi.oss-cn-beijing.aliyuncs.com/image/task-pop-bg.png') no-repeat;
+		background-size: 100% 100%;
+		padding: 0 60rpx 46rpx;
+		box-sizing: border-box;
+		.icon-img {
+			width: 200rpx;
+			height: 200rpx;
+			border-radius: 50%;
+			position: absolute;
+			top: -100rpx;
+			left: 50%;
+			transform: translateX(-50%);
+		}
+		.reason-box-title {
+			padding-top: 150rpx;
+			color: #1D212A;
+			font-family: "PingFang SC";
+			font-size: 32rpx;
+			font-weight: bold;
+			text-align: center;
+		}
+		.btn-box {
+			display: flex;
+			align-items: center;
+			justify-content: space-between;
+			margin-top: 60rpx;
+			.cancel-btn,
+			.confirm-btn {
+				width: 244rpx;
+				height: 80rpx;
+				border-radius: 16rpx;
+				font-size: 32rpx;
+			}
+			.cancel-btn {
+				border: 1px solid #BFC8DB;
+				color: #86909C;
+			}
+			.confirm-btn {
+				background: #0256FF;
+				color: #FFF;
+				font-weight: 500;
+			}
+		}
+	}
 </style>