using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyCode.Project.Infrastructure.Constant
{
///
/// 客服头像常量类
///
public class ServiceConst
{
///
/// 对应的客服昵称、头像
///
public static Dictionary ServiceHeadImgUrl = new Dictionary {
{"小淼","http://ztmall-pic.guoko.com/service_xiaomiao.png"},
{"小森","http://ztmall-pic.guoko.com/service_xiaoshen.png"}
};
///
/// 随机返回一个客服
///
///
public static Dictionary GetRandomService()
{
if(ServiceHeadImgUrl == null || ServiceHeadImgUrl.Count <= 0)
{
return null;
}
var keys = ServiceHeadImgUrl.Select(x => x.Key).ToList();
if(keys == null || keys.Count <= 0)
{
return null;
}
int index = (int)(keys.Count * (new Random().Next(99) * 0.01));
return new Dictionary {
{keys[index],ServiceHeadImgUrl[keys[index]]}
};
}
};
}