<template>
	<view class="container">
		<navBar title="接口测试" :back="true" color="white" background="green" />
		<button @click="wxAuthLogin">微信授权登陆</button>
		<button @click="getUserInfo">获取用户信息</button>
		<button @click="updatetUserInfo">更新用户信息</button>
		<button @click="updatetUserInfo">更新用户信息</button>
		<button @click="getIndexConfig">获取首页配置</button>
		<button @click="postOrder">提交订单</button>
		<button @click="getOrderDetail">获取订单详细</button>
		<button @click="getMallCat">获取商城分类数据</button>
		<button @click="getMall">获取商城数据</button>
		<button @click="getSerDoc">获取服务文档数据</button>
		<button @click="getPricePercent">获取各个身份的价格百分比</button>
		<button @click="getSerBack">获取我的售后保障</button>
		<button @click="getSerStep">获取我的服务流程</button>
		<button @click="getSerBackGoods">获取我的售后商品</button>
		<button @click="getSerBackCon">获取我的售后联系</button>
		<button @click="postInvite">提交邀请</button>
		<button @click="getMyInvite">获取我的邀请</button>
		<button @click="addInvite">添加邀请</button>
		<button @click="addColl">添加收藏</button>
		<button @click="cancelColl">取消收藏</button>
		<button @click="getActGoods">获取活动商品</button>


	</view>
</template>

<script>
	import {
		wxAuthLoginReq,
		getUserInfoReq,
		updateUserInfoReq,
		getIndexConfigReq,
		postOrderReq,
		getOrderDetailReq,
		getMallCatReq,
		getMallReq,
		getSerDocReq,
		getPricePercentReq,
		getSerBackReq,
		getSerStepReq,
		getSerBackGoodsReq,
		getSerBackConReq,
		postInviteReq,
		getMyInviteReq,
		addInviteReq,
		addCollReq,
		cancelCollReq,
		getActGoodsReq
	} from '@/api/test/index.js'
	export default {
		// components: {
		// 	navBar
		// },
		data() {
			return {

			}
		},
		methods: {
			async wxAuthLogin() {
				let res = await wxAuthLoginReq({
					code: '0b3nl20w3x5lh13zH53w3HRKX02nl20H'
				})
				if (res.code == 0) {
					console.log('微信授权登陆返回值:', res);

					uni.setStorageSync('token', res.data.token)
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
			},

			async getUserInfo() {
				let res = await getUserInfoReq()
				if (res.code == 0) {
					console.log('获取用户信息返回值:', res);
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
			},

			async updatetUserInfo() {
				let res = await updateUserInfoReq({
					nickname: '测试昵称',
					head: 'https://himg.bdimg.com/sys/portraitn/item/public.1.7bbfbe74.qTDof1r_zukwKzMF2A-cRQ',
					phone: '15609038521',
					sex: 1,
					name: '李万涛',
					birthday: '1999-01-03'
				})
				if (res.code == 0) {
					console.log('更新用户信息返回值:', res);
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
			},
			async getIndexConfig() {
				let res = await getIndexConfigReq({
					type: 2
				})
				if (res.code == 0) {
					console.log('获取首页配置返回值: ', res);
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
			},
			async postOrder() {
				let res = await postOrderReq({
					address: '成都市金牛区长平街70号',
					phone: '15609038521',
					name: '李万涛',
					remark: '备注内容',
					config_id: '1,3,5',
					lamp_id: '2,4,6'
				})
				if (res.code == 0) {
					console.log('提交订单返回值: ', res);
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
			},

			async getOrderDetail() {
				let res = await getOrderDetailReq({
					orderId: '3bfc962f6f049082267020faf903d777',
				})
				if (res.code == 0) {
					console.log('获取订单详细返回值: ', res);
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
			},
			async getMallCat() {
				let res = await getMallCatReq()
				if (res.code == 0) {
					console.log('获取商城分类数据返回值: ', res);
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
			},
			async getMall() {
				let res = await getMallReq({
					page: 1,
					type: 1,
					brand: 0,
					search: '筒'
				})
				if (res.code == 0) {
					console.log('获取商城数据返回值: ', res);
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
			},
			async getSerDoc() {
				let res = await getSerDocReq()
				if (res.code == 0) {
					console.log('获取服务文档数据返回值: ', res);
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
			},
			async getPricePercent() {
				let res = await getPricePercentReq()
				if (res.code == 0) {
					console.log('获取各个身份的价格百分比返回值: ', res);
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
			},
			async getSerBack() {
				let res = await getSerBackReq()
				if (res.code == 0) {
					console.log('获取我的售后保障返回值: ', res);
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
			},
			async getSerStep() {
				let res = await getSerStepReq()
				if (res.code == 0) {
					console.log('获取我的服务流程返回值: ', res);
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
			},
			async getSerBackGoods() {
				let res = await getSerBackGoodsReq({
					page: 1
				})
				if (res.code == 0) {
					console.log('获取我的售后商品返回值: ', res);
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
			},
			async getSerBackCon() {
				let res = await getSerBackConReq()
				if (res.code == 0) {
					console.log('获取我的售后联系返回值: ', res);
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
			},
			async postInvite() {
				let res = await postInviteReq({
					type: 0,
					name: '李万涛',
					phone: '15609038521',
					status: 'G-VIP',
					company: '思维定制科技有限公司',
					remark: '我的备注project_nameproject_name',
					project_name: 'project_name'
				})
				if (res.code == 0) {
					console.log('提交邀请返回值: ', res);
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
			},
			async getMyInvite() {
				let res = await getMyInviteReq({
					type: 0,
					state: 0,
				})
				if (res.code == 0) {
					console.log('获取我的邀请返回值: ', res);
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
			},
			async addInvite() {
				let res = await addInviteReq({
					inviteId: 'b3f48188b03b54aeb32256c825044e35',
				})
				if (res.code == 0) {
					console.log('添加邀请返回值: ', res);
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
			},
			async addColl() {
				let res = await addCollReq({
					id: 2,
				})
				if (res.code == 0) {
					console.log('添加收藏返回值: ', res);
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
			},
			async cancelColl() {
				let res = await cancelCollReq({
					id: 1,
				})
				if (res.code == 0) {
					console.log('取消收藏返回值: ', res);
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
			},
			async getActGoods() {
				let res = await getActGoodsReq()
				if (res.code == 0) {
					console.log('获取活动商品返回值: ', res);
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "./index.scss";
</style>