<template>
	<view>
		<view class="commonApplicationsCss usuallyCard">
			<view class="text-lg">
				常用应用
			</view>
			<view class="margin-top-lg">
				<u-line></u-line>
			</view>
			<u-grid :border="false" col="4" @click="goToAppPage">
				<u-grid-item v-for="(appListItem,appListIndex) in appList" :key="appListIndex">
					<view class="margin-top">
						<u-image width="30px" height="35px" mode="widthFix" :src="appListItem.icon"
							:customStyle="{marginTop:'5px'}"></u-image>
					</view>
					<text class="text-sm text-gray margin-top-sm">{{appListItem.name}}</text>
				</u-grid-item>
			</u-grid>
		</view>

	</view>
</template>

<script>
	export default {
		components: {},
		props: {

		},
		data() {
			return {
				appList: [{
						name: '报修工单',
						icon: "/static/images/mine/applist-01.png",
						path: "/pages/mine/appList/repairWorkOrder/repairWorkOrder"
					},
					{
						name: '退瓶列表',
						icon: "/static/images/mine/applist-02.png",
						path: "/pages/mine/appList/listOfBottleReturn/listOfBottleReturn"
					},
					{
						name: '气瓶回收列表',
						icon: "/static/images/mine/applist-03.png",
						path: "/pages/mine/appList/deaerationList/deaerationList"
					}, {
						name: '气瓶查看',
						icon: "/static/images/mine/applist-04.png",
						path: ""
					},
					{
						name: '积分商城',
						icon: "/static/images/mine/applist-05.png",
						path: "/pages/mine/emptyPage"
					},
					{
						name: '入户安检',
						icon: "/static/images/mine/applist-06.png",
						path: '/pages/mine/appList/homeSecurity/homeSecurityCheck'
					},
					{
						name: '我的押金',
						icon: "/static/images/mine/applist-07.png",
						path: "/pages/mine/emptyPage"
					},
					{
						name: '地址管理',
						icon: "/static/images/mine/applist-08.png",
						path: "/pages/mine/appList/addressManagement/addressManagement"
					}, {
						name: '编辑信息',
						icon: "/static/images/mine/applist-09.png",
						path: "/pages/mine/appList/editInformation/editInformation"
					},
					// {
					// 	name: '联系客服',
					// 	icon: "/static/images/mine/applist-10.png",
					// 	path:""
					// },
					{
						name: '联系我们',
						icon: "/static/images/mine/applist-11.png",
						path: ""
					},
          {
            name: '员工信息',
            icon: "/static/images/mine/applist-11.png",
            path: "/pages/scanCodeUserInfo/index"
          }
				],
				callPhone: '',
				qptm: '',
			}
		},
		computed: {

		},
		onLoad(data) {
			if (data.qptm) {
				this.qptm = data.qptm;
				this.getGasInformation();
			}
		},
		methods: {
			async getGasInformation() {
				let query = {
					qptm: this.qptm
				}
				const result = await this.$api.gasApi.getDetailByQuery(query);
				let {
					code,
					value
				} = result;
				let data = code === 200 ? value : null;
				this.list = this.$assignValues(data, this.list);
			},
			async getPhone() {
				let params = {
					pageBean: {
						page: 1,
						pageSize: 10,
						showTotal: true
					},
					querys: [{
						property: 'f_key',
						value: 'system.pt.lxdh',
						group: 'advance',
						relation: 'AND',
						operation: 'EQUAL'
					}]
				}
				let result = await this.$api.chargingInformationApi.getSecurityInfo(params);
				let {
					rows
				} = result;
				let infoValue = rows[0].f_value;
				this.callPhone = infoValue;
				let option = {
					confirmText: "呼叫",
				}
				console.log('打印this.callPhonew', this.callPhone);
				this.$modal.confirm(this.callPhone, '呼叫号码', option).then(() => {
					// window.location.href = `tel:${this.callPhone}`
					uni.makePhoneCall({
						phoneNumber: this.callPhone, // 电话号码
						success: function() {
							console.log('拨号成功');
						},
						fail: function(err) {
							console.log('拨号失败：', err);
						}
					});
				}).catch(() => {
					console.log("取消");
				});
			},
			goToAppPage(app) {
				console.log('打印goToAppPage',app);
				if (this.appList[app].path) {
					let toUrl = this.appList[app].path;
					let urlName = this.appList[app].name
					uni.navigateTo({
						url: `${toUrl}?qptm=${this.qptm}&pageName=${urlName}`
					})
				} else {
					if (app == 3) {
						this.$emit('selectItem', app);
					} else if (app == 9) {
						this.getPhone();
					} else {
						this.$modal.msg('待开发');
					}
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.commonApplicationsCss {
		margin: 10px;
		padding: 20px 10px 20px 10px;
	}
</style>