123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- <script>
- import config from './config'
- import store from '@/store'
- import { getToken } from '@/utils/auth'
- import {updateUserProfile,findVersion} from "@/api/system/user.js"
- const baseUrl = config.baseUrl
- export default {
- data(){
- return{
- platform:'Android'
- }
- },
- onLaunch: function() {
-
- this.onlineWgt();
-
-
-
-
-
-
-
- },
- methods: {
-
-
-
- onlineWgt() {
- let that = this;
- plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
- that.comparisonVersionNo(widgetInfo.versionCode);
- });
-
- },
- comparisonVersionNo(versionCode) {
- let that = this;
-
- const parmas = {
- model: that.platform
- }
- findVersion(parmas).then(res => {
- console.log(res)
- if (res.code == "200") {
- let versionNos = res.data.code;
-
- let filePath = res.data.path;
- if (Number(versionNos) > Number(versionCode)) {
- uni.showModal({
- title: '提示',
- content: '发现新版本,是否升级',
- success: function(res) {
-
- if (res.confirm) {
- console.log('用户点击确定');
- that.getProperty(filePath);
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- });
- }
- }
- }).catch(error=>{
- uni.hideLoading()
- console.log(error)
- })
- },
- getProperty(getProperty) {
-
- let that = this;
-
-
- that.showwri = true;
- const downloadTask = uni.downloadFile({
- url: baseUrl + getProperty,
- success: (downloadResult) => {
-
- if (downloadResult.statusCode == 200) {
-
- plus.runtime.install(downloadResult.tempFilePath, {
- force: true
- }, function() {
-
- that.showwri = false;
- plus.nativeUI.alert("应用资源更新完成!", function() {
- plus.runtime.restart();
- });
- }, function(e) {
- that.showwri = false;
- plus.nativeUI.alert("更新失败,请稍后再试");
- });
- }
- }
- });
- downloadTask.onProgressUpdate((res) => {
- that.totalBytesWritten = res.totalBytesWritten;
- that.progress = res.progress;
- that.totalBytesExpectedToWrite = res.totalBytesExpectedToWrite;
- });
- },
-
- getJGtuifn(){
-
- var jpushModule = uni.requireNativePlugin("JG-JPush");
- jpushModule.setLoggerEnable(true);
-
- jpushModule.initJPushService();
- jpushModule.addConnectEventListener(result=>{
- let connectEnable = result.connectEnable
-
- })
- jpushModule.getRegistrationID(result => {
-
- this.registerID = result.registerID;
- if(getToken()){
- var params={
- jgId:this.registerID,
- }
- updateUserProfile(params).then(res=>{
- if(rtes.code==200){
- console.log(res,9)
- }
- })
- }
- })
- jpushModule.isPushStopped(result=>{
- let code = result.code
- console.log('连接状态回调',result)
- });
-
- jpushModule.setAlias({
- 'alias' : 'coder',
- 'sequence': 1
- })
- jpushModule.addNotificationListener(result=>{
- let notificationEventType = result.notificationEventType
- let messageID = result.messageID
- let title = result.title
- let content = result.content
- let extras = result.extras
- console.log('通知事件回调',result)
-
- jpushModule.addLocalNotification({
- messageID,
- title,
- content,
- extras
- })
- })
- jpushModule.addNotificationListener(result => {
- console.log(result)
- if (result.notificationEventType == "notificationOpened") {
-
- uni.reLaunch({
- url:'/pages/login'
- })
- }
-
- });
-
- },
-
- initApp() {
-
- this.initConfig()
-
-
- this.checkLogin()
-
- },
- initConfig() {
- this.globalData.config = config
- },
- checkLogin() {
-
-
-
- }
- }
- }
- </script>
- <style lang="scss">
- @import '@/static/scss/index.scss';
- @import "@/static/style.css";
- </style>
|