import dd from '@/static/dd.js' export function editDDtitle(text) { dd.ready(function() { dd.biz.navigation.setTitle({ title: text, // 替换为你想要设置的导航栏文字 }); }); } export function addColor(list) { let arr = [{ color: 'rgba(41,212,175,1)', bgcColor: 'rgba(41,212,175,0.5)' }, { color: 'rgba(204,115,237,1)', bgcColor: 'rgba(204,115,237,0.5)' }, { color: 'rgba(254,127,126,1)', bgcColor: 'rgba(254,127,126,0.5)' }, { color: 'rgba(102,195,255,1)', bgcColor: 'rgba(102,195,255,0.5)' } ] list.forEach((item, index) => { item.honor.forEach((item1, index1) => { let num = index1 % 4 item1.color = arr[num].color item1.bgcColor = arr[num].bgcColor }) }) return list } export function addText(list) { let obj = { 0: '#FE6B6B', 1: '#43B3FF', 2: '#05CCA1', 3: '#BF57EA' } let obj1 = { 0: '未提交', 1: '已提交', 2: '已批改', 3: '线上提交' } list.forEach(item => { item.color = obj[item.status] item.text = obj1[item.status] }) return list } export function toChinesNum(num) { let changeNum = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'] let unit = ['', '十', '百', '千', '万'] num = parseInt(num) let getWan = (temp) => { let strArr = temp.toString().split('').reverse() let newNum = '' let newArr = [] strArr.forEach((item, index) => { newArr.unshift(item === '0' ? changeNum[item] : changeNum[item] + unit[index]) }) let numArr = [] newArr.forEach((m, n) => { if (m !== '零') numArr.push(n) }) if (newArr.length > 1) { newArr.forEach((m, n) => { if (newArr[newArr.length - 1] === '零') { if (n <= numArr[numArr.length - 1]) { newNum += m } } else { newNum += m } }) } else { newNum = newArr[0] } return newNum } let overWan = Math.floor(num / 10000) let noWan = num % 10000 if (noWan.toString().length < 4) { noWan = '0' + noWan } return overWan ? getWan(overWan) + '万' + getWan(noWan) : getWan(num) }