处理IOS 链接判断找ai问问加快链接
This commit is contained in:
parent
1f99299bd7
commit
d51e8c9006
582
App.vue
582
App.vue
|
@ -1,280 +1,302 @@
|
|||
<script>
|
||||
var xBlufi = require("./utils/blufi/xBlufi.js")
|
||||
var call
|
||||
var data_call
|
||||
var ble_id = "1231"
|
||||
var ble_url
|
||||
|
||||
var user_info
|
||||
|
||||
// 在文件顶部添加一个变量来存储当前连接的MAC地址
|
||||
var current_connected_mac = null;
|
||||
|
||||
export default {
|
||||
globalData: {
|
||||
userInfo: null,
|
||||
topicTypeIndex: 0,
|
||||
token: "",
|
||||
isShow: true,
|
||||
bleInfo: {
|
||||
current_connected_mac: null,
|
||||
ble_id: "1231",
|
||||
ble_url: null,
|
||||
devicesList: [],
|
||||
xBlufi: xBlufi
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// #ifdef APP-PLUS
|
||||
plus.navigator.closeSplashscreen()
|
||||
// #endif
|
||||
console.log('App @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Launch')
|
||||
// #ifndef APP-PLUS
|
||||
console.log('App 1111111111111Launch')
|
||||
xBlufi.initXBlufi(1);
|
||||
console.log("xBlufi初始化", xBlufi) // 修改日志输出,确保输出有意义的信息
|
||||
xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent); // 取消注释,确保事件监听被正确设置
|
||||
xBlufi.notifyStartDiscoverBle({
|
||||
'isStart': true
|
||||
})
|
||||
// #endif
|
||||
|
||||
// 添加以下代码,将方法绑定到 uni 全局对象
|
||||
uni.$emit('init_app_methods', {
|
||||
set_ble_mac: this.set_ble_mac.bind(this)
|
||||
})
|
||||
},
|
||||
onLaunch(options) {
|
||||
uni.setInnerAudioOption({
|
||||
obeyMuteSwitch: false
|
||||
})
|
||||
|
||||
},
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
methods: {
|
||||
get_ble_name(callback) {
|
||||
if (callback != undefined) {
|
||||
xBlufi.notifyConnectBle({
|
||||
isStart: false,
|
||||
deviceId: ble_id,
|
||||
name: ""
|
||||
})
|
||||
console.log('关闭蓝牙接口', ble_id);
|
||||
call = callback
|
||||
}
|
||||
},
|
||||
get_ble_data(callback) {
|
||||
if (callback != undefined)
|
||||
data_call = callback;
|
||||
},
|
||||
set_ble_mac(mac) {
|
||||
const bleInfo = this.globalData.bleInfo
|
||||
// 如果MAC地址与当前连接的相同,则不重复连接
|
||||
if (mac === bleInfo.current_connected_mac) {
|
||||
console.log('设备已连接,无需重复连接')
|
||||
return
|
||||
}
|
||||
if (mac != undefined && bleInfo.devicesList) {
|
||||
const device = bleInfo.devicesList.find(device =>
|
||||
device.name && device.name.toLowerCase().includes(mac.toLowerCase())
|
||||
)
|
||||
if (device) {
|
||||
bleInfo.ble_url = ''
|
||||
uni.hideLoading()
|
||||
bleInfo.ble_id = device.deviceId
|
||||
bleInfo.xBlufi.notifyConnectBle({
|
||||
isStart: true,
|
||||
deviceId: device.deviceId
|
||||
})
|
||||
uni.showToast({
|
||||
title: "连接蓝牙设备中",
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
})
|
||||
bleInfo.xBlufi.notifyInitBleEsp32({
|
||||
deviceId: device.deviceId
|
||||
})
|
||||
// 更新全局MAC地址
|
||||
bleInfo.current_connected_mac = mac
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "未找到匹配的设备",
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
set_ble_id(id, url) {
|
||||
console.log("id", id)
|
||||
if (id != undefined) {
|
||||
ble_url = url
|
||||
uni.hideLoading()
|
||||
ble_id = id
|
||||
xBlufi.notifyConnectBle({
|
||||
isStart: true,
|
||||
deviceId: id
|
||||
// name
|
||||
})
|
||||
uni.showToast({
|
||||
title: "连接蓝牙设备中",
|
||||
icon: 'none',
|
||||
duration: 3500
|
||||
})
|
||||
xBlufi.notifyInitBleEsp32({
|
||||
deviceId: id
|
||||
})
|
||||
}
|
||||
},
|
||||
ble_send(data) {
|
||||
if (data != undefined) {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: data,
|
||||
});
|
||||
}
|
||||
},
|
||||
get_user_iphone(data) {
|
||||
return user_info;
|
||||
},
|
||||
set_user_iphone(data) {
|
||||
console.log("电话存储")
|
||||
uni.setStorage({
|
||||
key: 'user_info',
|
||||
data: data,
|
||||
success: () => {
|
||||
console.log('已经缓存,userInfo:', data.phone);
|
||||
resolve('success')
|
||||
}
|
||||
});
|
||||
user_info = data
|
||||
},
|
||||
call(e) {
|
||||
call = e;
|
||||
},
|
||||
funListenDeviceMsgEvent(options) {
|
||||
switch (options.type) {
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED:
|
||||
if (!options.result) {
|
||||
// 清除全局MAC地址
|
||||
this.globalData.bleInfo.current_connected_mac = null;
|
||||
const pages = getCurrentPages();
|
||||
const currentPage = pages[pages.length - 1];
|
||||
console.log("当前页面路径", currentPage.route)
|
||||
if (currentPage.route != 'pages/index/index') {
|
||||
uni.showModal({
|
||||
title: '设备提示!',
|
||||
content: '与设备断开请重联',
|
||||
showCancel: false,
|
||||
success: function (res) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_CONNECT_ROUTER_RESULT:
|
||||
uni.hideLoading();
|
||||
if (!options.result) {
|
||||
uni.hideLoading();
|
||||
uni.showModal({
|
||||
title: '温馨提示',
|
||||
content: '配网失败,请确认是2.4G模式并且账户密码正确',
|
||||
showCancel: false //是否显示取消按钮
|
||||
});
|
||||
} else {
|
||||
if (options.data.progress == 100) {
|
||||
let ssid = options.data.ssid;
|
||||
uni.hideLoading();
|
||||
uni.showModal({
|
||||
title: '温馨提示',
|
||||
content: `连接成功路由器`,
|
||||
showCancel: false,
|
||||
//是否显示取消按钮
|
||||
success: function (res) {
|
||||
// uni.navigateBack()
|
||||
uni.navigateTo({
|
||||
url: '/pages/dd/xiaoai'
|
||||
});
|
||||
console.log("确定成功之后 返回 ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
||||
if (data_call != undefined) {
|
||||
data_call(options.data)
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
|
||||
if (options.result) {
|
||||
this.globalData.bleInfo.devicesList = options.data; // 假设你想在组件内部使用这个变量,应该这样设置
|
||||
console.log("获取设备列表", this.globalData.bleInfo.devicesList)
|
||||
if (call != undefined) {
|
||||
console.log("获取设备列表", this.globalData.bleInfo.devicesList)
|
||||
call(this.globalData.bleInfo.devicesList)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
|
||||
console.log("连接回调:" + JSON.stringify(options));
|
||||
if (options.result) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '连接成功',
|
||||
icon: 'none'
|
||||
});
|
||||
console.log("连接进入:", ble_url);
|
||||
// uni.navigateTo({ url: ble_url });
|
||||
}
|
||||
else {
|
||||
uni.showToast({
|
||||
title: '连接超时,请重新链接',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
|
||||
if (!options.result) {
|
||||
uni.showToast({
|
||||
title: '蓝牙未开启解决方法',
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
});
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP:
|
||||
if (options.result) {
|
||||
console.log('蓝牙停止搜索ok');
|
||||
} else {
|
||||
console.log('蓝牙停止搜索失败');
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
/*每个页面公共css */
|
||||
@import "uview-ui/index.scss";
|
||||
@import "./common/css/iconfont.css";
|
||||
|
||||
// 自定义tabar样式修改
|
||||
/deep/.u-tabbar__content__item__text {
|
||||
font-size: 20rpx !important;
|
||||
bottom: 10rpx !important;
|
||||
}
|
||||
|
||||
page {
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var xBlufi = require("./utils/blufi/xBlufi.js")
|
||||
var call
|
||||
var data_call
|
||||
var ble_id = "1231"
|
||||
var ble_url
|
||||
|
||||
var user_info
|
||||
|
||||
// 在文件顶部添加一个变量来存储当前连接的MAC地址
|
||||
var current_connected_mac = null;
|
||||
|
||||
export default {
|
||||
globalData: {
|
||||
userInfo: null,
|
||||
topicTypeIndex: 0,
|
||||
token: "",
|
||||
isShow: true,
|
||||
bleInfo: {
|
||||
current_connected_mac: null,
|
||||
ble_id: "1231",
|
||||
ble_url: null,
|
||||
devicesList: [],
|
||||
xBlufi: xBlufi
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// #ifdef APP-PLUS
|
||||
plus.navigator.closeSplashscreen()
|
||||
// #endif
|
||||
console.log('App @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Launch')
|
||||
// #ifndef APP-PLUS
|
||||
console.log('App 1111111111111Launch')
|
||||
|
||||
// wx.openBluetoothAdapter({
|
||||
// success: function (res) {
|
||||
// console.log('蓝牙适配器初始化成功')
|
||||
// //xBlufi.initXBlufi(1)
|
||||
|
||||
// xBlufi.initXBlufi(1);
|
||||
// console.log("xBlufi初始化", xBlufi) // 修改日志输出,确保输出有意义的信息
|
||||
// xBlufi.listenDeviceMsgEvent(true, this.funListenDeviceMsgEvent); // 取消注释,确保事件监听被正确设置
|
||||
// xBlufi.notifyStartDiscoverBle({
|
||||
// 'isStart': true
|
||||
// })
|
||||
// // xBlufi.notifyStartDiscoverBle({
|
||||
// // 'isStart': true
|
||||
// // })
|
||||
|
||||
// // 你可以在这里继续调用其他蓝牙相关的API
|
||||
// },
|
||||
// fail: function (err) {
|
||||
// uni.showToast({
|
||||
// title: '蓝牙权限获取失败,请打开系统蓝牙和定位',
|
||||
// icon: 'none',
|
||||
// duration:3000
|
||||
// })
|
||||
// console.error('蓝牙适配器初始化失败,可能是因为没有权限', err)
|
||||
// }
|
||||
// })
|
||||
|
||||
// #endif
|
||||
|
||||
// 添加以下代码,将方法绑定到 uni 全局对象
|
||||
uni.$emit('init_app_methods', {
|
||||
set_ble_mac: this.set_ble_mac.bind(this)
|
||||
})
|
||||
},
|
||||
onLaunch(options) {
|
||||
uni.setInnerAudioOption({
|
||||
obeyMuteSwitch: false
|
||||
})
|
||||
|
||||
},
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
methods: {
|
||||
get_ble_name(callback) {
|
||||
if (callback != undefined) {
|
||||
xBlufi.notifyConnectBle({
|
||||
isStart: false,
|
||||
deviceId: ble_id,
|
||||
name: ""
|
||||
})
|
||||
console.log('关闭蓝牙接口', ble_id);
|
||||
call = callback
|
||||
}
|
||||
},
|
||||
get_ble_data(callback) {
|
||||
if (callback != undefined)
|
||||
data_call = callback;
|
||||
},
|
||||
set_ble_mac(mac) {
|
||||
const bleInfo = this.globalData.bleInfo
|
||||
// 如果MAC地址与当前连接的相同,则不重复连接
|
||||
if (mac === bleInfo.current_connected_mac) {
|
||||
console.log('设备已连接,无需重复连接')
|
||||
return
|
||||
}
|
||||
if (mac != undefined && bleInfo.devicesList) {
|
||||
const device = bleInfo.devicesList.find(device =>
|
||||
device.name && device.name.toLowerCase().includes(mac.toLowerCase())
|
||||
)
|
||||
if (device) {
|
||||
bleInfo.ble_url = ''
|
||||
uni.hideLoading()
|
||||
bleInfo.ble_id = device.deviceId
|
||||
bleInfo.xBlufi.notifyConnectBle({
|
||||
isStart: true,
|
||||
deviceId: device.deviceId
|
||||
})
|
||||
uni.showToast({
|
||||
title: "连接蓝牙设备中",
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
})
|
||||
bleInfo.xBlufi.notifyInitBleEsp32({
|
||||
deviceId: device.deviceId
|
||||
})
|
||||
// 更新全局MAC地址
|
||||
bleInfo.current_connected_mac = mac
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "未找到匹配的设备",
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
set_ble_id(id, url) {
|
||||
console.log("id", id)
|
||||
if (id != undefined) {
|
||||
ble_url = url
|
||||
uni.hideLoading()
|
||||
ble_id = id
|
||||
xBlufi.notifyConnectBle({
|
||||
isStart: true,
|
||||
deviceId: id
|
||||
// name
|
||||
})
|
||||
uni.showToast({
|
||||
title: "连接蓝牙设备中",
|
||||
icon: 'none',
|
||||
duration: 3500
|
||||
})
|
||||
xBlufi.notifyInitBleEsp32({
|
||||
deviceId: id
|
||||
})
|
||||
}
|
||||
},
|
||||
ble_send(data) {
|
||||
if (data != undefined) {
|
||||
xBlufi.notifySendCustomData({
|
||||
customData: data,
|
||||
});
|
||||
}
|
||||
},
|
||||
get_user_iphone(data) {
|
||||
return user_info;
|
||||
},
|
||||
set_user_iphone(data) {
|
||||
console.log("电话存储")
|
||||
uni.setStorage({
|
||||
key: 'user_info',
|
||||
data: data,
|
||||
success: () => {
|
||||
console.log('已经缓存,userInfo:', data.phone);
|
||||
resolve('success')
|
||||
}
|
||||
});
|
||||
user_info = data
|
||||
},
|
||||
call(e) {
|
||||
call = e;
|
||||
},
|
||||
funListenDeviceMsgEvent(options) {
|
||||
switch (options.type) {
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_STATUS_CONNECTED:
|
||||
if (!options.result) {
|
||||
// 清除全局MAC地址
|
||||
this.globalData.bleInfo.current_connected_mac = null;
|
||||
const pages = getCurrentPages();
|
||||
const currentPage = pages[pages.length - 1];
|
||||
console.log("当前页面路径", currentPage.route)
|
||||
if (currentPage.route != 'pages/index/index') {
|
||||
uni.showModal({
|
||||
title: '设备提示!',
|
||||
content: '与设备断开请重联',
|
||||
showCancel: false,
|
||||
success: function (res) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_CONNECT_ROUTER_RESULT:
|
||||
uni.hideLoading();
|
||||
if (!options.result) {
|
||||
uni.hideLoading();
|
||||
uni.showModal({
|
||||
title: '温馨提示',
|
||||
content: '配网失败,请确认是2.4G模式并且账户密码正确',
|
||||
showCancel: false //是否显示取消按钮
|
||||
});
|
||||
} else {
|
||||
if (options.data.progress == 100) {
|
||||
let ssid = options.data.ssid;
|
||||
uni.hideLoading();
|
||||
uni.showModal({
|
||||
title: '温馨提示',
|
||||
content: `连接成功路由器`,
|
||||
showCancel: false,
|
||||
//是否显示取消按钮
|
||||
success: function (res) {
|
||||
// uni.navigateBack()
|
||||
uni.navigateTo({
|
||||
url: '/pages/dd/xiaoai'
|
||||
});
|
||||
console.log("确定成功之后 返回 ");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_RECIEVE_CUSTON_DATA:
|
||||
if (data_call != undefined) {
|
||||
data_call(options.data)
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS:
|
||||
if (options.result) {
|
||||
this.globalData.bleInfo.devicesList = options.data; // 假设你想在组件内部使用这个变量,应该这样设置
|
||||
console.log("获取设备列表", this.globalData.bleInfo.devicesList)
|
||||
if (call != undefined) {
|
||||
console.log("获取设备列表", this.globalData.bleInfo.devicesList)
|
||||
call(this.globalData.bleInfo.devicesList)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_CONNECTED:
|
||||
console.log("连接回调:" + JSON.stringify(options));
|
||||
if (options.result) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '连接成功',
|
||||
icon: 'none'
|
||||
});
|
||||
console.log("连接进入:", ble_url);
|
||||
// uni.navigateTo({ url: ble_url });
|
||||
}
|
||||
else {
|
||||
uni.showToast({
|
||||
title: '连接超时,请重新链接',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_START:
|
||||
if (!options.result) {
|
||||
uni.showToast({
|
||||
title: '蓝牙未开启解决方法',
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
});
|
||||
}
|
||||
break;
|
||||
case xBlufi.XBLUFI_TYPE.TYPE_GET_DEVICE_LISTS_STOP:
|
||||
if (options.result) {
|
||||
console.log('蓝牙停止搜索ok');
|
||||
} else {
|
||||
console.log('蓝牙停止搜索失败');
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
/*每个页面公共css */
|
||||
@import "uview-ui/index.scss";
|
||||
@import "./common/css/iconfont.css";
|
||||
|
||||
// 自定义tabar样式修改
|
||||
/deep/.u-tabbar__content__item__text {
|
||||
font-size: 20rpx !important;
|
||||
bottom: 10rpx !important;
|
||||
}
|
||||
|
||||
page {
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -1,141 +1,141 @@
|
|||
const install = (Vue, vm) => {
|
||||
// Vue.prototype.$u.http.setConfig({
|
||||
// baseURL: 'https://yruibao.com/admin',
|
||||
// // baseUrl: 'http://192.168.10.104:8088',
|
||||
// method: 'POST',
|
||||
// // 设置为json,返回后会对数据进行一次JSON.parse()
|
||||
// dataType: 'json',
|
||||
// showLoading: true, // 是否显示请求中的loading
|
||||
// loadingText: '...', // 请求loading中的文字提示
|
||||
// loadingTime: 800, // 在此时间内,请求还没回来的话,就显示加载中动画,单位ms
|
||||
// originalData: false, // 是否在拦截器中返回服务端的原始数据
|
||||
// loadingMask: true, // 展示loading的时候,是否给一个透明的蒙层,防止触摸穿透
|
||||
// // 配置请求头信息
|
||||
// header: {
|
||||
// 'content-type': 'application/json;charset=UTF-8',
|
||||
// },
|
||||
// });
|
||||
Vue.prototype.$u.http.setConfig({
|
||||
baseUrl: 'http://192.168.2.27:10002',
|
||||
// baseUrl: 'https://kg.chuangtewl.com/prod-api',
|
||||
// loadingText: '加载中...',
|
||||
// loadingTime: 1000,
|
||||
// 设置自定义头部content-type
|
||||
header: {
|
||||
'content-type': 'application/json;charset=UTF-8',
|
||||
},
|
||||
})
|
||||
// 请求拦截部分,如配置,每次请求前都会执行
|
||||
Vue.prototype.$u.http.interceptor.request = (config) => {
|
||||
// 引用token
|
||||
// 方式一,存放在vuex的token,假设使用了uView封装的vuex方式
|
||||
// 见:https://uviewui.com/components/globalVariable.html
|
||||
// config.header.token = vm.token;
|
||||
// 方式二,如果没有使用uView封装的vuex方法,那么需要使用$store.state获取
|
||||
// config.header.token = vm.$store.state.token;
|
||||
// 方式三,如果token放在了globalData,通过getApp().globalData获取
|
||||
// 方式四,如果token放在了Storage本地存储中,拦截是每次请求都执行的
|
||||
// 所以哪怕您重新登录修改了Storage,下一次的请求将会是最新值
|
||||
const token = uni.getStorageSync('token');
|
||||
// const token = " eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImE1ZmE2YzM0LWM0Y2YtNGEwMS05YjY2LTE1M2M4YWY1YzU1YSJ9.Wze_tAjY7cCfw2K6mtDpTSd-QFLRF4A49Fx7bq7g2tVLKL4v5bqqHfpG0VQy7_a_CUQch5RPBTBIKMVCDupIqg"
|
||||
// console.log("我是token", token)
|
||||
config.header.Authorization = token;
|
||||
// config.header.Tenant-Id=1
|
||||
// #ifdef H5
|
||||
config.header.Authorization = 'Bearer '+token;
|
||||
// #endif
|
||||
// 可以对某个url进行特别处理,此url参数为this.$u.get(url)中的url值
|
||||
if(config.url == '/user/login') config.header.noToken = true;
|
||||
// 最后需要将config进行return
|
||||
return config;
|
||||
|
||||
// 如果return一个false值,则会取消本次请求
|
||||
// if(config.url == '/user/rest') return false; // 取消某次请求
|
||||
}
|
||||
|
||||
// 响应拦截,如配置,每次请求结束都会执行本方法
|
||||
Vue.prototype.$u.http.interceptor.response = (res) => {
|
||||
// if(res.code == 10022 || res.code == 10023) {
|
||||
// // res为服务端返回值,可能有code,result等字段
|
||||
// // 这里对res.result进行返回,将会在this.$u.post(url).then(res => {})的then回调中的res的到
|
||||
// // 如果配置了originalData为true,请留意这里的返回值
|
||||
// uni.redirectTo({
|
||||
// url:"/pages/login/login",
|
||||
// fail:function(mes){
|
||||
// console.log(mes)
|
||||
// },
|
||||
// success:function(mes){
|
||||
// console.log(mes)
|
||||
// }
|
||||
// })
|
||||
// // return res.result;
|
||||
// }
|
||||
if(res.code == 401) {
|
||||
// res为服务端返回值,可能有code,result等字段
|
||||
// 这里对res.result进行返回,将会在this.$u.post(url).then(res => {})的then回调中的res的到
|
||||
// 如果配置了originalData为true,请留意这里的返回值
|
||||
|
||||
// return res.result;
|
||||
|
||||
uni.login({
|
||||
success: function(ret) {
|
||||
// console.log("main.js==>res", ret)
|
||||
// vm.$u.post('/user/login',{"js_code": ret.code}).then(res=>{
|
||||
// if (res.code == 10003) {
|
||||
// // console.log("新用户登录")
|
||||
// uni.setStorageSync('token', res.data);
|
||||
|
||||
// } else if (res.code == 200) {
|
||||
// // console.log("老用户登录",res.data)
|
||||
// uni.setStorageSync('token', res.data);
|
||||
|
||||
// }
|
||||
// });
|
||||
}
|
||||
})
|
||||
wx.login({
|
||||
success(res) {
|
||||
if (res.code) {
|
||||
console.log('登录!', res);
|
||||
let data = {
|
||||
loginCode: res.code,
|
||||
appId:1
|
||||
}
|
||||
vm.$u.post('/app/auth/wxLogin',data).then(res=>{
|
||||
if (res.code == 10003) {
|
||||
// uni.navigateTo({
|
||||
// url:'/pages/login/login'
|
||||
// })
|
||||
|
||||
} else if (res.code == 200) {
|
||||
// console.log("老用户登录",res.data)
|
||||
// uni.switchTab({
|
||||
// url:'/pages/index/index'
|
||||
// })
|
||||
uni.setStorageSync('token', res.token)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
return res;
|
||||
// else if(res.code == 201) {
|
||||
// // 假设201为token失效,这里跳转登录
|
||||
// vm.$u.toast('验证失败,请重新登录');
|
||||
// setTimeout(() => {
|
||||
// // 此为uView的方法,详见路由相关文档
|
||||
// vm.$u.route('/pages/user/login')
|
||||
// }, 1500)
|
||||
// return false;
|
||||
// } else {
|
||||
// // 如果返回false,则会调用Promise的reject回调,
|
||||
// // 并将进入this.$u.post(url).then().catch(res=>{})的catch回调中,res为服务端的返回值
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
install
|
||||
const install = (Vue, vm) => {
|
||||
// Vue.prototype.$u.http.setConfig({
|
||||
// baseURL: 'https://yruibao.com/admin',
|
||||
// // baseUrl: 'http://192.168.10.104:8088',
|
||||
// method: 'POST',
|
||||
// // 设置为json,返回后会对数据进行一次JSON.parse()
|
||||
// dataType: 'json',
|
||||
// showLoading: true, // 是否显示请求中的loading
|
||||
// loadingText: '...', // 请求loading中的文字提示
|
||||
// loadingTime: 800, // 在此时间内,请求还没回来的话,就显示加载中动画,单位ms
|
||||
// originalData: false, // 是否在拦截器中返回服务端的原始数据
|
||||
// loadingMask: true, // 展示loading的时候,是否给一个透明的蒙层,防止触摸穿透
|
||||
// // 配置请求头信息
|
||||
// header: {
|
||||
// 'content-type': 'application/json;charset=UTF-8',
|
||||
// },
|
||||
// });
|
||||
Vue.prototype.$u.http.setConfig({
|
||||
// baseUrl: 'http://192.168.2.27:10002',
|
||||
baseUrl: 'https://kg.chuangtewl.com/prod-api',
|
||||
// loadingText: '加载中...',
|
||||
// loadingTime: 1000,
|
||||
// 设置自定义头部content-type
|
||||
header: {
|
||||
'content-type': 'application/json;charset=UTF-8',
|
||||
},
|
||||
})
|
||||
// 请求拦截部分,如配置,每次请求前都会执行
|
||||
Vue.prototype.$u.http.interceptor.request = (config) => {
|
||||
// 引用token
|
||||
// 方式一,存放在vuex的token,假设使用了uView封装的vuex方式
|
||||
// 见:https://uviewui.com/components/globalVariable.html
|
||||
// config.header.token = vm.token;
|
||||
// 方式二,如果没有使用uView封装的vuex方法,那么需要使用$store.state获取
|
||||
// config.header.token = vm.$store.state.token;
|
||||
// 方式三,如果token放在了globalData,通过getApp().globalData获取
|
||||
// 方式四,如果token放在了Storage本地存储中,拦截是每次请求都执行的
|
||||
// 所以哪怕您重新登录修改了Storage,下一次的请求将会是最新值
|
||||
const token = uni.getStorageSync('token');
|
||||
// const token = " eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImE1ZmE2YzM0LWM0Y2YtNGEwMS05YjY2LTE1M2M4YWY1YzU1YSJ9.Wze_tAjY7cCfw2K6mtDpTSd-QFLRF4A49Fx7bq7g2tVLKL4v5bqqHfpG0VQy7_a_CUQch5RPBTBIKMVCDupIqg"
|
||||
// console.log("我是token", token)
|
||||
config.header.Authorization = token;
|
||||
// config.header.Tenant-Id=1
|
||||
// #ifdef H5
|
||||
config.header.Authorization = 'Bearer '+token;
|
||||
// #endif
|
||||
// 可以对某个url进行特别处理,此url参数为this.$u.get(url)中的url值
|
||||
if(config.url == '/user/login') config.header.noToken = true;
|
||||
// 最后需要将config进行return
|
||||
return config;
|
||||
|
||||
// 如果return一个false值,则会取消本次请求
|
||||
// if(config.url == '/user/rest') return false; // 取消某次请求
|
||||
}
|
||||
|
||||
// 响应拦截,如配置,每次请求结束都会执行本方法
|
||||
Vue.prototype.$u.http.interceptor.response = (res) => {
|
||||
// if(res.code == 10022 || res.code == 10023) {
|
||||
// // res为服务端返回值,可能有code,result等字段
|
||||
// // 这里对res.result进行返回,将会在this.$u.post(url).then(res => {})的then回调中的res的到
|
||||
// // 如果配置了originalData为true,请留意这里的返回值
|
||||
// uni.redirectTo({
|
||||
// url:"/pages/login/login",
|
||||
// fail:function(mes){
|
||||
// console.log(mes)
|
||||
// },
|
||||
// success:function(mes){
|
||||
// console.log(mes)
|
||||
// }
|
||||
// })
|
||||
// // return res.result;
|
||||
// }
|
||||
if(res.code == 401) {
|
||||
// res为服务端返回值,可能有code,result等字段
|
||||
// 这里对res.result进行返回,将会在this.$u.post(url).then(res => {})的then回调中的res的到
|
||||
// 如果配置了originalData为true,请留意这里的返回值
|
||||
|
||||
// return res.result;
|
||||
|
||||
uni.login({
|
||||
success: function(ret) {
|
||||
// console.log("main.js==>res", ret)
|
||||
// vm.$u.post('/user/login',{"js_code": ret.code}).then(res=>{
|
||||
// if (res.code == 10003) {
|
||||
// // console.log("新用户登录")
|
||||
// uni.setStorageSync('token', res.data);
|
||||
|
||||
// } else if (res.code == 200) {
|
||||
// // console.log("老用户登录",res.data)
|
||||
// uni.setStorageSync('token', res.data);
|
||||
|
||||
// }
|
||||
// });
|
||||
}
|
||||
})
|
||||
wx.login({
|
||||
success(res) {
|
||||
if (res.code) {
|
||||
console.log('登录!', res);
|
||||
let data = {
|
||||
loginCode: res.code,
|
||||
appId:1
|
||||
}
|
||||
vm.$u.post('/app/auth/wxLogin',data).then(res=>{
|
||||
if (res.code == 10003) {
|
||||
// uni.navigateTo({
|
||||
// url:'/pages/login/login'
|
||||
// })
|
||||
|
||||
} else if (res.code == 200) {
|
||||
// console.log("老用户登录",res.data)
|
||||
// uni.switchTab({
|
||||
// url:'/pages/index/index'
|
||||
// })
|
||||
uni.setStorageSync('token', res.token)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
return res;
|
||||
// else if(res.code == 201) {
|
||||
// // 假设201为token失效,这里跳转登录
|
||||
// vm.$u.toast('验证失败,请重新登录');
|
||||
// setTimeout(() => {
|
||||
// // 此为uView的方法,详见路由相关文档
|
||||
// vm.$u.route('/pages/user/login')
|
||||
// }, 1500)
|
||||
// return false;
|
||||
// } else {
|
||||
// // 如果返回false,则会调用Promise的reject回调,
|
||||
// // 并将进入this.$u.post(url).then().catch(res=>{})的catch回调中,res为服务端的返回值
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
install
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name" : "kaiguan",
|
||||
"appid" : "__UNI__F877C47",
|
||||
"appid" : "__UNI__96CC1F5",
|
||||
"description" : "",
|
||||
"versionName" : "1.0.0",
|
||||
"versionCode" : "100",
|
||||
|
|
95
package-lock.json
generated
95
package-lock.json
generated
|
@ -1,40 +1,55 @@
|
|||
{
|
||||
"name": "dianbiao",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"echarts": {
|
||||
"version": "5.4.3",
|
||||
"resolved": "https://registry.npmjs.org/echarts/-/echarts-5.4.3.tgz",
|
||||
"integrity": "sha512-mYKxLxhzy6zyTi/FaEbJMOZU1ULGEQHaeIeuMR5L+JnJTpz+YR03mnnpBhbR4+UYJAgiXgpyTVLffPAjOTLkZA==",
|
||||
"requires": {
|
||||
"tslib": "2.3.0",
|
||||
"zrender": "5.4.4"
|
||||
}
|
||||
},
|
||||
"js-base64": {
|
||||
"version": "3.7.5",
|
||||
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-3.7.5.tgz",
|
||||
"integrity": "sha512-3MEt5DTINKqfScXKfJFrRbxkrnk2AxPWGBL/ycjz4dK8iqiSJ06UxD8jh8xuh6p10TX4t2+7FsBYVxxQbMg+qA=="
|
||||
},
|
||||
"tslib": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz",
|
||||
"integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg=="
|
||||
},
|
||||
"uview-ui": {
|
||||
"version": "1.8.8",
|
||||
"resolved": "https://registry.npmjs.org/uview-ui/-/uview-ui-1.8.8.tgz",
|
||||
"integrity": "sha512-Osal3yzXiHor0In9OPTZuXTaqTbDglMZ9RGK/MPYDoQQs+y0hrBCUD0Xp5T70C8i2lLu2X6Z11zJhmsQWMR7Jg=="
|
||||
},
|
||||
"zrender": {
|
||||
"version": "5.4.4",
|
||||
"resolved": "https://registry.npmjs.org/zrender/-/zrender-5.4.4.tgz",
|
||||
"integrity": "sha512-0VxCNJ7AGOMCWeHVyTrGzUgrK4asT4ml9PEkeGirAkKNYXYzoPJCLvmyfdoOXcjTHPs10OZVMfD1Rwg16AZyYw==",
|
||||
"requires": {
|
||||
"tslib": "2.3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
"name": "dianbiao",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "dianbiao",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"dianbiao": "file:",
|
||||
"echarts": "^5.4.0",
|
||||
"js-base64": "^3.7.3",
|
||||
"uview-ui": "^1.8.8"
|
||||
}
|
||||
},
|
||||
"node_modules/dianbiao": {
|
||||
"resolved": "",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/echarts": {
|
||||
"version": "5.4.3",
|
||||
"resolved": "https://registry.npmjs.org/echarts/-/echarts-5.4.3.tgz",
|
||||
"integrity": "sha512-mYKxLxhzy6zyTi/FaEbJMOZU1ULGEQHaeIeuMR5L+JnJTpz+YR03mnnpBhbR4+UYJAgiXgpyTVLffPAjOTLkZA==",
|
||||
"dependencies": {
|
||||
"tslib": "2.3.0",
|
||||
"zrender": "5.4.4"
|
||||
}
|
||||
},
|
||||
"node_modules/js-base64": {
|
||||
"version": "3.7.5",
|
||||
"resolved": "https://registry.npmjs.org/js-base64/-/js-base64-3.7.5.tgz",
|
||||
"integrity": "sha512-3MEt5DTINKqfScXKfJFrRbxkrnk2AxPWGBL/ycjz4dK8iqiSJ06UxD8jh8xuh6p10TX4t2+7FsBYVxxQbMg+qA=="
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz",
|
||||
"integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg=="
|
||||
},
|
||||
"node_modules/uview-ui": {
|
||||
"version": "1.8.8",
|
||||
"resolved": "https://registry.npmjs.org/uview-ui/-/uview-ui-1.8.8.tgz",
|
||||
"integrity": "sha512-Osal3yzXiHor0In9OPTZuXTaqTbDglMZ9RGK/MPYDoQQs+y0hrBCUD0Xp5T70C8i2lLu2X6Z11zJhmsQWMR7Jg=="
|
||||
},
|
||||
"node_modules/zrender": {
|
||||
"version": "5.4.4",
|
||||
"resolved": "https://registry.npmjs.org/zrender/-/zrender-5.4.4.tgz",
|
||||
"integrity": "sha512-0VxCNJ7AGOMCWeHVyTrGzUgrK4asT4ml9PEkeGirAkKNYXYzoPJCLvmyfdoOXcjTHPs10OZVMfD1Rwg16AZyYw==",
|
||||
"dependencies": {
|
||||
"tslib": "2.3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
51
package.json
51
package.json
|
@ -1,25 +1,26 @@
|
|||
{
|
||||
"name": "dianbiao",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/lchighpass/lchighpass-speaking.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/lchighpass/lchighpass-speaking/issues"
|
||||
},
|
||||
"homepage": "https://github.com/lchighpass/lchighpass-speaking#readme",
|
||||
"dependencies": {
|
||||
"echarts": "^5.4.0",
|
||||
"js-base64": "^3.7.3",
|
||||
"uview-ui": "^1.8.8"
|
||||
}
|
||||
}
|
||||
{
|
||||
"name": "dianbiao",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/lchighpass/lchighpass-speaking.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/lchighpass/lchighpass-speaking/issues"
|
||||
},
|
||||
"homepage": "https://github.com/lchighpass/lchighpass-speaking#readme",
|
||||
"dependencies": {
|
||||
"dianbiao": "file:",
|
||||
"echarts": "^5.4.0",
|
||||
"js-base64": "^3.7.3",
|
||||
"uview-ui": "^1.8.8"
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -50,6 +50,7 @@ function initXBlufi(type) {
|
|||
break;
|
||||
|
||||
case XMQTT_SYSTEM.WeChat:
|
||||
console.log("初始化@@@@@@@!!!!!!!!!!!!")
|
||||
if(once==0)
|
||||
{
|
||||
once = 1;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
3824
pages/shanghudd.vue
3824
pages/shanghudd.vue
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user