import {
	_userlogin,
	_login,
	_shoplist,
	route_timeout
} from '../api/logoApi'
import {
	_query,
	_queryPage,
	_queryList,
	_getters,
	_dispatch
} from './BaseService'
const service = {
	setforcedLogin: (brandList = []) => _dispatch('setforcedLogin', brandList), // 保存数据到store中
	sethasLogin: (hasLogin = []) => _dispatch('sethasLogin', hasLogin), // 保存数据到store中
	setuserName: (userName = []) => _dispatch('setuserName', userName), // 保存数据到store中
	setwixinInfo: (wixinInfo = {}) => _dispatch('setwixinInfo', wixinInfo), 								// 保存微信信息到store中
	setAppUser: (appUser = {}) => _dispatch('setAppUser', {
		openid: appUser.openid,
		token: appUser.token,
		tokenHead: appUser.tokenHead,
		currentTime: new Date().getTime(),
		phone:appUser.phone,
		username:appUser.username,
		id:appUser.id,
	}),	
	getAppUser: () => _getters('appUser', {}), 	// 获取store中的app信息
	getforcedLogin: () => _getters('forcedLogin', []), // 获取store中的数据
	gethasLogin: () => _getters('hasLogin', []), // 获取store中的数据
	getuserName: () => _getters('userName', []), // 获取store中的数据
	getwixinInfo: () => _getters('wixinInfo', {}), // 获取store中的微信信息
	
	// 方法
	login(userName,state) {
		service.setuserName(userName) 
		service.setforcedLogin('true')	
	},
	logout(state) {
		service.setuserName("")
		service.setforcedLogin('false')
	},
	// 初始化
	login: (goods = {}) => _queryList({api: _login, params: goods, callBack: (data = {}) => {
		service.setAppUser(data);
		// console.log(service.getAppUser())
	}}),
	// 绑定微信
	bindWx: (goods = {}) => _queryList({api: _userlogin, params: goods, callBack: (data = {}) => {
		service.setAppUser(data);
		uni.setStorage({
		    key: 'bindWx',
		    data: data,
		    success: function () {
		        // console.log('success');
		    }
		});
		// console.log(service.getAppUser())
	}}),
	
	// 绑定微信
	verifyToken: (goods = {}) => _queryList({api: _userlogin, params: goods, callBack: (data = {}) => {
		
	}}),
	
	// Shop/list 店铺列表
	shoplist: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	// Shop​/detail商铺详情
	shopdetail: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	// Shop​/save商铺保存
	shopsave: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	// Shop​/del商铺删除
	shopdel: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	// Machine/list  设备列表
	Machinelist: (goods = {}) => _query({api: _shoplist, params: goods, callBack: (data = {}) => {
		// console.log(data)
	}}),
	// Machine/detail  设备列表详情
	Machinelistdetail: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	// Machine/status 设备挂起|启动
	Machinestatus: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	// 捕获屏幕截图 Machine/screen
	Machinescreen: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),

	// 更新设备图片 Machine/saveCover
	MachinesaveCover: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	// 保存设备对应库存 Machine/saveStock
	MachinesaveStock: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	// 设备关联店铺 Machine​/bindShop
	MachinebindShop: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	// Machine/printRecord 设备打印信息
	MachineprintRecord: (goods = {}) => _query({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	
	//Money/statementList 清算列表
	MoneystatementList: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	// Money/statementDetail 清算列表详情
	MoneystatementDetail: (goods = {}) => _queryList({api: route_timeout, params: goods, callBack: (data = {}) => {
		
	}}),
	// Withdrawal/refund 退款原因
	Withdrawal: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	// Money/login 结算中心登陆
	Moneylogin: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	// Money/info 结算账户
	Moneyinfo: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	// Money/saveInfo 保存账户
	MoneysaveInfo: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	
	// Money/billList 账单列表
	MoneybillList: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	// Money/billDetail 账单详情
	MoneybillDetail: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	
	// Money/confirmBill 账单确认
	MoneyconfirmBill: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	// Money/billRemark 疑惑账单
	MoneybillRemark: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	// Withdrawal/apply 提现申请
	Withdrawalapply: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	// Withdrawal/list 提现记录
	Withdrawallist: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	// Withdrawal/detail 提现记录详情
	Withdrawaldetail: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	// Money/partner 代理信息
	Moneypartner: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	// Report/index 首页数据
	Reportindex: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	
	// Machine/againPrint 再次打印
	MachineagainPrint: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	
	// Machine/getStock 获取商品库存
	MachineGetStock: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	
	// Machine/getStock 获取代理设备库存
	MachineStockList: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	
	//Machine/savePartnerStock//修改代理库存
	MachineSavePartnerStock: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	
	//获取代理商库存商品列表
	MachineStockGoodsList: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	
	// Money/receiveMoneyList
	// 每日退款收益数量
	receiveMoneyList: (goods = {}) => _queryList({api: _shoplist, params: goods, callBack: (data = {}) => {
		
	}}),
	
}

export default service