|
@@ -53,24 +53,21 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="24" style="text-align: right">
|
|
|
- <!-- <el-checkbox v-model="checked" class="fl" style="padding-top: 5px">我已知晓,后续不再提示!</el-checkbox> -->
|
|
|
+ <el-checkbox v-model="checked" class="fl" style="padding-top: 5px">我已知晓,后续不再提示!</el-checkbox>
|
|
|
+
|
|
|
<el-button
|
|
|
+ plain
|
|
|
v-if="!isForce"
|
|
|
type="primary"
|
|
|
- plain
|
|
|
:size="'mini'"
|
|
|
- @click="showModel = false"
|
|
|
+ @click="handleClose"
|
|
|
>关闭
|
|
|
</el-button>
|
|
|
- <el-progress
|
|
|
- v-else
|
|
|
- type="circle"
|
|
|
- :width="40"
|
|
|
- color="#67C23A"
|
|
|
- text-color="#67C23A"
|
|
|
- :format="formatProgressText"
|
|
|
- :percentage="countdown"
|
|
|
- />
|
|
|
+
|
|
|
+ <div
|
|
|
+ v-else
|
|
|
+ >{{countdown / 10}} 秒后可以关闭
|
|
|
+ </div>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</el-form>
|
|
@@ -82,20 +79,24 @@
|
|
|
|
|
|
<script>
|
|
|
import asyncRequest from '@/apis/service/system/updates'
|
|
|
-import md5 from "js-md5"
|
|
|
import { mapGetters } from "vuex"
|
|
|
import dayjs from "dayjs"
|
|
|
+import md5 from "js-md5"
|
|
|
+
|
|
|
+import { setVersionKey , getVersionKey } from '@/utils/auth'
|
|
|
+
|
|
|
|
|
|
export default {
|
|
|
name:"NotifyModal",
|
|
|
data(){
|
|
|
return {
|
|
|
activeMsg: null, // 消息展示对象
|
|
|
- isForce:false, // 是否强制展示
|
|
|
+ isForce: false, // 是否强制展示
|
|
|
+ showModel: false,
|
|
|
+ checked: false,
|
|
|
countdown: 100, //倒计时
|
|
|
- showModel:false,
|
|
|
- timer: null,
|
|
|
- checked: false
|
|
|
+ curVersion: "",
|
|
|
+ timer: null
|
|
|
}
|
|
|
},
|
|
|
mounted(){
|
|
@@ -108,6 +109,10 @@ computed:{
|
|
|
...mapGetters(['userInfo'])
|
|
|
},
|
|
|
methods:{
|
|
|
+ handleClose(){
|
|
|
+ this.showModel = false
|
|
|
+ setVersionKey(this.checked ? this.curVersion : "");
|
|
|
+ },
|
|
|
formatProgressText(percentage){
|
|
|
return (percentage / 10) || 0
|
|
|
},
|
|
@@ -173,6 +178,7 @@ async openNotifyModal(isInitialPage = false) {
|
|
|
},
|
|
|
async handleForcedDisplay(curMessage, isInitialPage){
|
|
|
const { version } = curMessage;
|
|
|
+ this.curVersion = version;
|
|
|
// 获取用户信息
|
|
|
const {code, data, message} = await asyncRequest.userinfo();
|
|
|
if(code >= 100 && code <= 104){
|
|
@@ -187,11 +193,19 @@ async handleForcedDisplay(curMessage, isInitialPage){
|
|
|
|
|
|
const { system_version, id } = data;
|
|
|
const { cx } = Array.isArray(system_version) ? {} : (system_version || {})
|
|
|
- // 该用户没有读取过该版本
|
|
|
- this.isForce = cx !== version;
|
|
|
+ const versionKey = getVersionKey();
|
|
|
this.activeMsg = curMessage;
|
|
|
+
|
|
|
+ this.checked = version === versionKey;
|
|
|
+
|
|
|
+ if(this.checked && isInitialPage){
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ this.showModel = true;
|
|
|
+ // 该用户没有读取过该版本 version当前要显示的版本号 cx用户存储的版本号
|
|
|
+ this.isForce = (cx || "").trim() !== (version || "").trim();
|
|
|
// 用户已经读取过该推送且是初始化页面不弹出消息
|
|
|
- this.showModel = !(!this.isForce && isInitialPage);
|
|
|
// 判断是否有读取当前推送,如果没有强制显示10秒
|
|
|
if(this.isForce) this.onForceDisplay(id, version)
|
|
|
},
|
|
@@ -200,20 +214,25 @@ async handleForcedDisplay(curMessage, isInitialPage){
|
|
|
this.timer = setInterval(async () => {
|
|
|
this.countdown = this.countdown - 10;
|
|
|
if(this.countdown !== 0) return
|
|
|
- this.showModel = false;
|
|
|
+ this.isForce = false;
|
|
|
window.clearInterval(this.timer);
|
|
|
// 存储当前用户已读取过该推送
|
|
|
-
|
|
|
const noce = this.generateRandomString(10);
|
|
|
const origin = window.location.origin;
|
|
|
const timestamp = new Date().valueOf();
|
|
|
-
|
|
|
- await asyncRequest.setVersion({ account_id: userId, system_version: curVersion, plat_code: "cx" },{
|
|
|
- "web-auth":"1",
|
|
|
- sign:md5(origin + noce + timestamp),
|
|
|
- timestamp,
|
|
|
- noce
|
|
|
- })
|
|
|
+ await asyncRequest.setVersion(
|
|
|
+ {
|
|
|
+ account_id: userId,
|
|
|
+ system_version: curVersion,
|
|
|
+ plat_code: "cx"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "web-auth":"1",
|
|
|
+ sign: md5(origin + noce + timestamp),
|
|
|
+ timestamp,
|
|
|
+ noce
|
|
|
+ }
|
|
|
+ )
|
|
|
}, 1000)
|
|
|
}
|
|
|
}
|