<template>
  <view class="contact">
    <view class="item-view" @click="makePhone">
      <view class="title">联系电话</view>
      <view class="content">{{ phoneNumber }}</view>
      <u-icon name="arrow-right" color="#9A9A9A" size="24"></u-icon>
    </view>
    <view class="item-view" @click="customerService">
      <view class="title">客服服务</view>
      <u-icon name="arrow-right" color="#9A9A9A" size="24"></u-icon>
    </view>
  </view>
</template>
<script>
export default {
  data() {
    return {
      phoneNumber: '',
    }
  },
  created() {
    this.getPhone();
  },
  methods: {
    getPhone() {
			this.$u.api.getConfigInfo({
				code: 'site_tel400'
			}).then(res => {
				this.phoneNumber = res.data.config.value;
			})
    },
    makePhone() {
			uni.makePhoneCall({
				phoneNumber: this.phoneNumber,
			});
		},
    customerService(){
      if(!this.$store.state.hasLogin){
        this.$u.toast('请先登录');
      } else {
        function Friend(uuid, name, avatar,time = "", text = "",date = "") {
          this.uuid = uuid;
          this.name = name;
          this.avatar = avatar;
          this.online = false;
          this.unReadMessage = 0;
          this.text = text;
          this.time = time;
          this.date = date
        }
        const token = uni.getStorageSync('token');
        let that = this
        uni.request({
          url:"https://mall.dmygkeji.com/api/Specialci/getAtwillUserInfo",
          data:{
            userId: 1
          },
          method:"POST",
          header:{
            "Authorization" : 'Bearer' + " " + token
          },
          success(res){
            res = res.data;
            let user = new Friend(res.data.member_id,res.data.store_name,res.data.member_avatar);
            that.$u.route({
              url:"/pageD/privateChat/privateChat",
              params:{
                id:JSON.stringify(user)
              }
            })
          }
        })
      }
    },
  }
};
</script>
<style lang="scss" scoped>
.contact {
  border-top: 1rpx solid #ECECEC;
  .item-view {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 34rpx 30rpx;
    border-bottom: 2rpx solid #ECECEC;
    .title {
      font-size: 30rpx;
      color: #343434;
    }
    .content {
      margin-left: auto;
      font-size: 28rpx;
      color: #666666;
    }
    .u-icon {
      margin-left: 20rpx;
    }
  }
}
</style>