閑聊:
小穎今年四月底從西安跑到深圳來找作業,本來想著好好賺錢還房貸,結果快轉正了被通知要么無薪待崗,要么辦理離職,嗯~ o(* ̄▽ ̄*)o.............................. 想罵人咋辦 ?
小穎之前沒怎么寫過小程式,到這邊后接手了離職小姐姐的作業,看代碼、看api、自己試著建專案,后面摸索著根據需求開發前端靜態頁面,一邊寫還要一邊和產品溝通,說的是按PC端開發移動端,但產品給的原型和PC端差異很大,有的是Pc端沒有按他當時給的需求寫,有的是產品遺漏了······,反正寫的時候是真費勁,后來組里又招了個前端,不過我的隊友有自己的想法,寫的時候只看當前頁面不封裝不整理,也不呼叫別人寫的············,UI出來了也是不按UI的來寫個大概的樣式,然后他負責的模塊前端進度就是一排排的

給他說把一個模塊改完了再弄下一個也不聽········反正就是很有自己的想法,然后后面調介面時,他就開始吐槽他好忙,我也不知道怎么接話,我三個模塊的介面都聯調完了,他一個模塊都沒完,雖然領導要求我們1、2、4、6加班,但他的進度依舊真怕后面我把活干完了,他沒干完領導讓我給他擦屁股,這下要被勸退了就不用擔心啦
所以這么想想就覺得其實還挺開心的,起碼不用再和我的隊友一起寫代碼了,畢竟現在跑哦那個比后面發現坑太多跑不急的好,那么希望我倆后面不要再面試同一家了,希望我們接下來找的作業都比現在的工資高、待遇好,加油??
偷偷向下看: 其實想想我這還好不算慘,我們另一個組和我一起入職的男生,剛被上一家釋放,來這邊快轉正了又遇到釋放·············這更慘,所以想想也就不那么難過啦,所以不要覺得自己過的不如意,過得不如意時看看比自己慘的就突然釋懷了,覺得自己也沒那么慘了,也就沒那么焦慮啦,
無薪待崗 or 離職 ,我當然選擇離職啦,趕緊提桶跑路,那就在跑前把自己寫的部分組件整理下,雖然不是什么復雜組件,但記錄一下,方便以后找代碼,不然靠腦子的話,怕是有點難為我自己,哈哈,那就上代碼
1.創建小程式專案
具體怎么弄,請大家移步到:HBuilderx 創建 、運行uniapp專案
2.初始化選單
第一步:點擊 page檔案夾右鍵——>新建頁面

根據自己的需求是否 注冊、創建同名目錄
第二步:在pages.json中配置小程式頁面選單和頂部導航欄標題
{ "pages": [ //pages陣列中第一項表示應用啟動頁,參考:https://uniapp.dcloud.io/collocation/pages { "path": "pages/index/index", "style": { "navigationBarTitleText": "小組件", "navigationBarBackgroundColor": "#ffffff" } }, { "path": "pages/echarts-report/echarts-report", "style": { "navigationBarTitleText": "報表組件", "enablePullDownRefresh": false } }, { "path": "pages/show-com/show-com", "style": { "navigationBarTitleText": "", "enablePullDownRefresh": false } } ], "tabBar": { // "height": "67px", "color": "#8F919F", "selectedColor": "#2F65DF", "borderStyle": "black", "backgroundColor": "#ffffff", "list": [{ "pagePath": "pages/index/index", // "iconPath": "./static/tabbar/tab_workbench_nromal.png", // "selectedIconPath": "./static/tabbar/tab_workbench_select.png", "text": "其他" }, { "pagePath": "pages/echarts-report/echarts-report", // "iconPath": "./static/tabbar/tab_my_normal.png", // "selectedIconPath": "./static/tabbar/tab_my_select.png", "text": "報表" } ] }, "globalStyle": { "navigationBarTextStyle": "black", "navigationBarTitleText": "uni-app", "navigationBarBackgroundColor": "#F8F8F8", "backgroundColor": "#F8F8F8" } }
其中 tabBar 中配置的底部導航資訊,pages 中配置頁面路由資訊
第三步:開發頁面
因為小穎的這個小程式里就只有兩個選單,倆選單模塊中點擊進去后就開始渲染相應的組件,所以小穎就把他們拆分成兩個選單頁和一個加載組件頁,選單頁樣式和互動方式一樣所以,小穎把才對呢單獨提了個組件,兩個頁面是各自底部導航點進入的頁面,把渲染組件的頁面用的同一頁組件,具體怎么實作的呢,代碼一個一個往上貼哈哈
目錄:

小組件頁面:index.vue
<template>
<view >
<menu-list :comList="comList" />
</view>
</template>
<script>
import menuList from '@/components/menu-list.vue';
export default {
components: {
menuList
},
data() {
return {
comList: [
{ id: 1, name: '排名進度條', img: '/static/img/progress-icon.svg', url: '/pages/show-com/show-com?type=progress' },
{ id: 2, name: '回到頂部', img: '/static/img/to-top.svg', url: '/pages/show-com/show-com?type=toTop' },
{ id: 3, name: '日期', img: '/static/img/date-time.svg', url: '/pages/show-com/show-com?type=Time' },
{ id: 4, name: '錨點定位', img: '/static/img/map-fill.svg', url: '/pages/show-com/show-com?type=aimingPosition' }
]
};
},
onl oad() {},
methods: {}
};
</script>
<style lang="scss" scoped>
.content {
background-color: $uni-bg-color-grey;
}
</style>
報表組件頁面:echarts-report.vue
<template>
<!-- 報表組件 -->
<view ><menu-list :comList="comList" /></view>
</template>
<script>
import menuList from '@/components/menu-list.vue';
export default {
components: {
menuList
},
data() {
return {
comList: [
{ id: 1, name: '餅狀圖', img: '/static/img/pie-icon.svg', url: '/pages/show-com/show-com?type=pieEchart' },
{ id: 2, name: '柱狀圖', img: '/static/img/bar-icon.svg', url: '/pages/show-com/show-com?type=barEchart' },
{ id: 3, name: '混合圖', img: '/static/img/bar-line-icon.svg', url: '/pages/show-com/show-com?type=barLineEChart' }
// { id: 4, name: '堆疊', img: '/static/img/map-fill.svg' }
]
};
},
methods: {}
};
</script>
<style></style>
選單組件:menu-list.vue
<template>
<view >
<view :key="dt.id" v-for="dt in comList" @click="changePage(dt.url)">
<view ><image :src="https://www.cnblogs.com/yingzi1028/archive/2022/08/30/dt.img"></image></view>
<view >{{ dt.name }}</view>
</view>
</view>
</template>
<script>
export default {
props: {
comList: {
type: Array,
required: true
}
},
data() {
return {};
},
methods: {
changePage(url) {
uni.navigateTo({url});
}
}
};
</script>
<style lang="scss" scoped>
.menu-list-box {
padding-top: 30rpx;
margin-left: 32rpx;
.list-item {
border-radius: 12rpx;
height: 170rpx;
flex: 2;
background-color: $uni-bg-color;
margin: 16rpx 32rpx 16rpx 0;
image {
width: 90rpx;
height: 90rpx;
margin: 20rpx 0 10rpx 0;
}
}
.menu-name {
font-size: 28rpx;
width: 100%;
text-align: center;
}
}
</style>
加載組件的:show-com.vue
<template>
<!-- 展示組件 -->
<view >
<!-- 進度條 -->
<view v-if="showCom == 'progress'">
<ranking-prog :unitType="2" :rankList="rankingData" unitTxt="個" />
<ranking-prog :unitType="1" :rankList="rankingData" unitTxt="億" />
</view>
<!-- 回到頂部 -->
<view v-if="showCom == 'toTop'">
<scroll-view scroll-y="true" scroll-with-animation="true" :scroll-top="scrollTopNum" @scroll="scrollFun">
<view ></view>
<!-- 回到頂部 -->
<scroll-top :showToTop="showToTops" @goTopFun="goTopFun" />
</scroll-view>
</view>
<!-- 瞄點定位 -->
<view v-if="showCom == 'aimingPosition'" >
<uni-data-select v-model="toView" :localdata="https://www.cnblogs.com/yingzi1028/archive/2022/08/30/anchorPoints" @change="changeFun" />
<scroll-view scroll-y="true" scroll-with-animation="true" :scroll-into-view="toView">
<view id="anchor1" >內容模塊1</view>
<view id="anchor2" >內容模塊2</view>
<view id="anchor3" >內容模塊3</view>
</scroll-view>
</view>
<!-- 日期 -->
<view v-if="showCom == 'Time'" >
<!-- 不支持設定默認時間 -->
<view >
<view >
<view >
<view ><text >日期型別:</text></view>
<view ><uni-data-select v-model="timePram.timeType" :localdata="https://www.cnblogs.com/yingzi1028/archive/2022/08/30/timeTypeList" @change="changeType" /></view>
</view>
</view>
<view ><select-dt :timeType="timePram.timeType" :endTime="true" @getStartT="getStartTime" @getEndT="getEndTime" /></view>
</view>
<text v-if="timePram.timeType">所選日期:{{ timePram.startTime }}-{{ timePram.endTime }}</text>
</view>
<!-- 餅狀圖 -->
<pie-echart v-if="showCom == 'pieEchart'" :pieCanvasId="'chartsPie'" :pieChartData="https://www.cnblogs.com/yingzi1028/archive/2022/08/30/ChartData" ref="chartsPie" />
<!-- 柱狀圖 -->
<bar-echart v-if="showCom == 'barEchart'" :barCanvasId="'columnCanvas'" :barChartData="https://www.cnblogs.com/yingzi1028/archive/2022/08/30/ChartData" :ontouch="true" />
<!-- 折現+柱狀混合圖 -->
<barLineEChart v-if="showCom == 'barLineEChart'" :chartData="https://www.cnblogs.com/yingzi1028/archive/2022/08/30/ChartData" />
</view>
</template>
<script>
import rankingProg from '@/components/ranking-progress/ranking-progress.vue';
import scrollTop from '@/components/scrollTop/scrollTop.vue';
import selectDt from '@/components/select-date/select-date.vue';
import pieEchart from '@/components/echartsCom/pie-y.vue';
import barEchart from '@/components/echartsCom/bar-charts.vue';
import barLineEChart from '@/components/echartsCom/bar-line-charts.vue';
import { pieChart } from '@/utils/echarts.config.js';
import moment from '@/static/js/moment.min.js';
export default {
name: 'show-com',
components: {
rankingProg,
scrollTop,
selectDt,
pieEchart,
barEchart,
barLineEChart
},
data() {
return {
showCom: 'pieEchart',
ChartData: {},
rankingData: [],
oldScrollNum: 0,
scrollTopNum: 0,
showToTops: false,
toView: '',
anchorPoints: [{ value: 'anchor1', text: '內容模塊1' }, { value: 'anchor2', text: '內容模塊2' }, { value: 'anchor3', text: '內容模塊3' }],
timePram: {
timeType: 'day',
startTime: '',
endTime: '',
startTimeTxt: '',
endTimeTxt: ''
},
timeTypeList: [{ value: 'day', text: '日' }, { value: 'month', text: '月' }, { value: 'quarter', text: '季度' }, { value: 'year', text: '年' }]
};
},
onl oad(option) {
let type = option.type,
_title = '';
this.showCom = type;
switch (type) {
case 'progress':
_title = '組件-排名進度條';
this.initProgress();
break;
case 'toTop':
_title = '組件-回到頂部';
this.initBarChar();
break;
case 'Time':
_title = '組件-日期';
this.initTimeCom();
break;
case 'aimingPosition':
_title = '組件-錨點定位';
break;
case 'pieEchart':
_title = '組件-餅圖';
this.initPieChar();
break;
case 'barEchart':
_title = '組件-柱狀圖';
this.initBarChar();
break;
case 'barLineEChart':
_title = '組件-折線+柱狀圖';
this.initBarLineEChart();
break;
}
uni.setNavigationBarTitle({
title: _title
});
},
methods: {
initProgress() {
this.rankingData =https://www.cnblogs.com/yingzi1028/archive/2022/08/30/ [
{
name: 'XXXXXXXXXXXXXXXX銀行分理處1',
percentage: 82,
num: 385
},
{
name: 'XXXXXXX中國銀行分理處2',
percentage: 80,
num: 345
},
{
name: '中國工商銀行雄縣支行3',
percentage: 70,
num: 233
},
{
name: '容城縣津海大街光大銀行分理處4',
percentage: 55,
num: 214
},
{
name: '農業銀行雄縣支行5',
percentage: 40,
num: 128
},
{
name: '農業銀行雄縣支行6',
percentage: 40,
num: 128
},
{
name: '容城閑羅薩大街中國銀行分理處7',
percentage: 80,
num: 345
},
{
name: '中國工商銀行雄縣支行8',
percentage: 70,
num: 233
},
{
name: '容城縣津海大街光大銀行分理處9',
percentage: 55,
num: 214
},
{
name: '農業銀行雄縣支行10',
percentage: 40,
num: 128
},
{
name: '2農業銀行雄縣支行11',
percentage: 40,
num: 128
}
];
},
scrollFun(e) {
this.oldScrollNum = e.detail.scrollTop;
if (this.oldScrollNum > 500 || this.oldScrollNum == 500) {
this.showToTops = true;
} else {
this.showToTops = false;
}
},
// 回滾到頂部
goTopFun(v) {
// 解決view層不同步的問題
this.scrollTopNum = this.oldScrollNum;
this.$nextTick(() => {
this.scrollTopNum = 0;
});
},
initTimeCom() {
this.timePram.startTime = moment(new Date().getTime()).format('YYYY-MM-DD');
this.timePram.endTime = this.timePram.startTime;
},
getStartTime(time) {
this.timePram.startTime = time._time;
this.timePram.startTimeTxt = time.timeY;
console.log('開始時間', time);
},
getEndTime(time) {
this.timePram.endTime = time._time;
this.timePram.endTimeTxt = time.timeY;
console.log('結束時間', time);
},
changeType(value) {
this.timePram.timeType = value;
},
changeFun(id) {
if (!id) {
return;
}
let anchorId = id;
setTimeout(() => {
this.$nextTick(() => {
this.toView = anchorId;
});
}, 1000);
},
initPieChar() {
setTimeout(() => {
this.ChartData =https://www.cnblogs.com/yingzi1028/archive/2022/08/30/ JSON.parse(JSON.stringify(pieChart.series));
this.ChartData.series[0].data = https://www.cnblogs.com/yingzi1028/archive/2022/08/30/[{ name:'繳存', value: 200 }, { name: '提取', value: 200 }, { name: '貸款', value: 201 }];
this.$refs.chartsPie.pieEopts.title.text = '本月檢核問題型別占比';
}, 500);
},
initBarChar() {
//模擬從服務器獲取資料時的延時
setTimeout(() => {
//模擬服務器回傳資料,如果資料格式和標準格式不同,需自行按下面的格式拼接
let res = {
categories: ['202108', '202109', '202110', '202111', '202112', '202201', '202202', '202203', '202204', '202205', '202206', '202207'],
series: [
{
name: '問題數量',
data: [990, 850, 790, 700, 700, 450, 700, 650, 590, 580, 550, 570]
}
]
};
this.ChartData =https://www.cnblogs.com/yingzi1028/archive/2022/08/30/ JSON.parse(JSON.stringify(res));
}, 500);
},
initBarLineEChart() {
setTimeout(() => {
let res = {
categories: ['2016', '2017', '2018', '2019', '2020', '2021'],
series: [
{ name: '發放金額', type: 'column', data: [70, 90, 88, 88, 65, 78] },
{ name: '同期發放金額', type: 'column', data: [50, 58, 56, 58, 43, 55] },
{ name: '同比增長率', index: 1, type: 'line', data: [-2, -6, 4, 3, 4, 0], addPoint: true },
{ name: '環比增長率', index: 1, type: 'line', data: [-5, -9, 5, -5, -14, 0], addPoint: true }
]
};
this.ChartData =https://www.cnblogs.com/yingzi1028/archive/2022/08/30/ JSON.parse(JSON.stringify(res));
}, 500);
}
}
};
</script>
<style lang="scss" scoped>
.charts-content {
/deep/.ranking-progress-box {
padding: 20rpx 32rpx;
}
.row-item {
flex: 1;
.time-type-txt {
height: 70rpx;
line-height: 70rpx;
}
}
.show-time-com {
padding-top: 50rpx;
padding: 50rpx 32rpx 0 32rpx;
}
.scroller-box {
height: 1600rpx;
.scroller-content {
height: 1500px;
background-color: aliceblue;
}
}
.aiming-position-box {
.scroller-box {
height: 1500rpx;
}
}
.has-back {
height: 800rpx;
width: 100%;
background-color: antiquewhite;
}
#anchor2 {
background-color: paleturquoise;
}
#anchor3 {
background-color: greenyellow;
}
}
</style>
瞄點定位那個小穎沒有提成組件,其實就是 下拉框 和 scroll-view的結合 ,需要注意: scroll-view 要給高 并且里面的小模塊的高加起來要大于 scroll-view 的 高,這樣才能滾起來
回到頂部那個也是需要注意 scroll-view 設定高,不然不會觸發它的 @scroll 事件
其他組件麻煩大家移步:comp-y
選單效果圖:

作者:愛喝酸奶的吃貨出處:http://www.cnblogs.com/yingzi1028/ 本博客文章大多為原創,轉載請請在文章頁面明顯位置給出原文連接,否則保留追究法律責任的權利,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/503216.html
標籤:其他
