Commit db353e68 authored by Xuguangxing's avatar Xuguangxing

Merge branch 'feat/group-buy' of git.quantgroup.cn:ui/group-buy-ui into feat/group-buy

parents e6ee192d 3ac6efec
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<cr-loading class="loading" size="24px">加载中...</cr-loading> <cr-loading class="loading" size="24px">加载中...</cr-loading>
</div> </div>
<net-error /> <net-error />
<goods-share ref="gdShare" />
</div> </div>
</template> </template>
<script> <script>
...@@ -17,11 +18,14 @@ import NetError from '@/components/NetError'; ...@@ -17,11 +18,14 @@ import NetError from '@/components/NetError';
import { isApp, isWxMp, isWechat } from '@/service/validation.service'; import { isApp, isWxMp, isWechat } from '@/service/validation.service';
import store from '@/store'; import store from '@/store';
import Weapp from '@/components/weapp'; import Weapp from '@/components/weapp';
import goodsShare from '@/components/groupShare';
export default { export default {
name: 'App', name: 'App',
components: { components: {
NetError, NetError,
Weapp Weapp,
goodsShare
}, },
data() { data() {
return {}; return {};
......
...@@ -22,16 +22,19 @@ export default { ...@@ -22,16 +22,19 @@ export default {
getTemplateList(activityId) { getTemplateList(activityId) {
return http.get( return http.get(
`http://yapi.quantgroups.com/mock/351/api/kdsp/activity/activity-goods-special/template-list`, `http://yapi.quantgroups.com/mock/351/api/kdsp/activity/activity-goods-special/template-list`,
{ params: { activityId } } {
// return http.get(`${talosHost}/api/kdsp/activity/activity-goods-special/template-list`, {
params: { activityId }
}
); );
}, },
// 入口活动列表 // 入口活动列表
getGoodsList(params) { getGoodsList(params) {
return http.get( return http.get(
`http://yapi.quantgroups.com/mock/351/api/kdsp/activity/activity-goods-special/goods-list`, `http://yapi.quantgroups.com/mock/351/api/kdsp/activity/activity-goods-special/goods-list`,
{ params },
{ {
hideLoading: true // return http.get(`${talosHost}/api/kdsp/activity/activity-goods-special/goods-list`, {
params
} }
); );
}, },
......
...@@ -9,17 +9,17 @@ ...@@ -9,17 +9,17 @@
</div> </div>
</template> </template>
<script> <script>
import { isWxMp, isApp } from '@/service/validation.service';
import Bridge from '@qg/js-bridge';
import MpBridge from '@/service/mp'; import MpBridge from '@/service/mp';
import { mapState } from 'vuex';
export default { export default {
name: 'GroupShare', name: 'GroupShare',
components: {}, components: {},
props: {}, props: {},
data() { data() {
return { return {
showFlag: false,
shareOptions: null,
nativeBridge: null, nativeBridge: null,
showShare: false,
types: [ types: [
{ value: 'weixin', disabled: false }, { value: 'weixin', disabled: false },
{ value: 'pic', disabled: false } { value: 'pic', disabled: false }
...@@ -27,66 +27,53 @@ export default { ...@@ -27,66 +27,53 @@ export default {
}; };
}, },
computed: { computed: {
notBwoser() { ...mapState({
return !isWxMp && !isApp; shareInfo: state => state.pay.shareInfo
}),
showShare: {
get() {
return this.$store.state.pay.showShare;
},
set() {
this.$store.dispatch('goods_share_close');
}
} }
}, },
watch: {}, watch: {},
created() { created() {
if (isApp) this.nativeBridge = new Bridge(); // 如果是小程序直接调用postMessage像小程序派发事件监听
else if (isWxMp) this.nativeBridge = new MpBridge(); this.nativeBridge = new MpBridge();
}, },
methods: { methods: {
async open() { shareCloseChange() {},
try {
let options = await this.getShareData();
// 判断是否时小程序平台
if (!isWxMp) {
this.showShare = true;
}
// 判断是否是App
if (!isApp) {
this.shareAppChange(options);
}
} catch (err) {
console.log(err);
this.$toast('调用分享失败!');
}
},
async getShareData() {
return Promise.resolve({
title: '随便砍砍就能拿,价格你来定',
desc: '我正在免费拿商品,请你帮帮我',
link: `${window.location.origin}/activity/zeroBuy`, // 页面地址
imgUrl: 'https://appsync.lkbang.net/shareIcon.png' // 图片地
});
// await
},
shareCloseChange() {
this.$emit('hideShare', false);
},
bundleShareClickItem(ev) { bundleShareClickItem(ev) {
console.log(ev); if (ev === 'pic') {
console.log(this.nativeBridge); this.nativeBridge.openNewUrl({
}, newUrl: `/pages/goodshare/index?ev=${ev}`
shareAppChange({ title, desc, link, imgUrl }) { });
const data = { }
event: 'showShareView', if (ev === 'weixin') {
data: { this.nativeBridge.run({
platform: ['weChat', 'timeLine', 'QQ', 'QQZone', 'CopyLink'], //依次分别是微信、朋友圈、QQ好友、QQ空间、复制链接 event: 'showShareView',
shareDic: { data: {
title, shareDic: this.shareInfo
desc,
link, // 页面地址
imgUrl // 图片地址
} }
});
this.shareDialogConfirm();
}
},
shareDialogConfirm() {
this.$dialog({
message: '请在微信小程序中参与此活动哦~',
showCancelButton: false,
confirmButtonText: '我知道了哦~',
onConfirm: () => {
// todo 跳转到小程序
this.$toast('确定');
} }
}; });
this.nativeBridge.showShareView(data);
} }
// shareAppChange() {}
} }
}; };
</script> </script>
......
import Bridge from '@qg/js-bridge';
import MpBridge from '@/service/mp';
import { isWxMp, isApp } from '@/service/validation.service';
import localStorage from '@/service/localStorage.service';
export default {
data() {
return {
nativeBridge: null
};
},
methods: {
getToken() {
const that = this;
window.xyqbNativeEvent = function(res) {
const json = typeof res === 'string' ? JSON.parse(res) : res;
if (json.event === 'getTokenSuccess') {
const appData = json.data || {};
if (appData && appData.token) {
localStorage.get('vccToken', appData.token);
that.$nextTick(() => {
window.location.reload();
});
}
}
};
this.nativeBridge.getToken();
},
checkLogin() {
const vccToken = localStorage.get('vccToken');
const needLogin = vccToken ? false : true;
if (needLogin) {
if (isApp) this.nativeBridge = new Bridge();
else if (isWxMp) this.nativeBridge = new MpBridge();
this.$dialog({
message: '参与拼团活动需要您先进行登录哦~',
title: '',
showCancelButton: false,
confirmButtonText: '登录',
onConfirm: () => {
if (isWxMp) {
this.nativeBridge.getToken();
} else if (isApp) {
// native调用getToken
this.getToken();
} else {
this.$dialog({
message: '请在App或小程序中参与活动~',
title: '',
showCancelButton: false,
confirmButtonText: '我知道了'
});
}
}
});
}
return needLogin;
}
}
};
import { isAndroid, isIOS } from './validation.service'; import { isAndroid, isIOS } from './validation.service';
import Bridge from '@qg/js-bridge';
import Vue from 'vue'; import Vue from 'vue';
export const EventBus = new Vue(); export const EventBus = new Vue();
...@@ -335,3 +336,19 @@ export function getQueryString(name) { ...@@ -335,3 +336,19 @@ export function getQueryString(name) {
if (r != null) return unescape(r[2]); if (r != null) return unescape(r[2]);
return null; return null;
} }
export function appShareEventChange({ title, desc, link, imgUrl }) {
const data = {
event: 'showShareView',
data: {
platform: ['weChat', 'timeLine', 'QQ', 'QQZone', 'CopyLink'], //依次分别是微信、朋友圈、QQ好友、QQ空间、复制链接
shareDic: {
title,
desc,
link, // 页面地址
imgUrl // 图片地址
}
}
};
Bridge.showShareView(data);
}
import * as types from './type'; import * as types from './type';
import groupBuy from '@/api/groupBuy'; import groupBuy from '@/api/groupBuy';
import { isWxMp, isApp } from '@/service/validation.service';
import { appShareEventChange } from '@/service/utils.service';
const state = { const state = {
header: true, header: true,
title: '支付中心', title: '支付中心',
...@@ -7,7 +9,9 @@ const state = { ...@@ -7,7 +9,9 @@ const state = {
meta: {}, meta: {},
keepAliveMap: [], keepAliveMap: [],
isPrimordialBrowser: false, // 是否是原生浏览器 isPrimordialBrowser: false, // 是否是原生浏览器
isWeixinBrowser: false // 是否是微信浏览器 isWeixinBrowser: false, // 是否是微信浏览器
showShare: false, // 是否打开底部分享showShare
shareInfo: {} // 分享信息
}; };
// getters // getters
...@@ -35,6 +39,12 @@ const actions = { ...@@ -35,6 +39,12 @@ const actions = {
}, },
change_is_weixin_browser({ commit }, bool) { change_is_weixin_browser({ commit }, bool) {
commit(types.CHANGE_IS_WEIXIN_BROWSER, bool); commit(types.CHANGE_IS_WEIXIN_BROWSER, bool);
},
goods_share_open({ commit }, options) {
commit(types.GOODS_SHARE_OPEN, options);
},
goods_share_close({ commit }) {
commit(types.GOODS_SHARE_CLOSE);
} }
}; };
...@@ -99,6 +109,18 @@ const mutations = { ...@@ -99,6 +109,18 @@ const mutations = {
} }
}); });
} }
},
[types.GOODS_SHARE_OPEN](state, options) {
if (isWxMp) {
state.shareInfo = options;
state.showShare = true;
}
if (isApp) {
appShareEventChange(options);
}
},
[types.GOODS_SHARE_CLOSE](state) {
state.showShare = false;
} }
}; };
......
...@@ -7,3 +7,5 @@ export const CHANGE_IS_WEIXIN_BROWSER = 'CHANGE_IS_WEIXIN_BROWSER'; ...@@ -7,3 +7,5 @@ export const CHANGE_IS_WEIXIN_BROWSER = 'CHANGE_IS_WEIXIN_BROWSER';
export const ADD_KEEP_ALIVE = 'ADD_KEEP_ALIVE'; export const ADD_KEEP_ALIVE = 'ADD_KEEP_ALIVE';
export const DEL_KEEP_ALIVE = 'DEL_KEEP_ALIVE'; export const DEL_KEEP_ALIVE = 'DEL_KEEP_ALIVE';
export const CLEAR_KEEP_ALIVE = 'CLEAR_KEEP_ALIVE'; export const CLEAR_KEEP_ALIVE = 'CLEAR_KEEP_ALIVE';
export const GOODS_SHARE_OPEN = 'GOODS_SHARE_OPEN';
export const GOODS_SHARE_CLOSE = 'GOODS_SHARE_CLOSE';
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
font-size: @font-size-14; font-size: @font-size-14;
position: relative; position: relative;
&-top { &-top {
height: 380px; height: 375px;
} }
&-puzzle { &-puzzle {
position: absolute; position: absolute;
......
<template> <template>
<!-- 配置活动背景色 --> <!-- 配置活动背景色 -->
<div class="group" :style="{ backgroundColor: topicCfg.bgcolor }"> <div class="group" :style="{ backgroundColor: topicCfg.bgcolor }">
<div v-if="!isShowShare" class="group-puzzle" @click="openShareEvent">我的拼团</div> <div v-if="!isShowShare" class="group-puzzle" @click="goToMyorder">我的拼团</div>
<!-- 配置头部动态信息 start --> <!-- 配置头部动态信息 start -->
<div class="group-top"> <div class="group-top">
<!-- 动态活动背景图 --> <!-- 动态活动背景图 -->
...@@ -59,14 +59,11 @@ ...@@ -59,14 +59,11 @@
</dt> </dt>
<dd class="group-share-text">分享</dd> <dd class="group-share-text">分享</dd>
</dl> </dl>
<goods-share ref="gdShare" />
</div> </div>
</template> </template>
<script> <script>
import { mapState } from 'vuex';
import store from '@/store'; import store from '@/store';
import groupBuyApi from '@/api/groupBuy'; import groupBuyApi from '@/api/groupBuy';
import goodsShare from '@/components/groupShare';
import countDown from '@/components/countDown'; import countDown from '@/components/countDown';
import swipeCustomerInfo from '@/components/swipeCustomerInfo'; import swipeCustomerInfo from '@/components/swipeCustomerInfo';
import gpImagePath from '@/assets/images/groupBuy/bg-top.png'; import gpImagePath from '@/assets/images/groupBuy/bg-top.png';
...@@ -75,14 +72,13 @@ import groupSwiper from '@/components/groupSwiper'; ...@@ -75,14 +72,13 @@ import groupSwiper from '@/components/groupSwiper';
import { isNull } from '@/service/validation.service'; import { isNull } from '@/service/validation.service';
import { handleRemainTime, handleDateFormat } from './components/utils'; import { handleRemainTime, handleDateFormat } from './components/utils';
import localStorage from '@/service/localStorage.service'; import localStorage from '@/service/localStorage.service';
import goodsCheckMixin from '@/mixins/goodsCheck.mixin';
let topicIndex; let topicIndex;
export default { export default {
// beforeRouteEnter(to, from, next) {
// next(vm => {});
// },
// eslint-disable-next-line vue/name-property-casing // eslint-disable-next-line vue/name-property-casing
name: 'groupBuyList', name: 'groupBuyList',
components: { countDown, swipeCustomerInfo, goodsCard, groupSwiper, goodsShare }, components: { countDown, swipeCustomerInfo, goodsCard, groupSwiper },
mixins: [goodsCheckMixin],
data() { data() {
return { return {
showShare: false, showShare: false,
...@@ -125,12 +121,8 @@ export default { ...@@ -125,12 +121,8 @@ export default {
}; };
}, },
computed: { computed: {
...mapState({
isPrimordialBrowser: state => state.pay.isPrimordialBrowser,
isWeixinBrowser: state => state.pay.isWeixinBrowser
}),
isShowShare() { isShowShare() {
return this.isPrimordialBrowser || this.isWeixinBrowser; return this.$store.state.pay.isPrimordialBrowser;
}, },
// 更具goodsSpecialId 获取查询活动模板列表-对应数据项 // 更具goodsSpecialId 获取查询活动模板列表-对应数据项
...@@ -146,8 +138,9 @@ export default { ...@@ -146,8 +138,9 @@ export default {
} }
}, },
created() { created() {
console.log(this.isShowShare); // console.log(this.isShowShare);
this.hasLogin = !!localStorage.get('vccToken'); // console.log(this.activityId);
// this.hasLogin = !!localStorage.get('vccToken');
}, },
mounted() { mounted() {
// todo 曝光埋点 // todo 曝光埋点
...@@ -177,8 +170,26 @@ export default { ...@@ -177,8 +170,26 @@ export default {
} }
}, },
methods: { methods: {
openShareEvent() { async goToMyorder() {
this.$refs.gdShare.open(); const isLogin = this.checkLogin();
console.log(isLogin);
// const isLogin = await this.checkLogin();
// console.log(isLogin);
// if (isApp) this.nativeBridge = new Bridge();
// else if (isWxMp) this.nativeBridge = new MpBridge();
},
async openShareEvent() {
let options = await this.getShareData();
this.$store.dispatch('goods_share_open', options);
},
async getShareData() {
return Promise.resolve({
title: '随便砍砍就能拿,价格你来定',
desc: '我正在免费拿商品,请你帮帮我',
link: `${window.location.origin}/activity/zeroBuy`, // 页面地址
imgUrl: 'https://appsync.lkbang.net/shareIcon.png' // 图片地
});
// await
}, },
avatorTimeSyncChange() { avatorTimeSyncChange() {
setInterval(() => { setInterval(() => {
...@@ -284,6 +295,7 @@ async function getActivityList(urlQuery, next) { ...@@ -284,6 +295,7 @@ async function getActivityList(urlQuery, next) {
vm.activityId = activityId; vm.activityId = activityId;
vm.topicList = list; vm.topicList = list;
vm.topicIndex = activityIndex; vm.topicIndex = activityIndex;
localStorage.set('activityId', activityId);
// const { hasStop } = vm.topicCfg; // const { hasStop } = vm.topicCfg;
// if (hasStop || !list.length) { // if (hasStop || !list.length) {
// vm.showOverTip = true; // vm.showOverTip = true;
......
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