KunWeb/ciyon/fapp/ciyon_ap/App.vue

193 lines
9.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script>
export default {
globalData: {},
onLaunch: function(lopn) {
var app = this;
app.globalData.launchopn = lopn;
console.log('launchopn', lopn);
app.launch();
app.globalData.srv = 't'; //默认的独立微服务集群标识。
app.globalData.jsnurl = {};
app.globalData.jsnurl.t = 'https://ciyon.ciy.cn/ambap/';
app.globalData.tokenfield = "ciyap"; //header授权名称。H5同域名多个移动端项目需区分。
app.globalData.tokensalt = "ast34h$3"; //用户密码加密盐值。
app.globalData.mainpage = '/pages/main/index'; //入口页面。一般为tabbar第一个页面。
app.globalData.share_backmainpage = false; //分享如需从首页跳转则true。用户返回后不退出小程序而是进入首页。
app.globalData.dupsec = 60; //防重复点击的间隔秒数。
app.globalData.stordefault = '/'; //默认全局存储路径。 / 为本地存储(用于单web服务器项目)A-Z 可定义成多种云存储(阿里云OSS/腾讯云COS/Cloudflare R2等)
app.globalData.storlist = { //上传文件需补全的显示链接
'/': 'https://ciyon.ciy.cn/ud/',
'A': 'https://cf5.nyyzsoft.cn/ud/',
'B': 'https://tob-1322789299.cos.ap-nanjing.myqcloud.com/ud/',
'C': 'https://expn.oss-cn-hangzhou.aliyuncs.com/ud/',
};
app.globalData.storthumb = { //图片文件缩略图配置。默认100px高度宽度自适应。
'/': '?100',
'A': 'https://cf5.nyyzsoft.cn/cdn-cgi/image/height=100/ud/#img#', //开启媒体Images转换
'B': '?imageMogr2/thumbnail/x100',
'C': '?x-oss-process=image/resize,h_100',
}
if (process.env.NODE_ENV === 'development') {
//#ifdef H5
app.globalData.jsnurl.t = 'https://ciyon.local.ciy.cn/ambap/';
app.globalData.storlist['/'] = 'https://ciyon.local.ciy.cn/ud/';
//golang
// app.globalData.jsnurl.t = 'https://ciyongo.local.ciy.cn/';
//#endif
}
var bggray1 = '#dfdfdf'; //底部导航按钮未选颜色1
var bggray2 = '#bbbbbb'; //底部导航按钮未选颜色2
var bgsel1 = '#ffdc72'; //底部导航按钮选中颜色1
var bgsel2 = '#e65411'; //底部导航按钮选中颜色2
app.globalData.tabbarArr = []; //最底部导航按钮。双色svg
var svg = '<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M10,515c0,277,225,503,503,503s503-225,503-503l0,0c0-277-225-503-503-503S9,238,10,515L10,515z" fill="{{bg2}}"></path><path d="M777,322L547,178c-28-18-64-18-91,0L226,322c-25,16-40,43-40,73v263c0,76,61,137,137,137h61V633l0,0c0-66,53-119,119-119l0,0c66,0,119,53,119,119v162h61l0,0c76,0,137-61,137-137V395c-1-29-17-56-42-73H777z" fill="{{bg1}}"></path></svg>';
app.globalData.tabbarArr.push({
name: 'tabbar.index',
fullpath: '/pages/main/index',
selecticon: svg.replaceAll(/{{bg1}}/g, bgsel1).replaceAll(/{{bg2}}/g, bgsel2),
icon: svg.replaceAll(/{{bg1}}/g, bggray1).replaceAll(/{{bg2}}/g, bggray2)
});
// svg = '<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M969,956L913,810c51-81,107-209,103-313C1008,230,789,15,522,10C237,5,5,237,9,522c4,274,223,494,497,494c69,0,208-38,265-75L932,997C954,998,972,979,969,956L969,956z" fill="{{bg2}}"></path><path d="M715,299l-22,133c-3,16,3,32,15,43l99,94c20,19,20,49,1,69c-7,7-17,12-28,15l-134,21c-16,3-30,12-37,27l-59,122c-12,25-42,35-65,22c-10-5-17-12-22-22l-62-121c-7-15-21-25-37-27l-134-19c-27-4-46-28-42-55c1-11,6-21,14-28l96-96c11-11,17-27,14-43l-23-134c-5-27,14-52,39-57c11-1,22,0,31,5l121,63c15,7,32,7,46,0l119-64c23-12,54-4,67,20C715,277,716,288,715,299z" fill="{{bg1}}"></path></svg>';
// app.globalData.tabbarArr.push({
// name: 'tabbar.zh',
// fullpath: '/pages/expo',
// selecticon: svg.replaceAll(/{{bg1}}/g, bgsel1).replaceAll(/{{bg2}}/g, bgsel2),
// icon: svg.replaceAll(/{{bg1}}/g, bggray1).replaceAll(/{{bg2}}/g, bggray2)
// });
// svg = '<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M788,950h-551c-80,0-144-64-144-144V281h839v524C933,886,869,950,788,950L788,950z" fill="{{bg2}}"></path><path d="M685,842H352c-33,0-60-27-60-60s27-60,60-60h333c33,0,60,27,60,60S718,842,685,842z M946,322H80c-41,0-75-33-75-75V136c0-41,33-75,75-75h866c41,0,75,33,75,75v111C1021,288,988,322,946,322z" fill="{{bg1}}"></path></svg>';
// app.globalData.tabbarArr.push({
// name: 'tabbar.sq',
// fullpath: '/pages/socg',
// selecticon: svg.replaceAll(/{{bg1}}/g, bgsel1).replaceAll(/{{bg2}}/g, bgsel2),
// icon: svg.replaceAll(/{{bg1}}/g, bggray1).replaceAll(/{{bg2}}/g, bggray2)
// });
// svg = '<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M207,110h614c109,0,197,88,197,197v416c0,109-88,197-197,197H207c-109,0-197-88-197-197V308C9,198,97,110,207,110z" fill="{{bg2}}"></path><path d="M865,819H118c-10,0-19-9-19-19c0-3,1-7,2-10l26-35c3-6,10-9,17-9h748c10,0,19,9,19,19c0,3-1,7-2,10l-26,35C878,815,872,819,865,819z M451,285c0-8-6-14-14-14h-246c-8,0-14,6-14,14v246c0,8,6,14,14,14h246c8,0,14-6,14-14V285z M909,503c0-8-6-14-14-14H562c-8,0-14,6-14,14v25c0,8,6,14,14,14h333c8,0,14-6,14-14V503z" fill="{{bg1}}"></path></svg>';
// app.globalData.tabbarArr.push({
// name: 'tabbar.cd',
// fullpath: '/pages/card',
// selecticon: svg.replaceAll(/{{bg1}}/g, bgsel1).replaceAll(/{{bg2}}/g, bgsel2),
// icon: svg.replaceAll(/{{bg1}}/g, bggray1).replaceAll(/{{bg2}}/g, bggray2)
// });
svg = '<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M706,460c64-38,107-104,107-179c0-118-106-213-237-213c-131,0-237,95-237,213c0,75,43,141,107,179c-181,51-311,206-311,385c0,39,35,70,78,70H938c43,0,78-32,78-70v-5C1017,661,886,511,706,460L706,460z" fill="{{bg1}}"/><path d="M580,472c64-42,107-115,107-197c0-131-106-237-237-237c-131,0-237,106-237,237c0,83,43,155,107,199c-181,57-311,228-311,427c0,43,14,76,57,76l745,1c43,0,78-35,78-78v-6C891,696,761,528,580,472L580,472z" fill="{{bg2}}"/></svg>';
app.globalData.tabbarArr.push({
name: 'tabbar.me',
fullpath: '/pages/main/me',
selecticon: svg.replaceAll(/{{bg1}}/g, bgsel1).replaceAll(/{{bg2}}/g, bgsel2),
icon: svg.replaceAll(/{{bg1}}/g, bggray1).replaceAll(/{{bg2}}/g, bggray2)
});
setInterval(() => {
getnewnotice();
}, 120000); //2分钟请求一次notice
getnewnotice();
//lopn 结合me将数据上传到平台
function getnewnotice() {
return;
app.callfunc({
func: 'me.notice_new',
showload: false,
success: json => {
app.setTabbar({
'index.detail': {
reddot: false
}
});
}
});
}
// #ifdef APP-PLUS
plus.runtime.getProperty(plus.runtime.appid, widgetInfo => {
app.globalData._version = widgetInfo.version;
});
app.appupdate('app');
uni.getPushClientId({
success: (res) => {
console.log('客户端推送标识:', res);
app.globalData._appcid = res.cid;
}
})
uni.onPushMessage((res) => {
this.alert(JSON.stringify(res));
})
// #endif
// #ifdef APP-PLUS
var sysinfo = app.globalData._sysinfo;
if (sysinfo.model == 'k71v1_64_bsp') {
app.device_rfid = uni.requireNativePlugin("UhfGModule"); // 133左/134枪/135右
app.device_rfid_gunkey = 134;
} else if (sysinfo.model == 'k62v1_6c') {
app.device_rfid = uni.requireNativePlugin(
"UhfGModule"); //C61型号手柄按键137左侧135右侧是136 F1-F4对应131-134
app.device_rfid_gunkey = 137;
}
console.log('device_rfid', app.device_rfid);
// #endif
// #ifndef H5
app.globalData.dev_bt = {};
//自动连接蓝牙
this.info = uni.getStorageInfoSync();
this.info.kv = {};
this.info.total = 0;
for (var i in this.info.keys) {
var key = this.info.keys[i];
if (key.indexOf('dev_bt_') !== 0)
continue;
var savedev = app.getstorage(key);
var devup = key.substr(7);
console.log('auto', savedev, devup);
if (devup != savedev.devup) {
console.log('蓝牙自动连接设置错误', devup, savedev.devup);
continue;
}
app.connectbt(savedev.devup, savedev.devtype, savedev.id);
}
uni.onBLEConnectionStateChange(res => {
//设置dev_bt重连。
console.log('statechanged', res);
for (var dup in app.globalData.dev_bt) {
var devbt = app.globalData.dev_bt[dup];
if (devbt.deviceid != res.deviceId)
continue;
devbt.opened = res.connected ? 10 : 9;
if (typeof(devbt.onmsg) == 'function')
devbt.onmsg(res);
if (res.connected)
return;
if (devbt.enableclose)
return;
console.log('re devopen' + devbt.deviceid);
devbt.bt_devopen(devbt.deviceid);
return;
}
});
uni.onBLECharacteristicValueChange(res => {
console.log('onBLECharacteristicValueChange', res);
for (var dup in app.globalData.dev_bt) {
var devbt = app.globalData.dev_bt[dup];
if (devbt.deviceid != res.deviceId)
continue;
var dat = devbt.convertmsg(res);
res.data = dat;
if (typeof(devbt.onmsg) == 'function')
devbt.onmsg(res);
}
});
// #endif
},
onShow: function() {},
onHide: function() {},
methods: {}
}
</script>
<style>
</style>