1. 开发推送以及热更新功能

huipay-app-dev
杨杰 1 year ago
parent 0b7da8dfcf
commit 8f25b05713
  1. 39
      components/downloadUp.vue
  2. 2
      manifest.json
  3. 129
      pages/tabBar/home/home.vue

@ -2,7 +2,7 @@
<view class="content" v-if="bannerShow">
<!-- 弹出层 -->
<view class="uni-banner">
<!-- <image src="../static/logo.png" class="startUpHeaderLogo" /> -->
<image src="../static/logo.png" class="startUpHeaderLogo" />
<view class="banner_box">
<view class="startUpHeaderBox h6">发现新版本</view>
<view class="conter">{{ msg }}</view>
@ -41,10 +41,11 @@
let localAppVersonName = uni.getStorageSync('version');
// #ifdef APP-PLUS
let datas = {
termType: "app"
termType: "APP"
}
queryVersion(datas).then(res => {
if (res.return_code == '000000') {
that.msg = res.return_data.content;
if (res.return_data.versionType == 1 && that.comparisonVersionHandler(localAppVersonName,
res.return_data.version)) {
that.downloadWgt(res.return_data.fileUrl);
@ -67,19 +68,17 @@
const that = this;
// wgt
plus.nativeUI.showWaiting('正在更新...');
plus.downloader
.createDownload(
updateWgtUrl, {
filename: '_doc/update/'
},
function(d, status) {
if (status == 200) {
that.installWgt(d.filename); // wgt
}
plus.nativeUI.closeWaiting();
plus.downloader.createDownload(
updateWgtUrl, {
filename: '_doc/update/'
},
function(d, status) {
if (status == 200) {
that.installWgt(d.filename); // wgt
}
)
.start();
plus.nativeUI.closeWaiting();
}
).start();
},
installWgt(path) {
// wgt
@ -100,7 +99,7 @@
);
},
goUpdate() {
if (this.type == 2) {
// if (this.type == 2) {
//
var dtask = plus.downloader.createDownload(
this.updateApkObj.fileUrl, {},
@ -156,9 +155,9 @@
duration: 1500
});
}
} else if (this.type == 1) { // iosapp store
plus.runtime.openURL(updateApkObj.downloadUrl);
}
// } else if (this.type == 1) { // iosapp store
// plus.runtime.openURL(updateApkObj.downloadUrl);
// }
},
//
comparisonVersionHandler(reqV, curV) {
@ -257,8 +256,8 @@
width: 80%;
.startUpHeaderLogo {
width: 256rpx;
height: 194rpx;
width: 200rpx;
height: 200rpx;
}
.banner_box {

@ -128,6 +128,6 @@
"key": "7UMBZ-HFEHX-HSD4Q-Z3QY6-OQKN7-2QBDB"
}
}
},
}
}
}

@ -103,6 +103,44 @@
},
onLoad() {
if (this.userInfo.secUser.objectType == 5) {
let status = 1;
let that = this;
uni.getPushClientId({
success: res => {
that.storeCid = res.cid;
uni.getStorage({
key: "clientId",
success: (res) => {
if (res.data && res.data != undefined && res.data != that
.storeCid) {
status = 2;
}
},
fail(err) {
status = 3;
uni.setStorage({
key: "clientId",
data: that.storeCid
})
}
})
},
fail(err) {
console.log(err);
}
})
setTimeout(function() {
if (status == 1 && that.storeCid) {
that.setTimer();
}
if ((status == 2 || status == 3) && that.storeCid) {
that.connectStoreCid(that.storeCid)
}
}, 1500);
}
uni.onPushMessage((res) => {
// console.log("", res.data.content) //
let conts = res.data.content.split('!@#PUSH#@!');
@ -226,52 +264,73 @@
if (this.userInfo.secUser.objectType == 4) {
this.mermoveHomeCount();
}
if (this.userInfo.secUser.objectType == 5) {
this.storemoveHomeCount();
let status = 1;
let that = this;
uni.getPushClientId({
success: res => {
that.storeCid = res.cid;
uni.getStorage({
key: "clientId",
success: (res) => {
if (res.data && res.data != undefined && res.data != that
.storeCid) {
status = 2;
}
},
fail(err) {
status = 1;
uni.setStorage({
key: "clientId",
data: that.storeCid
})
}
})
},
fail(err) {
console.log(err);
}
})
setTimeout(function() {
if (status == 1 && that.storeCid) {
that.connectStoreCid(that.storeCid)
}
}, 1500);
if (this.userInfo.secUser.objectType == 5) {
this.storemoveHomeCount();
}
this.getDictionaries();
},
methods: {
Timersockt() {},
//cid
connectStoreCid(item) {
let datas = {
"cid": item,
"storeId": this.userInfo.store.id
}
connectStoreCid(datas).then(res => {})
connectStoreCid(datas).then(res => {
this.setTimer();
})
},
setTimer() {
let holdTime = 10;
this.Timersockt = setInterval(() => {
if (holdTime <= 0) {
holdTime = 60;
clearInterval(this.Timersockt);
let status = 1;
let that = this;
uni.getPushClientId({
success: res => {
that.storeCid = res.cid;
uni.getStorage({
key: "clientId",
success: (res) => {
if (res.data && res.data != undefined && res
.data != that
.storeCid) {
status = 2;
}
},
fail(err) {
status = 3;
uni.setStorage({
key: "clientId",
data: that.storeCid
})
}
})
},
fail(err) {
console.log(err);
}
})
setTimeout(function() {
if (status == 1 && that.storeCid) {
that.setTimer();
}
if ((status == 2 || status == 3) && that.storeCid) {
that.connectStoreCid(that.storeCid)
}
}, 1500);
return;
}
holdTime--;
}, 1000)
},
//
voiceSucceed(item) {

Loading…
Cancel
Save