import request from './request.js'
const CryptoJS = require('../utils/aes_util');

/**
 * 打点上报通用方法
 * @param {string} code
 * @param {number} time
 */

class Dots {
	constructor(args) {
	}
	
	// 打点上传
	save(oType, bType, val) {
		let {id, petName} = uni.getStorageSync('setUerInfo')? uni.getStorageSync('setUerInfo').user : {id: '', petName: ''};
		let params = {
			userId: id,
			userName: petName,
			operateType: oType,
			businessType: bType,
			businessValue: val
		}
		request.post({
			url: 'userOperateLog/saveLog',
			loadingTip: "加载中...",
			data: params
		}).then(res => {
			console.log(res);
		})
	}

	search(type, val) {
		this.save(0, type, val)
	}

	share(type, val) {
		this.save(1, type, val)
	}
	
	view(type, val) {
		this.save(2, type, val)
	}
	
	submit(type, val) {
		this.save(3, type, val)
	}
	
	pay(type, val) {
		this.save(4, type, val)
	}
}



const dots = new Dots();

export default dots