123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- import Vue from 'vue'
- import { mapState,mapMutations} from 'vuex'
- import authorize from '@/common/config/authorize.js'
- const appMixins = {
- computed: {
- ...mapState(['hasLogin','isWxAuthorize'])
- },
- methods: {
- ...mapMutations(['login','logout','updateNoticeNum']),
- async getWxAuthorize(){
- const wechatCode = await authorize.getCode('weixin')// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
- const getUserInfo = await authorize.getUserInfo('weixin')
- this.UserService.UserLoginAuthApplets({
- code:wechatCode,
- encryptedData:getUserInfo.encryptedData,
- iv:getUserInfo.iv
- })
- .then(response =>{
- this.$store.commit('updateStatus',response.data)
- this.login(response.data)
- uni.setStorageSync('token',response.data.token)
- uni.setStorageSync('unionId',response.data.unionId)
- })
- .catch(error =>{
- this.logout(error.data)
- this.$store.commit('updateStatus',error.data)
- uni.setStorageSync('unionId',error.data.unionId)
- })
- },
- appUpdataRefresh(){
- let TIME = (20*60)*1000
- setInterval(()=>{
- this.getWxAuthorize()
- },TIME)
- },
- diffTime(t){
- let date = Date.now()
- return (date -t) < 2*60*1000 ? false : true
- },
- initSetSystemInfo() {
- let self = this
- uni.getSystemInfo({
- success: function(e) {
- let modelmes = e.model
- console.log(e)
- if (modelmes.search('iPhone 11') !== -1 || modelmes.search('iPhone 11 Pro Max') !==
- -1 || modelmes.search('iPhone X') != -1) { //XS,XR,XS MAX均可以适配
- self.$store.dispatch('setVariableFun', true)
- } else {
- self.$store.dispatch('setVariableFun', false)
- }
- // #ifndef MP
- Vue.prototype.StatusBar = e.statusBarHeight
- if (e.platform == 'android') {
- Vue.prototype.CustomBar = e.statusBarHeight + 50
- Vue.prototype.platformClass = true
- } else {
- Vue.prototype.CustomBar = e.statusBarHeight + 45
- Vue.prototype.platformClass = false
- };
- // #endif
- // #ifdef MP-WEIXIN || MP-QQ
- console.log(e.platform)
- if (e.platform == 'android') {
- Vue.prototype.platformClass = 'left'
- self.$store.dispatch('setVariableFun', false)
- } else {
- Vue.prototype.platformClass = 'center'
- self.$store.dispatch('setIsIphoneFun', true)
- }
- Vue.prototype.StatusBar = e.statusBarHeight
- Vue.prototype.fontSizeSetting = e.fontSizeSetting
- Vue.prototype.screenWidth = e.screenWidth
- let capsule = wx.getMenuButtonBoundingClientRect()
- Vue.prototype.capsule = capsule
- if (capsule) {
- Vue.prototype.Custom = capsule
- Vue.prototype.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight
- } else {
- Vue.prototype.CustomBar = e.statusBarHeight + 50
- }
- // #endif
- // #ifdef MP-ALIPAY
- Vue.prototype.StatusBar = e.statusBarHeight
- Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight
- // #endif
- }
- })
- }
- }
- }
- export default appMixins
|