<template>
	<view class="right-nav row">
		<view class="right-nav-button col-12" v-for="(item,index) in buttonGroup" @click="handle(item.type)" :style="{backgroundImage:'url('+item.image+')'}"></view>
	</view>
</template>

<script>
	import { imghost } from '@/config/host.js'
  import functions from "@/utils/functions";
  import {getConfig} from "@/api/other";
	export default{
		data() {
			return {
				title: 'Hello',
				loading: true,
				buttonGroup:[
					{
						image:imghost+"/static/image/right-button-wechat.png",
						type:'wechat'
					},{
						image:imghost+"/static/image/right-button-chat.png",
						type:'chat'
					},{
						image:imghost+"/static/image/right-button-phone.png",
						type:'phone'
					},
				],
        kefu_phone:''
			}
		},
		onLoad() {

		},
		methods: {
      callPhone(phone){
        uni.makePhoneCall({
          phoneNumber: phone.toString()
        });
      },
			handle(type){
					switch (type) {
						case 'chat':
							uni.navigateTo({
								url:"/pages/ChatDetail/index?id=0"
							});
              break;
            case 'wechat':
              functions.success('跳转微信客服');
              break;
            default:
              this.callPhone(this.kefu_phone)
					}
			},
      getPhone(){
        getConfig('kefu_phone').then(res => {
          this.kefu_phone = res.data.kefu_phone;
        })
      }
		},
    created() {
      this.getPhone();
    },
	}
</script>

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