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
...@@ -28,3 +28,5 @@ app/view/* ...@@ -28,3 +28,5 @@ app/view/*
yarn.lock yarn.lock
*.log *.log
coverage coverage
.yalc/
yalc.lock
\ No newline at end of file
...@@ -7,6 +7,7 @@ import { release } from '@/.sentryclirc'; ...@@ -7,6 +7,7 @@ import { release } from '@/.sentryclirc';
import '@/service/qg.service'; import '@/service/qg.service';
import SaDirective from '@qg/citrus-ui/src/helper/directives/saTrack.directive.js'; import SaDirective from '@qg/citrus-ui/src/helper/directives/saTrack.directive.js';
import config from '@qg/citrus-ui/src/config/index.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 { getParameterByName } from '../../../service/utils.service';
import lazyload from '@qg/cherry-ui/src/lazyload/index'; import lazyload from '@qg/cherry-ui/src/lazyload/index';
...@@ -39,6 +40,16 @@ if (EASY_ENV_IS_BROWSER) { ...@@ -39,6 +40,16 @@ if (EASY_ENV_IS_BROWSER) {
Vue.use(lazyload); Vue.use(lazyload);
const saDirective = new SaDirective(); const saDirective = new SaDirective();
Vue.directive('track', saDirective.directive); 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({ @Component({
name: 'Layout' name: 'Layout'
......
...@@ -3,5 +3,6 @@ declare var EASY_ENV_IS_BROWSER: boolean; ...@@ -3,5 +3,6 @@ declare var EASY_ENV_IS_BROWSER: boolean;
type PlainObject<T = any> = { [key: string]: T }; type PlainObject<T = any> = { [key: string]: T };
interface Window { interface Window {
__INITIAL_STATE__: string | any; __INITIAL_STATE__: string | any;
xyqbNativeEvent: any;
} }
declare var apollo: any; declare var apollo: any;
...@@ -10,13 +10,17 @@ import TransformStyleMixin from '@/page/mixins/transformStyle.mixin'; ...@@ -10,13 +10,17 @@ import TransformStyleMixin from '@/page/mixins/transformStyle.mixin';
import SaMixin from '@/page/mixins/sa.mixin'; import SaMixin from '@/page/mixins/sa.mixin';
import { getStyle, debounce, isApp, isWxMp } from '@/service/utils.service'; import { getStyle, debounce, isApp, isWxMp } from '@/service/utils.service';
import { setAppTitleColor } from '@/service/color.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'}) @Component({ components: { FreedomContainer, GridLayout, GridItem, PageBottomTip, BackTop, EmptyState }, name: 'Activity'})
export default class Activity extends Mixins(TransformStyleMixin, SaMixin) { export default class Activity extends Mixins(TransformStyleMixin, SaMixin) {
@Getter('pageData') pageData; @Getter('pageData') pageData;
@State(state => state.activity.pageInfo.pageName) pageName; @State(state => state.activity.pageInfo.pageName) pageName;
@State(state => state.activity.noPageData) noPageData; @State(state => state.activity.noPageData) noPageData;
@State(state => state.activity.pageInfo.appLoginState) appLoginState;
@State(state => state.activity.gridLayout.rowHeight) rowHeight; @State(state => state.activity.gridLayout.rowHeight) rowHeight;
@Mutation('SET_PAGE_ELEMENTS') setPageElement; @Mutation('SET_PAGE_ELEMENTS') setPageElement;
@Mutation('UPDATE_APP_LOGIN_STATE') updateAppLoginState;
@Provide() editor = this; @Provide() editor = this;
isEditor: boolean = false; isEditor: boolean = false;
...@@ -34,8 +38,8 @@ export default class Activity extends Mixins(TransformStyleMixin, SaMixin) { ...@@ -34,8 +38,8 @@ export default class Activity extends Mixins(TransformStyleMixin, SaMixin) {
modfiTabsStyleDebounce = debounce(this.modfiTabsStyle, 300); modfiTabsStyleDebounce = debounce(this.modfiTabsStyle, 300);
get layout() { get layout() {
if (!isApp && !isWxMp) { if (!isApp && !isWxMp && !EASY_ENV_IS_NODE) {
this.pageData.elements = this.pageData.elements.filter(v => v.name !== 'cs-search-bar'); this.pageData.elements = this.pageData.elements.filter(v => v.name != 'cs-search-bar');
} }
return this.pageData && this.pageData.elements.map(v => v.point) || []; return this.pageData && this.pageData.elements.map(v => v.point) || [];
} }
...@@ -55,6 +59,12 @@ export default class Activity extends Mixins(TransformStyleMixin, SaMixin) { ...@@ -55,6 +59,12 @@ export default class Activity extends Mixins(TransformStyleMixin, SaMixin) {
if (lastGridItemPoint.w > this.bottomInfo.w) { this.bottomInfo.w = lastGridItemPoint.w; } if (lastGridItemPoint.w > this.bottomInfo.w) { this.bottomInfo.w = lastGridItemPoint.w; }
this.bottomInfo.y = this.bottomInfo.y + lastGridItemPoint.y + lastGridItemPoint.h; 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 }) @Watch('pageName', { immediate: true })
...@@ -78,6 +88,22 @@ export default class Activity extends Mixins(TransformStyleMixin, SaMixin) { ...@@ -78,6 +88,22 @@ export default class Activity extends Mixins(TransformStyleMixin, SaMixin) {
mounted() { mounted() {
this.targetEle = document.querySelector('body'); this.targetEle = document.querySelector('body');
this.showBackTop = true; 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) { fetchApi(options) {
const { store, route } = options; const { store, route } = options;
...@@ -142,6 +168,28 @@ export default class Activity extends Mixins(TransformStyleMixin, SaMixin) { ...@@ -142,6 +168,28 @@ export default class Activity extends Mixins(TransformStyleMixin, SaMixin) {
this.showBackTop = state; 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() { modfiTabsStyle() {
const tabsEle = document.querySelector('.tabs'); const tabsEle = document.querySelector('.tabs');
// console.log('tabsEle', tabsEle); // console.log('tabsEle', tabsEle);
......
...@@ -36,7 +36,8 @@ export default class TransformStyleMixin extends Vue { ...@@ -36,7 +36,8 @@ export default class TransformStyleMixin extends Vue {
const eleId = element.getAttribute('id'); const eleId = element.getAttribute('id');
const component = this.pageData.elements.find(v => v.id === eleId); const component = this.pageData.elements.find(v => v.id === eleId);
if (!component) { return; } 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 }); this.setElementPoint({ id: eleId, data: point });
console.log('adjustHeight', height, component, element.getAttribute('id'), point); console.log('adjustHeight', height, component, element.getAttribute('id'), point);
......
import api from '@/api/editor.api'; import api from '@/api/editor.api';
import { Module, GetterTree, ActionTree, MutationTree } from 'vuex'; import { Module, GetterTree, ActionTree, MutationTree } from 'vuex';
import Vue from 'vue'; 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 RootState from '../../state';
import EditorState, { PageInfo, defaultState, Page, PageElement } from './state'; import EditorState, { PageInfo, defaultState, Page, PageElement } from './state';
...@@ -46,6 +46,9 @@ export default class EditorModule implements Module<EditorState, RootState> { ...@@ -46,6 +46,9 @@ export default class EditorModule implements Module<EditorState, RootState> {
[SET_PAGE_DATA](state, data) { [SET_PAGE_DATA](state, data) {
state.pageInfo.page = data; state.pageInfo.page = data;
}, },
[UPDATE_APP_LOGIN_STATE](state, data) {
state.pageInfo.appLoginState = data;
},
[SET_PAGE_ELEMENTS](state, data) { [SET_PAGE_ELEMENTS](state, data) {
if (data) { (state.pageInfo.page as Page).elements = data; } if (data) { (state.pageInfo.page as Page).elements = data; }
}, },
......
...@@ -47,6 +47,7 @@ export interface PageInfo { ...@@ -47,6 +47,7 @@ export interface PageInfo {
coverImage?: string; coverImage?: string;
isTemplate?: number; isTemplate?: number;
isPublish?: number | boolean; isPublish?: number | boolean;
appLoginState?: boolean;
} }
export const defaultState = { export const defaultState = {
......
...@@ -15,3 +15,4 @@ export const UPDATE_PAGE_PROPS = 'UPDATE_PAGE_PROPS'; ...@@ -15,3 +15,4 @@ export const UPDATE_PAGE_PROPS = 'UPDATE_PAGE_PROPS';
export const SET_PAGE_ELEMENTS = 'SET_PAGE_ELEMENTS'; export const SET_PAGE_ELEMENTS = 'SET_PAGE_ELEMENTS';
export const SET_ELEMENT_POINT = 'SET_ELEMENT_POINT'; export const SET_ELEMENT_POINT = 'SET_ELEMENT_POINT';
export const SET_EMPTY_PAGE = 'SET_EMPTY_PAGE'; 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'; ...@@ -4,7 +4,7 @@ import Cookies from './cookieStorage.service';
import localStorage from './localStorage.service'; import localStorage from './localStorage.service';
// formXcxPage:标识是从小程序跳转过来的; // formXcxPage:标识是从小程序跳转过来的;
const localStorageParams = ['creditToken', 'vccToken', 'vccChannel', 'sonVccChannel', 'formXcxPage']; const localStorageParams = ['creditToken', 'vccToken', 'vccChannel', 'sonVccChannel', 'formXcxPage'];
const cookiesParams = ['h', 'vccToken']; const cookiesParams = ['h'];
export default { export default {
// token校验,整个流程都是登陆后的 // token校验,整个流程都是登陆后的
......
...@@ -5,6 +5,7 @@ declare var EASY_ENV_IS_NODE: boolean; ...@@ -5,6 +5,7 @@ declare var EASY_ENV_IS_NODE: boolean;
interface Window { interface Window {
__INITIAL_STATE__: any; __INITIAL_STATE__: any;
xyqbNativeEvent: any;
} }
declare module 'axios' { declare module 'axios' {
......
{ {
"apiHost": "https://quantum-blocks-vcc2.liangkebang.net", "apiHost": "https://quantum-blocks-test1.liangkebang.net",
"h5Host": "https://quantum-h5-vcc2.liangkebang.net", "h5Host": "https://quantum-h5-test1.liangkebang.net",
"opapiHost": "https://opapi-vcc2.liangkebang.net", "opapiHost": "https://opapi-test1.liangkebang.net",
"passportHost": "https://passportapi-vcc2.liangkebang.net", "passportHost": "https://passportapi-test1.liangkebang.net",
"kdspHost": "https://talos-vcc2.liangkebang.net", "kdspHost": "https://talos-test1.liangkebang.net",
"loginUrl": "", "loginUrl": "",
"h5ShopHost": "https://tenet-vcc2.liangkebang.net/#", "h5ShopHost": "https://tenet-test1.liangkebang.net/#",
"qiniuUpHost": "https://up-z0.qiniup.com", "qiniuUpHost": "https://up-z0.qiniup.com",
"qiniuHost": "https://appsync.lkbang.net" "qiniuHost": "https://appsync.lkbang.net"
} }
...@@ -29,8 +29,8 @@ export default (appInfo: EggAppConfig) => { ...@@ -29,8 +29,8 @@ export default (appInfo: EggAppConfig) => {
exports.redis = { exports.redis = {
client: { client: {
port: 31565, // Redis port port: 32625, // Redis port
host: '172.17.5.13', // Redis host host: '172.17.5.17', // Redis host
password: '', password: '',
db: 0 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