/**
* 非父子组件数据中转站
*/
var Bus = new Vue();
/**
* 缓存对象
*/
var Cache = {};
/**
* 组件公共部分
*/
var commonMixin = {
data: function () {
return {
channelInfo: {}
}
},
created: function () {
var el = this;
el.channelInfo = Cache.channelInfo;
Bus.$on('setChannelInfo', function (r) {
console.log(r)
el.channelInfo = r;
})
}
}
/**
* 代理信息
*/
var salesInfo = {
mixins: [commonMixin],
template: `
`,
data: function () {
return {
salesid: '20',
result: {}
}
},
methods: {
querySalesInfo: function () {
try {
var el = this;
if (!$.isRightId(el.salesid)) throw {code: 102, msg: '请输入正确的代理ID'};
$.api(
{
isLoading: true,
data: {
method: 'Admin.Admin.salesInfo',
biz_content: {
salesid: el.salesid,
agentid: el.channelInfo.agentid,
channelid: el.channelInfo.channelid
}
},
success: function (r) {
el.result = r;
}
}
);
} catch (e) {
$.alert(e.msg);
}
},
save: function () {
var el = this;
var tmp = $.extend({}, el.channelInfo, el.result);
tmp.salesid = el.salesid;
$.confirm(function () {
$.api(
{
isLoading: true,
data: {
method: 'Admin.Admin.changeSalesInfo',
biz_content: tmp
},
success: function (r) {
el.result = {};
}
}
);
})
}
}
};
var playerInfo = {
mixins: [commonMixin],
template: 'playerInfo|{{channelInfo.name}}
',
};
var createAgent = {
template: `
`,
data: function () {
return {
agentid: '',
name: '',
power: '11'
}
},
methods: {
save: function () {
var el = this;
$.api(
{
isLoading: true,
data: {
method: 'Admin.Admin.createAgent',
biz_content: {
agentid: el.agentid,
name: el.name,
power: el.power
}
},
success: function (r) {
$.alert('添加成功');
}
}
);
}
}
};
/**
* 添加新渠道
*/
var createChannel = {
template: `
`,
mixins: [commonMixin],
data: function () {
return {
result: {
agentid: '',
channelid: '',
name: '',
parentid: '',
logo: '',
qq: '',
wechat: '',
become_sales_mode: '2',
invitation_model: '2',
buy_card_mode: '2',
is_open: '1',
id:''
}
}
},
methods: {
queryChannelInfo: function () {
var el = this;
$.api(
{
isLoading: true,
data: {
method: 'Admin.Admin.queryChannelInfo',
biz_content: el.channelInfo,
},
success: function (r) {
el.result = r;
}
}
);
},
changeChannelInfo: function () {
var el = this;
$.api(
{
isLoading: true,
data: {
method: 'Admin.Admin.changeChannelInfo',
biz_content: el.result,
},
success: function (r) {
$.alert('保存成功');
}
}
);
},
createChannel: function () {
var el = this;
$.confirm(function () {
$.api(
{
isLoading: true,
data: {
method: 'Admin.Admin.createChannel',
biz_content: el.result,
},
success: function (r) {
$.alert('添加成功');
}
}
);
});
}
}
};
/**
* 添加游戏
*/
var createGame = {
template: `
`,
data: function () {
return {
result: {
channelid: '',
gameid: '',
gamename: '',
logo: '',
description: '',
ios_download_url: '',
ios_market_type: '2',
ios_app_size: '',
android_download_url: '',
android_app_size: '',
is_open: '1'
}
}
},
methods: {
createGame: function () {
var el = this;
$.confirm(function () {
$.api(
{
isLoading: true,
data: {
method: 'Admin.Admin.createGame',
biz_content: el.result
},
success: function (r) {
$.alert('添加成功');
}
}
);
});
}
}
};
/**
* 选择渠道
*/
var channelList = {
template: `
`,
data: function () {
return {
channelInfo: {},
channelList: []
}
},
watch: {
channelInfo: function () {
Bus.$emit('setChannelInfo', this.channelInfo);
Cache.channelInfo = this.channelInfo;
}
},
methods: {
getChannelList: function () {
var el = this;
$.api(
{
data: {
method: 'Admin.Admin.channelList',
biz_content: {a: 'a'}
},
success: function (r) {
el.channelList = r;
el.channelInfo = r[0];
Cache.channelInfo = el.channelInfo;
}
}
);
}
},
created: function () {
this.getChannelList();
}
}
/**
* 菜单列表
*/
var menuList = {
template: `
`
}
var routes = [
{
path: '/',
components: {
default: channelList,
a: menuList
}
},
{
path: '/salesInfo',
components: {
default: channelList,
a: salesInfo
}
},
{
path: '/playerInfo',
components: {
default: channelList,
a: playerInfo
}
},
{
path: '/createAgent',
components: {
default: channelList,
a: createAgent
}
},
{
path: '/createChannel',
components: {
default: channelList,
a: createChannel
}
},
{
path: '/createGame',
components: {
default: channelList,
a: createGame
}
}
];
var router = new VueRouter({routes: routes});
var app = new Vue({router: router}).$mount('#app');