Commit 3ef4b77c authored by 郭志伟's avatar 郭志伟

Merge branch 'feat/v1.3' into feat/v1.3-local

# Conflicts:
#	app/web/page/activity/view/activity/index.ts
#	app/web/page/store/modules/activity/index.ts
#	app/web/page/store/modules/activity/type.ts
#	package-lock.json
parents c9b2d774 e9928729
......@@ -27,4 +27,6 @@ app/view/*
!app/view/.gitkeep
yarn.lock
*.log
coverage
\ No newline at end of file
coverage
.yalc/
yalc.lock
\ No newline at end of file
......@@ -7,6 +7,7 @@ import { release } from '@/.sentryclirc';
import '@/service/qg.service';
import SaDirective from '@qg/citrus-ui/src/helper/directives/saTrack.directive.js';
import config from '@qg/citrus-ui/src/config/index.js';
import { EventBus } from '@qg/citrus-ui/src/helper/service/eventBus';
import { getParameterByName } from '../../../service/utils.service';
import lazyload from '@qg/cherry-ui/src/lazyload/index';
......@@ -39,6 +40,16 @@ if (EASY_ENV_IS_BROWSER) {
Vue.use(lazyload);
const saDirective = new SaDirective();
Vue.directive('track', saDirective.directive);
window.xyqbNativeEvent = function(res) {
const json = typeof res === 'string' ? JSON.parse(res) : res;
console.log('xyqbNativeEvent toggle');
if (json.event === 'loginAndLogoutNotification') {
EventBus.$emit('NATIVE_EVENT_LOGIN', json);
}
if (json.event === 'getTokenSuccess') {
EventBus.$emit('NATIVE_EVENT_GET_TOKEN', json);
}
};
}
@Component({
name: 'Layout'
......
......@@ -3,5 +3,6 @@ declare var EASY_ENV_IS_BROWSER: boolean;
type PlainObject<T = any> = { [key: string]: T };
interface Window {
__INITIAL_STATE__: string | any;
xyqbNativeEvent: any;
}
declare var apollo: any;
......@@ -10,13 +10,17 @@ import TransformStyleMixin from '@/page/mixins/transformStyle.mixin';
import SaMixin from '@/page/mixins/sa.mixin';
import { getStyle, debounce, isApp, isWxMp } from '@/service/utils.service';
import { setAppTitleColor } from '@/service/color.service';
import { EventBus } from '@qg/citrus-ui/src/helper/service/eventBus';
import localStorage from '@/service/localStorage.service';
@Component({ components: { FreedomContainer, GridLayout, GridItem, PageBottomTip, BackTop, EmptyState }, name: 'Activity'})
export default class Activity extends Mixins(TransformStyleMixin, SaMixin) {
@Getter('pageData') pageData;
@State(state => state.activity.pageInfo.pageName) pageName;
@State(state => state.activity.noPageData) noPageData;
@State(state => state.activity.pageInfo.appLoginState) appLoginState;
@State(state => state.activity.gridLayout.rowHeight) rowHeight;
@Mutation('SET_PAGE_ELEMENTS') setPageElement;
@Mutation('UPDATE_APP_LOGIN_STATE') updateAppLoginState;
@Provide() editor = this;
isEditor: boolean = false;
......@@ -34,8 +38,8 @@ export default class Activity extends Mixins(TransformStyleMixin, SaMixin) {
modfiTabsStyleDebounce = debounce(this.modfiTabsStyle, 300);
get layout() {
if (!isApp && !isWxMp) {
this.pageData.elements = this.pageData.elements.filter(v => v.name !== 'cs-search-bar');
if (!isApp && !isWxMp && !EASY_ENV_IS_NODE) {
this.pageData.elements = this.pageData.elements.filter(v => v.name != 'cs-search-bar');
}
return this.pageData && this.pageData.elements.map(v => v.point) || [];
}
......@@ -55,6 +59,12 @@ export default class Activity extends Mixins(TransformStyleMixin, SaMixin) {
if (lastGridItemPoint.w > this.bottomInfo.w) { this.bottomInfo.w = lastGridItemPoint.w; }
this.bottomInfo.y = this.bottomInfo.y + lastGridItemPoint.y + lastGridItemPoint.h;
}
if (isApp) {
// 当页面数据改变,并且渲染完成后改变app 标题栏颜色
this.$nextTick(() => {
debounce(setAppTitleColor(this.pageData.props.titleBgColor), 300);
});
}
}
@Watch('pageName', { immediate: true })
......@@ -78,6 +88,22 @@ export default class Activity extends Mixins(TransformStyleMixin, SaMixin) {
mounted() {
this.targetEle = document.querySelector('body');
this.showBackTop = true;
this.pageVisibilityChange();
if (EASY_ENV_IS_BROWSER) {
EventBus.$on('NATIVE_EVENT_LOGIN', json => {
console.log('xyqbNativeEvent got', json);
if (json.event === 'loginAndLogoutNotification') {
const appData = json.data || {};
if (appData && appData.login) {
localStorage.set('vccToken', appData.token);
this.updateAppLoginState(true);
} else {
this.updateAppLoginState(false);
localStorage.remove('vccToken');
}
}
});
}
}
fetchApi(options) {
const { store, route } = options;
......@@ -142,6 +168,28 @@ export default class Activity extends Mixins(TransformStyleMixin, SaMixin) {
this.showBackTop = state;
}
// 计算商品导航组件位置
pageVisibilityChange() {
if (EASY_ENV_IS_NODE) { return; }
let hidden = 'hidden';
let visibilityChange = 'visibilitychange';
if (typeof document.hidden !== 'undefined') {
hidden = 'hidden';
visibilityChange = 'visibilitychange';
} else if (typeof document.webkitHidden !== 'undefined') {
hidden = 'webkitHidden';
visibilityChange = 'webkitvisibilitychange';
}
window.addEventListener(visibilityChange, () => {
this.handleChange(document[hidden]);
}, false);
}
handleChange(state) {
if (!state) {
if (isApp) {
setAppTitleColor(this.pageData.props.titleBgColor);
}
}
}
modfiTabsStyle() {
const tabsEle = document.querySelector('.tabs');
// console.log('tabsEle', tabsEle);
......
......@@ -36,7 +36,8 @@ export default class TransformStyleMixin extends Vue {
const eleId = element.getAttribute('id');
const component = this.pageData.elements.find(v => v.id === eleId);
if (!component) { return; }
const point = { ...component.point, h: component.name === 'cs-goods-tabs' ? Math.floor(+height) : Math.ceil(+height) };
const calcHeight = +height + (component.commonStyle.paddingTop || 0) + (component.commonStyle.paddingBottom || 0);
const point = { ...component.point, h: component.name === 'cs-goods-tabs' ? Math.floor(+calcHeight) : Math.ceil(+calcHeight) };
this.setElementPoint({ id: eleId, data: point });
console.log('adjustHeight', height, component, element.getAttribute('id'), point);
......
import api from '@/api/editor.api';
import { Module, GetterTree, ActionTree, MutationTree } from 'vuex';
import Vue from 'vue';
import { UPDATE_PAGE_INFO, SET_PAGE_INFO, SET_PAGE_DATA, SET_PAGE_ELEMENTS, SET_ELEMENT_POINT, SET_EMPTY_PAGE } from './type';
import { UPDATE_PAGE_INFO, SET_PAGE_INFO, SET_PAGE_DATA, SET_PAGE_ELEMENTS, SET_ELEMENT_POINT, UPDATE_APP_LOGIN_STATE, SET_EMPTY_PAGE } from './type';
import RootState from '../../state';
import EditorState, { PageInfo, defaultState, Page, PageElement } from './state';
......@@ -46,6 +46,9 @@ export default class EditorModule implements Module<EditorState, RootState> {
[SET_PAGE_DATA](state, data) {
state.pageInfo.page = data;
},
[UPDATE_APP_LOGIN_STATE](state, data) {
state.pageInfo.appLoginState = data;
},
[SET_PAGE_ELEMENTS](state, data) {
if (data) { (state.pageInfo.page as Page).elements = data; }
},
......
......@@ -47,6 +47,7 @@ export interface PageInfo {
coverImage?: string;
isTemplate?: number;
isPublish?: number | boolean;
appLoginState?: boolean;
}
export const defaultState = {
......
......@@ -14,4 +14,5 @@ export const UPDATE_PAGE_STYLE = 'UPDATE_PAGE_STYLE';
export const UPDATE_PAGE_PROPS = 'UPDATE_PAGE_PROPS';
export const SET_PAGE_ELEMENTS = 'SET_PAGE_ELEMENTS';
export const SET_ELEMENT_POINT = 'SET_ELEMENT_POINT';
export const SET_EMPTY_PAGE = 'SET_EMPTY_PAGE';
\ No newline at end of file
export const SET_EMPTY_PAGE = 'SET_EMPTY_PAGE';
export const UPDATE_APP_LOGIN_STATE = 'UPDATE_APP_LOGIN_STATE';
......@@ -4,7 +4,7 @@ import Cookies from './cookieStorage.service';
import localStorage from './localStorage.service';
// formXcxPage:标识是从小程序跳转过来的;
const localStorageParams = ['creditToken', 'vccToken', 'vccChannel', 'sonVccChannel', 'formXcxPage'];
const cookiesParams = ['h', 'vccToken'];
const cookiesParams = ['h'];
export default {
// token校验,整个流程都是登陆后的
......
......@@ -5,6 +5,7 @@ declare var EASY_ENV_IS_NODE: boolean;
interface Window {
__INITIAL_STATE__: any;
xyqbNativeEvent: any;
}
declare module 'axios' {
......
{
"apiHost": "https://quantum-blocks-vcc2.liangkebang.net",
"h5Host": "https://quantum-h5-vcc2.liangkebang.net",
"opapiHost": "https://opapi-vcc2.liangkebang.net",
"passportHost": "https://passportapi-vcc2.liangkebang.net",
"kdspHost": "https://talos-vcc2.liangkebang.net",
"apiHost": "https://quantum-blocks-test1.liangkebang.net",
"h5Host": "https://quantum-h5-test1.liangkebang.net",
"opapiHost": "https://opapi-test1.liangkebang.net",
"passportHost": "https://passportapi-test1.liangkebang.net",
"kdspHost": "https://talos-test1.liangkebang.net",
"loginUrl": "",
"h5ShopHost": "https://tenet-vcc2.liangkebang.net/#",
"h5ShopHost": "https://tenet-test1.liangkebang.net/#",
"qiniuUpHost": "https://up-z0.qiniup.com",
"qiniuHost": "https://appsync.lkbang.net"
}
......@@ -29,8 +29,8 @@ export default (appInfo: EggAppConfig) => {
exports.redis = {
client: {
port: 31565, // Redis port
host: '172.17.5.13', // Redis host
port: 32625, // Redis port
host: '172.17.5.17', // Redis host
password: '',
db: 0
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment