/** * 非父子组件数据中转站 */ 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: `

此为直接设置,强烈建议只给自己增加,然后通过自己的账号给其他代理充值,方便统计

此为直接设置,强烈建议只给自己增加,然后通过自己的账号给其他代理充值,方便统计

1-是总代理, 0-不是总代理

`, 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: `

没有可关联的,必须填自己的代理商ID

2-免费 1-收费 0-收费

2-开启 1-禁止 0-禁止

2-可购买 1-不可购买 0-不可购买

1-开放 0-关闭

`, 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: `

0-普通 2-企业签

0-关闭 1-开放

`, 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: `
代理信息
playerInfo
添加代理商
添加渠道
添加游戏
` } 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');