45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace MyCode.Project.Infrastructure.Constant
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 客服头像常量类
|
|||
|
/// </summary>
|
|||
|
public class ServiceConst
|
|||
|
{
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 对应的客服昵称、头像
|
|||
|
/// </summary>
|
|||
|
public static Dictionary<string, string> ServiceHeadImgUrl = new Dictionary<string, string> {
|
|||
|
{"小淼","http://ztmall-pic.guoko.com/service_xiaomiao.png"},
|
|||
|
{"小森","http://ztmall-pic.guoko.com/service_xiaoshen.png"}
|
|||
|
};
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 随机返回一个客服
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
public static Dictionary<string, string> 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<string, string> {
|
|||
|
{keys[index],ServiceHeadImgUrl[keys[index]]}
|
|||
|
};
|
|||
|
}
|
|||
|
};
|
|||
|
}
|