Authored by TaoHuang

add gain

<template>
<div class="banner">
<img :src="resource" alt="">
<div class="link" @click="onClick"></div>
</div>
</template>
<script>
import {createNamespacedHelpers} from 'vuex';
const {mapState} = createNamespacedHelpers('gain');
export default {
computed: {
...mapState(['resource'])
},
methods: {
onClick() {
this.$yoho.goNewPage({
url: 'http://m.yohobuy.com/activity/have-gain/apply?title=有货有赚介绍&openby:yohobuy={"action":"go.h5","params":{"title":"有货有赚介绍","url":"http://m.yohobuy.com/activity/have-gain/apply"}}'
});
}
}
};
</script>
<style lang="scss" scoped>
.banner {
img {
position: relative;
width: 100%;
}
.link {
position: absolute;
width: 200px;
height: 200px;
top: 0;
right: 0;
}
}
</style>
... ...
<template>
<div>
<div ref='copy' class="btn" @click="onClick">
立即邀请
</div>
</div>
</template>
<script>
import {createNamespacedHelpers} from 'vuex';
import { get } from 'lodash';
import Clipboard from 'clipboard';
const {mapActions} = createNamespacedHelpers('gain');
export default {
name: 'GainFooter',
data() {
return {
isUnionType: false,
shareUrl: 'https://activity.yoho.cn/feature/5475.html?share_id=8169&title=新人礼遇'
};
},
mounted() {
let vm = this;
this.copyBtn = new Clipboard(this.$refs.copy, {
text() {
return vm.shareUrl + `&union_type=${vm.isUnionType}`;
}
});
this.copyBtn.on('success', function() {
if (vm.isUnionType) {
vm.$createToast({
txt: '邀请链接已复制,快去粘贴吧~',
type: 'txt'
}).show();
}
});
this.copyBtn.on('error', function() {
});
this.fetchUnionStatus().then(result => {
this.isUnionType = get(result, 'data.unionType', false);
});
},
methods: {
...mapActions(['fetchUnionStatus']),
async onClick() {
let vm = this;
const user = await this.$sdk.getUser();
if (!user.uid) {
this.$sdk.goLogin();
return;
}
if (!vm.isUnionType) {
this.$yoho.goNewPage({
url: 'http://m.yohobuy.com/activity/have-gain/apply?title=有货有赚介绍&openby:yohobuy={"action":"go.h5","params":{"title":"有货有赚介绍","url":"http://m.yohobuy.com/activity/have-gain/apply"}}'
});
return;
}
},
}
};
</script>
<style lang="scss" scoped>
.btn {
font-size: 32px;
width: 100%;
height: 98px;
line-height: 98px;
color: white;
text-align: center;
background: #444;
}
</style>
... ...
<template>
<div class="list-comp">
<div class="title">邀请记录</div>
<div class="header">
<div style="width: 25%; text-align: left;">我邀请的好友</div>
<div style="width: 55%; text-align: center;">注册时间</div>
<div style="width: 20%; text-align: right;">我的佣金</div>
</div>
<Scroll ref="scroll" class="list" :options="scrollOptions" :data="list" v-if="list.length" @pulling-up="onPullingUp">
<div class="item" v-for="item in list">
<div class="name" style="width: 25%; text-align: center; text-overflow:ellipsis; overflow: hidden; white-space: nowrap;">{{item.nickname}}</div>
<div class="date" style="width: 55%; text-align: center;">{{item.dateStr}}</div>
<div class="amount" style="width: 20%; text-align: center;">{{item.amountStr}}</div>
</div>
</Scroll>
<div class="empty" v-else>
快去邀请好友吧!
</div>
<div>
</div>
</div>
</template>
<script>
import {Scroll} from 'cube-ui';
import {createNamespacedHelpers} from 'vuex';
const {mapState, mapActions} = createNamespacedHelpers('gain');
export default {
data() {
return {
scrollOptions: {
pullUpLoad: true
}
};
},
mounted() {
this.fetchList();
},
methods: {
...mapActions(['fetchList']),
async onPullingUp() {
const result = await this.fetchList();
if (!result) {
this.$refs.scroll.$forceUpdate();
}
}
},
computed: {
...mapState(['list'])
},
components: {
Scroll
}
};
</script>
<style lang="scss" scoped>
.list-comp {
padding: 40px 30px 30px;
margin-bottom: 98px;
.title {
font-size: 34px;
color: #222;
text-align: center;
font-weight: 600;
margin-bottom: 20px;
}
.header {
display: flex;
font-size: 28px;
color: #b0b0b0;
justify-content: space-between;
height: 100px;
line-height: 100px;
border-bottom: 0.5PX solid #b0b0b0;
}
.list {
max-height: 1010px;
}
.item {
height: 100px;
font-size: 28px;
color: #444;
display: flex;
border-bottom: 0.5PX solid #b0b0b0;
line-height: 100px;
}
.empty {
width: 100%;
height: 350px;
font-size: 28px;
color: #b0b0b0;
line-height: 350px;
text-align: center;
}
}
</style>
... ...
export default [{
name: 'GainShow',
path: '/mapp/gain/show.html',
component: () => import(/* webpackChunkName: "gain" */ './show')
}];
... ...
<template>
<LayoutApp title="邀新返佣">
<div class="body">
<Banner></Banner>
<List></List>
</div>
<Footer class="footer"></Footer>
</LayoutApp>
</template>
<script>
import Layout from '../components/layout/layout-app';
import Footer from './components/footer';
import Banner from './components/banner';
import List from './components/list';
import {createNamespacedHelpers} from 'vuex';
const {mapActions} = createNamespacedHelpers('gain');
export default {
mounted() {
this.fetchResource();
},
methods: {
...mapActions(['fetchResource'])
},
components: {
LayoutApp: Layout,
Footer,
Banner,
List
}
};
</script>
<style lang="scss" scoped>
.footer {
position: absolute;
bottom: 0;
width: 100%;
z-index: 100;
}
.body {
height: 100%;
overflow-y: auto;
}
</style>
... ...
... ... @@ -4,5 +4,6 @@ import alipay from './alipay';
import selfUfo from './selfUfo';
import mine from './mine';
import invite from './invite';
import gain from './gain';
export default [...Order, ...license, ...alipay, ...selfUfo, ...mine, ...invite];
export default [...Order, ...license, ...alipay, ...selfUfo, ...mine, ...invite, ...gain];
... ...
import { get } from 'lodash';
import { getImgUrl } from '../../common/utils';
export default function() {
return {
namespaced: true,
state: {
list: [],
resource: '',
page: 1,
size: 10
},
mutations: {
addList(state, { list }) {
state.list = state.list.concat(list);
},
addResource(state, { url }) {
state.resource = url;
},
changePage(state, { page }) {
state.page = page;
}
},
actions: {
async fetchList({ commit, state }) {
let page = state.page;
const result = await this.$api.get('/api/union/inviteList', {
page: page,
size: state.size
});
if (result.code === 200) {
commit('addList', { list: result.data.list });
commit('changePage', { page: ++page });
}
return result.data.length || 0;
},
async fetchResource({ commit }) {
const result = await this.$api.get('/api/yoho/resource', { content_code: 'a51c8222d21b3d88faa4a49c01c9c93e' });
commit('addResource', { url: getImgUrl(get(result, 'data[0].data.src') || '', 700, 500) });
},
async fetchUnionStatus() {
const result = await this.$api.get('/api/union/queryUnion');
return result;
}
},
};
}
... ...
... ... @@ -6,6 +6,7 @@ import storeUfo from './order';
import storeLicense from './license';
import storeMine from './mine';
import storeInvite from './invite';
import storeGain from './gain';
Vue.use(Vuex);
... ... @@ -17,7 +18,8 @@ export function createStore(context) {
ufo: storeUfo(),
license: storeLicense(),
mine: storeMine(),
invite: storeInvite()
invite: storeInvite(),
gain: storeGain()
},
strict: process.env.NODE_ENV !== 'production'
});
... ...
... ... @@ -155,5 +155,23 @@ module.exports = {
api: 'ufo.invite.getInviteSettlementItemList',
params: {
}
},
'/api/yoho/resource': {
service: true,
api: 'operations/api/v5/resource/get',
params: {
content_code: {type: String}
}
},
'/api/union/inviteList': {
api: 'app.union.shareOrder.queryInviteYohoList',
params: {
page: {type: Number},
size: {type: Number}
}
},
'/api/union/queryUnion': {
api: 'app.union.shareOrder.queryUnionTypeByUid',
params: {}
}
};
... ...
{
"name": "ufo-app-web",
"version": "1.0.1",
"version": "1.0.5",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...