|
@@ -3,111 +3,75 @@
|
|
|
* vuex管理登陆状态,具体可以参考官方登陆模板示例
|
|
|
*/
|
|
|
import Vue from 'vue'
|
|
|
-import { mapState, mapMutations } from 'vuex'
|
|
|
-import authorize from '@/common/authorize.js'
|
|
|
-import wxLogin from '@/services/wxLogin.js'
|
|
|
+import { mapActions, mapMutations } from 'vuex'
|
|
|
export default {
|
|
|
onLaunch: function() {
|
|
|
- let self = this
|
|
|
- uni.getSystemInfo({
|
|
|
- success: function(e) {
|
|
|
- let modelmes = e.model
|
|
|
- self.$store.commit('app/setWindowHeight', e.windowHeight)
|
|
|
- // iphone x以上的版本都要控制下巴高度
|
|
|
- if (/iphone [1|x]\s?/i.test(modelmes)) {
|
|
|
- self.$store.dispatch('app/setVariableFun', true)
|
|
|
- } else {
|
|
|
- self.$store.dispatch('app/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('app/setVariableFun', false)
|
|
|
- } else {
|
|
|
- Vue.prototype.platformClass = 'center'
|
|
|
- self.$store.dispatch('app/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.capsuleSafe = uni.upx2px(750) - capsule.left + uni.upx2px(750) - capsule.right;
|
|
|
- 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
|
|
|
- }
|
|
|
- })
|
|
|
- this.refresh()
|
|
|
- if (uni.getStorageSync('isActivityStatus')) {
|
|
|
- const lockTime = uni.getStorageSync('lockTime')
|
|
|
- const eTime = this.diffTime(lockTime)
|
|
|
- this.$store.dispatch('app/setActivityFn', eTime)
|
|
|
- } else {
|
|
|
- this.$store.dispatch('app/setActivityFn', true)
|
|
|
- }
|
|
|
+ this.initSystemInfo()
|
|
|
+ // 判断优惠券弹窗是否显示
|
|
|
+ this.checkShowCouponPopup()
|
|
|
},
|
|
|
methods: {
|
|
|
- ...mapMutations('app', ['login', 'logout', 'updateStatus']),
|
|
|
- async getWxAuthorize() {
|
|
|
- const wechatCode = await authorize.getCode('weixin')
|
|
|
- this.UserService.userInfoLogin({
|
|
|
- code: wechatCode
|
|
|
- })
|
|
|
- .then(response => {
|
|
|
- this.login(response.data)
|
|
|
- this.updateStatus(response.data)
|
|
|
- })
|
|
|
- .catch(error => {
|
|
|
- uni.setStorage({
|
|
|
- //缓存游客用户openid
|
|
|
- key: 'openid',
|
|
|
- data: error.data.openid
|
|
|
- })
|
|
|
- this.logout()
|
|
|
- })
|
|
|
- },
|
|
|
- refresh() {
|
|
|
- let TIME = 20 * 60 * 1000
|
|
|
- setInterval(() => {
|
|
|
- authorize
|
|
|
- .getSetting()
|
|
|
- .then(res => {
|
|
|
- // console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
|
|
|
- if (res == 1) {
|
|
|
- this.getWxAuthorize()
|
|
|
- } else {
|
|
|
- console.log('授权失败============>:' + '用户取消授权或者未操作')
|
|
|
- }
|
|
|
- })
|
|
|
- .catch(error => {
|
|
|
- console.log('授权失败============>:' + '用户授权失败,提醒用户重新授权')
|
|
|
- })
|
|
|
- }, TIME)
|
|
|
+ ...mapActions('app', ['setWindowHeight', 'setVariableFun']),
|
|
|
+ ...mapMutations('coupon', ['setCouponPopupStatus']),
|
|
|
+ ...mapMutations('app', ['setWindowHeight']),
|
|
|
+ // 验证是否需要显示优惠券入口弹窗
|
|
|
+ checkShowCouponPopup() {
|
|
|
+ const couponPopupType = uni.getStorageSync('couponPopupType')
|
|
|
+ const nowDay = new Date().getDay()
|
|
|
+ // 新用户 当天不弹窗
|
|
|
+ if (couponPopupType === nowDay) {
|
|
|
+ this.setCouponPopupStatus(false)
|
|
|
+ }
|
|
|
},
|
|
|
- diffTime(t) {
|
|
|
- let date = Date.now()
|
|
|
- return date - t < 2 * 60 * 1000 ? false : true
|
|
|
+ initSystemInfo() {
|
|
|
+ let self = this
|
|
|
+ uni.getSystemInfo({
|
|
|
+ success: function(e) {
|
|
|
+ let modelmes = e.model
|
|
|
+ self.setWindowHeight(e.windowHeight)
|
|
|
+ // iphone x以上的版本都要控制下巴高度
|
|
|
+ if (/iphone [1|x]\s?/i.test(modelmes)) {
|
|
|
+ self.setVariableFun(true)
|
|
|
+ } else {
|
|
|
+ self.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
|
|
|
+ if (e.platform == 'android') {
|
|
|
+ Vue.prototype.platformClass = 'left'
|
|
|
+ self.setVariableFun(false)
|
|
|
+ } else {
|
|
|
+ Vue.prototype.platformClass = 'center'
|
|
|
+ self.setVariableFun(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
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -184,5 +148,7 @@ page {
|
|
|
.placeholder {
|
|
|
color: #999999;
|
|
|
}
|
|
|
-.uni-swiper__dots-box{display: none !important;}
|
|
|
+.uni-swiper__dots-box {
|
|
|
+ display: none !important;
|
|
|
+}
|
|
|
</style>
|