| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <style lang="scss">
- /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
- @import "@/uni_modules/uview-ui/index.scss";
- </style>
- <script>
- import config from './config'
- import store from '@/store'
- import { getToken } from '@/utils/auth'
- export default {
- onLaunch: function(option) {
- uni.removeStorageSync("device_sn")
- uni.removeStorageSync("sessionId")
- uni.removeStorageSync("title")
- uni.removeStorageSync("channel")
- console.log('option>onLaunch>>>>'+JSON.stringify( option.query))
- if( option.query.sn!=''&&option.query.sn!=null){
- uni.setStorageSync("device_sn",option.query.sn)
- }else{
-
- // uni.showModal({
- // title: '提示',
- // content: '设备码获取失败请重新扫码',
- // showCancel:false,
- // success: function (res) {
- // if (res.confirm) {
- // console.log('用户点击确定');
- // } else if (res.cancel) {
- // console.log('用户点击取消');
- // }
- // }
- // });
- // return;
- }
- //Object.keys(option.query).includes('sessionId') &&
- if( option.query.sessionId!=''&&option.query.sessionId!=null){
- uni.setStorageSync("sessionId",option.query.sessionId)
- }else{
- // uni.showModal({
- // title: '提示',
- // content: '小程序加载失败请重新扫码',
- // showCancel:false,
- // success: function (res) {
- // if (res.confirm) {
- // console.log('用户点击确定');
- // } else if (res.cancel) {
- // console.log('用户点击取消');
- // }
- // }
- // });
- // return;
- }
- this.initApp()
- },
- onShow(option) {
- // 热启动时获取参数
- console.log('option>onShow>>>>'+JSON.stringify( option))
- uni.removeStorageSync("device_sn")
- uni.removeStorageSync("sessionId")
- uni.removeStorageSync("title")
- uni.removeStorageSync("channel")
- console.log('option>onLaunch>>>>'+JSON.stringify( option.query))
- if( option.query.sn!=''&&option.query.sn!=null){
- uni.setStorageSync("device_sn",option.query.sn)
- }else{
- uni.setStorageSync("device_sn",'')
- }
-
- if( option.query.channel!=''&&option.query.channel!=null){
- uni.setStorageSync("channel",option.query.channel)
- }else{
- uni.setStorageSync("channel",'')
- }
-
- //Object.keys(option.query).includes('sessionId') &&
- if( option.query.sessionId!=''&&option.query.sessionId!=null){
- uni.setStorageSync("sessionId",option.query.sessionId)
- }else{
- uni.setStorageSync("sessionId",'')
- }
- if( option.query.title!=''&&option.query.title!=null){
- uni.setStorageSync("title",option.query.title)
- }else{
- uni.setStorageSync("title",'')
- }
- },
- methods: {
- // 初始化应用
- initApp() {
- // 初始化应用配置
- this.initConfig()
- // 检查用户登录状态
- //#ifdef H5
- this.checkLogin()
- //#endif
- },
- initConfig() {
- this.globalData.config = config
- },
- checkLogin() {
- // if (!getToken()) {
- // this.$tab.reLaunch('/pages/login')
- // }
- }
- }
- }
- </script>
- <style lang="scss">
- </style>
|