| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <script>
- //app.js
- const req = require("./utils/request.js");
- // // #ifndef H5
- // let livePlayer = requirePlugin('live-player-plugin')
- // // #endif
- export default {
- onLaunch: function(options) {
- // this.globalData.appInitData();
- this.globalData.InitUpdateManager();
- this.globalData.getChatList();
- //
- uni.hideTabBar()
- },
- onShow(options) {
- let scene = options.scene;
- req.setStorage('scene',scene)
- this.globalData.getVideoScene();
- // // #ifndef H5
- // // 分享卡片/订阅消息/扫码二维码/广告/朋友圈等场景才能调用getShareParams接口获取以下参数
- // const sceneList = [1007, 1008, 1014, 1044, 1045, 1046, 1047, 1048, 1049, 1073, 1154, 1155]
- // if (sceneList.includes(options.scene)) {
- // livePlayer.getShareParams()
- // .then(res => {
- // // 房间号
- // console.log('get room id', res.room_id)
- // // 用户openid
- // console.log('get openid', res.openid)
- // // 分享者openid,分享卡片进入场景才有
- // console.log('get share openid', res.share_openid)
- // // 开发者在跳转进入直播间页面时,页面路径上携带的自定义参数,这里传回给开发者
- // console.log('get custom params', res.custom_params)
- // if(res.custom_params){
- // req.setStorage('pidCode',res.custom_params.userId)
- // }
- // }).catch(err => {
- // console.log('get share params', err)
- // })
- // }
- // // #endif
- },
- globalData: {
- //获取客服配置
- getChatList() {
- req.getRequest('/api/customer/list', {}, res => {
- req.setStorage('chatService', res);
- });
- },
- appInitData() {
- var getSysInfo = uni.getSystemInfoSync();
- this.isIPhone = getSysInfo.model.indexOf("iPhone") != -1;
- this.isIPhoneX = getSysInfo.model.indexOf("iPhone X") != -1 || getSysInfo.model.indexOf("iPhone 11") != -
- 1; // 是否为全面屏
- this.isFullScreen = getSysInfo.screenHeight / getSysInfo.screenWidth >= 2.1; // iPhoneX底部空白高度为68,全面屏为20
- this.bottomBlankHeignt = this.isIPhoneX ? 68 : this.isFullScreen ? 10 : 0;
- this.height = getSysInfo.statusBarHeight;
- this.screenHeight = getSysInfo.screenHeight;
- },
- getVideoScene(){
- let scene = req.getStorage('scene');
- let arr = [1195,1193,1191,1184,1177,1176,1175,1201,1216,10001]
- req.setStorage('isVideoScene',false)
- arr.some(it=>{
- if(it === scene){
- req.setStorage('isVideoScene',true)
- }
- })
- console.log('isVideoScene==',req.getStorage('isVideoScene'))
- },
- InitUpdateManager() {
- const updateManager = uni.getUpdateManager();
- let that = this;
- updateManager.onCheckForUpdate(function(res) {
- // 请求完新版本信息的回调
- console.log(res.hasUpdate);
- });
- updateManager.onUpdateReady(function() {
- uni.showModal({
- title: '更新提示',
- content: '新版本已经准备好,是否重启应用?',
- success: function(res) {
- if (res.confirm) {
- // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
- uni.clearStorage({
- success() {
- updateManager.applyUpdate();
- }
- });
- }
- }
- });
- });
- updateManager.onUpdateFailed(function() { // 新版本下载失败
- });
- },
- getCheckSessoin(success) {
- // var sessionKey = req.getStorage('SESSION_KEY');
- // let that = this;
- // wx.checkSession({
- // success() {
- // if (!sessionKey) {
- // that.getSessionKey(success);
- // } else {
- // success.call(this, sessionKey);
- // }
- // },
- // fail() {
- // that.getSessionKey(success);
- // }
- // })
- this.getSessionKey(success);
- },
- getSessionKey(success) {
- let that = this;
- uni.login({
- success(res) {
- req.postRequest('/api/code', {
- code: res.code
- }, data => {
- that.SESSION_KEY = data.session_key;
- req.setStorage('SESSION_KEY', data.session_key);
- success.call(this, data);
- }, true);
- }
- });
- },
- userInfo: null,
- height: 0,
- isredenvelopes:true,
- isLayerAd:true,
- /**
- * 打开新页面
- */
- openPage(e) {
- let url
- if (e.indexOf("plugin-private:") != -1) {
- url = `${e}`
- } else {
- url = `/${e}`
- }
- uni.navigateTo({
- // url: `/${e}`
- url: url
- });
- // uni.navigateTo({
- // url: `/${e}`
- // });
- },
- /**
- *
- * 关闭当前页面,跳转到应用内的某个页面。
- */
- redirectTab(path) {
- uni.redirectTo({
- url: `/${path}`
- });
- },
- /**
- *
- * 跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面
- */
- switchTab(path) {
- uni.switchTab({
- url: `/${path}`
- });
- },
- /**
- *
- * 关闭所有页面,打开到应用内的某个页面
- */
- reLaunchTo(path) {
- uni.reLaunch({
- url: `/${path}`
- });
- },
- /**
- *
- * 保留当前页面,跳转到应用内的某个页面
- */
- navigateTo(path) {
- uni.navigateTo({
- url: `/${path}`
- });
- }
- },
- methods: {}
- };
- </script>
- <style>
- @import "./app.css";
- </style>
|