This commit is contained in:
shijing 2025-10-14 13:16:47 +08:00
commit 84af330ea8
2 changed files with 157 additions and 70 deletions

View File

@ -38,10 +38,16 @@
<uni-icons type="weixin" size="36" color="green" @click="wxmpLogin"></uni-icons>
<view style="text-align: center;font-size: 32rpx;">微信登陆</view>
</view> -->
<view v-show="dShow" style="position: fixed;top: 0;left: 0;width: 100%;height: 100%;background: rgba(0, 0, 0, .5);z-index: 999;">
<view style="position: absolute;padding: 50rpx;background: #ffffff;display: inline-block;margin: auto;top: 40%;left: 50%;transform: translateX(-50%);">
下载中 请勿退出 {{percentVal}}%
</view>
</view>
</view>
</template>
<script>
import config from '/utils/config';
export default {
data() {
return {
@ -80,17 +86,17 @@
}]
}
},
wxmp_openid: null
wxmp_openid: null,
dShow: false,
percentVal: 0
}
},
onLoad(options) {
var that = this
var autoLoading = options.autoLoading;
that.checkVersion();
if (autoLoading != 'no') {
// #ifdef APP-PLUS
that.appLogin()
// #endif
// #ifdef H5
// #ifdef APP-PLUS || H5
that.appLogin()
// #endif
// #ifdef MP-WEIXIN
@ -110,6 +116,82 @@
// #endif
},
methods: {
checkVersion() {
let that = this;
uni.getSystemInfo({
success(res) {
uni.setStorageSync("vuex_version", res.appVersion)
// #ifdef APP-PLUS
if (res.platform == 'android') {
that.$api.apkCheck().then(res1 => {
if (res.appWgtVersion != res1.version) {
uni.showModal({
title: "版本更新",
content: '有新的版本发布, 请下载新版本',
confirmText: '立即更新',
cancelText: '稍后进行',
success: function(res2) {
if (res2.confirm) {
let fullurl = res1.file
if (res1.file.indexOf("http") == -1) {
fullurl = config.baseUrl + res1.file
}
that.dShow =
true // showUI
uni.hideTabBar()
// apkfilePath
var dtask = plus.downloader.createDownload(
fullurl, {},
function(d, status) {
//
if (status == 200) {
that.dShow =
false //
uni.showTabBar();
plus.runtime.install(plus.io
.convertLocalFileSystemURL(
d
.filename), {}, {},
function(error) {
uni.showToast({
title: '安装失败',
duration: 1500
});
})
} else {
uni.showToast({
title: '更新失败',
duration: 1500
});
}
});
function onStateChanged(download, status) {
if (status == 200) {
const totalSize = download.totalSize
let nowSize = download.downloadedSize
that.percentVal = nowSize / 17700000 *
100 > 99 ? 99 : (nowSize /
17700000 * 100).toFixed(0)
}
}
dtask.addEventListener("statechanged",
onStateChanged, false);
dtask.start();
} else {
}
}
});
}
})
}
// #endif
}
})
},
wxmpLogin() {
var that = this;
uni.showLoading({
@ -119,7 +201,9 @@
uni.login({
provider: 'weixin',
success: (loginRes) => {
that.$api.wxmpLogin({code: loginRes.code}).then(res=>{
that.$api.wxmpLogin({
code: loginRes.code
}).then(res => {
uni.setStorageSync('access', res.access)
that.$api.getUserInfo().then(res => {
uni.setStorageSync('userInfo', res)
@ -220,8 +304,7 @@
}).catch(err => {
console.log('表单错误信息:', err);
})
}
else if(that.current == 0){
} else if (that.current == 0) {
that.$refs.form1.validate().then(res0 => {
that.$api.login(res0).then(res => {
uni.setStorageSync('access', res.access)
@ -283,7 +366,9 @@
// #endif
// #ifdef MP-WEIXIN
if (this.wxmp_openid != null) {
this.$api.bindWxmp({"openid": this.wxmp_openid}).then(res=>{
this.$api.bindWxmp({
"openid": this.wxmp_openid
}).then(res => {
})
}

View File

@ -11,6 +11,8 @@ export default {
codeLogin:(data) => http('/auth/login_sms_code/', 'POST', data),
wxmpLogin: (data) => http('/auth/login_wxmp/', 'POST', data, true, false), //微信小程序登录
wxmpClogin: (data) => http('/auth/login_wxmp/', 'POST', data, true, false), //微信小程序登录(自动创建账号)
apkCheck: ()=>http('/system/apk/'), //apk检查
getTicket:(data) => http('/wf/ticket/', 'GET', data),
ticketCreate:(data)=>http('/wf/ticket/', 'POST', data),
ticketHandle:(id,data)=>http(`/wf/ticket/${id}/handle/`, 'POST', data),