123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- <script>
- // // #ifdef APP-PLUS
- // import {
- // registerRequestPermissionTipsListener,
- // unregisterRequestPermissionTipsListener,
- // setRequestPermissionTips
- // } from "@/uni_modules/uni-registerRequestPermissionTips"
- // var PermissionTips = {
- // "android.permission.CAMERA": "<h4 style=\"font-size:40px;\">正在获取相机、存储权限</h4><font color=#cccccc>该权限用于获取设备拍摄或获取本地应用相册,进行头像或图片上传。</font>",
- // "android.permission.WRITE_EXTERNAL_STORAGE": "<h4 style=\"font-size:40px;\">正在获取相机、存储权限</h4><font color=#cccccc>该权限用于获取设备拍摄或获取本地应用相册,进行头像或图片上传。</font>",
- // "android.permission.READ_EXTERNAL_STORAGE": "<h4 style=\"font-size:40px;\">正在获取相机、存储权限</h4><font color=#cccccc>该权限用于获取设备拍摄或获取本地应用相册,进行头像或图片上传。</font>",
- // "android.permission.RECORD_AUDIO": "<h4 style=\"font-size:40px;\">正在获取麦克风权限</h4><font color=#cccccc>该权限用于获取设备语音通话、语音等录音或通讯场景所需。</font>"
- // }
- // // #endif
- const tabbars = ['/pages/my/my', '/pages/make/index', '/pages/message/mailMessage', '/pages/index/index']
- export default {
- globalData: {
- postHeader: null,
- headerSign: '',
- uuid: '',
- skey: '',
- isLogin: 0,
- userId: 0,
- socket: null,
- postHeader: null,
- systemInfo: null
- },
- beforeDestroy() {},
- onLaunch: function(options) {
- // #ifdef APP-PLUS
- // var brand = uni.getSystemInfoSync().deviceBrand
- // setRequestPermissionTips(PermissionTips)
- // registerRequestPermissionTipsListener({
- // onRequest: (e) => {
- // console.log(e)
- // },
- // onConfirm: (e) => {
- // console.log(e)
- // },
- // onComplete: (e) => {
- // // 华为手机在权限禁止之后,再次申请权限不会出现权限申请框。此时应该引导用户去系统设置开启此权限,不应该频繁申请。
- // if (brand.toLowerCase() == "huawei" || true) {
- // var tips = {}
- // var hasDeniedPermission = false
- // for (var k in PermissionTips) {
- // if (e[k] != "denied") {
- // tips[k] = PermissionTips[k]
- // } else {
- // hasDeniedPermission = true
- // }
- // }
- // setRequestPermissionTips(tips) // 更新弹框提醒,防止华为手机不出现权限申请框时权限提醒框闪烁的情况
- // if (hasDeniedPermission)
- // uni.showModal({
- // content: "权限已经被拒绝,请前往设置中开启"
- // })
- // }
- // }
- // });
- // #endif
- let deviceId = "";
- let uuid2 = uni.getStorageSync("app_uuid");
- if (uuid2 && uuid2.length >= 6) {
- deviceId = uuid2;
- } else {
- deviceId = uni.getSystemInfoSync().deviceId || uni.getDeviceInfo().deviceId;
- if (!deviceId || deviceId.length < 6) {
- deviceId = this.generateUUID();
- } else {
- // uni.setStorageSync("app_uuid", deviceId);
- }
- }
- if (deviceId && deviceId.length >= 6) {} else {
- deviceId = new Date().getTime()
- }
- this.globalData.uuid = deviceId;
- uni.setStorageSync("app_uuid", deviceId);
- // this.globalData.uuid = "";
- let skey = uni.getStorageSync("wapptoken");
- if (skey != null && skey != "" && skey != undefined) {
- this.globalData.skey = skey;
- }
- if (this.globalData.headerSign == "") {
- let headerSignKKK = uni.getStorageSync("headerSign");
- if (headerSignKKK != null && headerSignKKK != "" && headerSignKKK != undefined) {
- this.globalData.headerSign = headerSignKKK;
- }
- }
- // uni.getPushClientId({
- // success: (res) => {
- // console.log(res.cid);
- // // this.push_token = res.cid;
- // },
- // fail(err) {
- // console.log(err)
- // }
- // })
- // this.$nextTick(async () => {
- // for (var i = 0; i < tabbars.length; i++) {
- // await this.go(tabbars[i])
- // console.log('page:', i);
- // }
- // // uni.$store.commit('user/setPageState', 'loadmore')
- // })
- // #ifdef APP
- plus.navigator.closeSplashscreen()
- // #endif
- },
- onShow: function(options) {
- console.log('App Show');
- // setTimeout(()=>{
- // uni.hideTabBar()
- // },100)
- },
- onHide: function() {
- console.log('App Hide');
- },
- onExit: function() {
- unregisterRequestPermissionTipsListener(null)
- },
- onAppBackground() {},
- methods: {
- generateUUID() {
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
- const r = Math.random() * 16 | 0;
- const v = c === 'x' ? r : (r & 0x3 | 0x8);
- return v.toString(16);
- });
- },
- go(url) {
- return new Promise((resolve) => {
- uni.switchTab({
- url,
- complete: () => {
- setTimeout(() => {
- resolve()
- }, 100)
- }
- })
- })
- },
- }
- };
- </script>
- <style lang="scss">
- /*每个页面公共css */
- @import 'colorui/main.css';
- @import 'colorui/icon.css';
- @import 'style/FontStyle.css';
- body {
- -webkit-text-size-adjust: none;
- overscroll-behavior-y: contain;
- -webkit-overflow-scrolling: touch;
- background-color: #161616;
- // background: url('./http://c.yujianmate.com/images/v1/bg.png');
- // background-size: 750rpx 1624rpx;
- background-repeat: repeat-y;
- }
- /* 超出一行省略号 */
- .one-omit {
- white-space: nowrap;
- /*规定段落中的文本不进行换行*/
- overflow: hidden;
- /*内容会被修剪,并且其余内容是不可见的。*/
- text-overflow: ellipsis;
- /*显示省略号来代表被修剪的文本*/
- }
- .two-omit {
- display: -webkit-box;
- -webkit-line-clamp: 2;
- overflow: hidden;
- text-overflow: ellipsis;
- -webkit-box-orient: vertical;
- }
- img {
- width: 100%;
- }
- uni-modal {
- z-index: 998 !important;
- }
- .cu-modal {
- z-index: 997 !important;
- }
- </style>
|