empty.vue 页面为空时组件
1 <template> 2 <view class="flex flex-direction justify-center align-center" :style="{'margin-top': top}"> 3 <image :style="{height: imageHeight}" src="/static/empty.png" mode="aspectFit"></image> 4 <view class="text-black text-sm margin-top-sm"> 5 {{noContent}} 6 </view> 7 <view class="margin-top-sm" @click="goPage" v-if="linkText"> 8 <text class="text-red text-df margin-right-xs">{{linkText}}</text> 9 <text class="cuIcon-roundright text-red text-df"></text> 10 </view> 11 </view> 12 </template> 13 14 <script> 15 export default { 16 props:{ 17 noContent:String, 18 linkText:String, 19 imageHeight:{ 20 type:String, 21 default:"150px" 22 }, 23 top:{ 24 type:String, 25 default:"150px" 26 } 27 }, 28 methods:{ 29 goPage(){ 30 this.$emit('click') 31 } 32 } 33 } 34 </script> 35 36 <style> 37 </style>
float-button.vue 悬浮按钮(跳转首页)
1 <template> 2 <view class="home-btn" @click.stop="goHome"> 3 <image src="/static/home-icon.png" mode="aspectFit" style=""></image> 4 </view> 5 </template> 6 7 <script> 8 export default{ 9 methods:{ 10 goHome(){ 11 uni.switchTab({ 12 url:"/pages/index/index" 13 }) 14 } 15 } 16 } 17 </script> 18 19 <style lang="scss" scoped> 20 .home-btn{ 21 position: fixed; 22 right: 38upx; 23 bottom: 100upx; 24 76upx; 25 height:76upx; 26 overflow: hidden; 27 z-index:5; 28 image{ 29 100%; 30 height: 100%; 31 } 32 } 33 </style>
loadMore.vue (加载更多)
1 <template> 2 <view class="margin-tb flex justify-center"v-show="isShow"> 3 <view class="cu-load loading" v-show="isLoad"></view> 4 <view class="aimer-footer align-center" v-show="!isLoad"> 5 <image src="/static/footer-aimer.png" mode="aspectFit"></image> 6 </view> 7 </view> 8 </template> 9 10 <script> 11 export default { 12 props:{ 13 isLoad:Boolean, 14 isShow:Boolean 15 } 16 } 17 </script> 18 19 <style lang="scss" scoped> 20 .aimer-footer{ 21 500upx; 22 height: 30upx; 23 image{ 24 100%; 25 height: 100%; 26 } 27 } 28 .cu-load.loading{ 29 color: #666; 30 } 31 .cu-load.loading::before { 32 content: "e67a"; 33 animation: cuIcon-spin 1s infinite linear; 34 color: #999; 35 } 36 </style>
htmlContent.vue (后台使用的是vue-quill-editor 富文本编辑器组件,小程序中展示时,需要使用 uniapp插件 jyfParser 和 npm 包 quill 显示)
1 <template> 2 <div class="padding-lr" style=" 750upx;"> 3 <div class="ql-container ql-snow"> 4 <div class="ql-editor"> 5 <jyf-parser :html="content" ref="article" @parse="parse" @ready="ready" @linkpress="linkpress"></jyf-parser> 6 </div> 7 </div> 8 </div> 9 </template> 10 11 <script> 12 import jyfParser from "@/components/jyf-parser/jyf-parser" 13 import "quill/dist/quill.core.css"; 14 import "quill/dist/quill.snow.css"; 15 import "quill/dist/quill.bubble.css"; 16 import {navigatorToPage} from '@/common/index.js' 17 export default { 18 components:{ 19 jyfParser 20 }, 21 props: { 22 content: String 23 }, 24 methods:{ 25 parse(){ 26 uni.showLoading({ 27 title:"加载中" 28 }) 29 }, 30 ready(){ 31 uni.hideLoading() 32 this.$emit('ready') 33 }, 34 linkpress(e){ 35 if(e.href){ 36 e.ignore() 37 navigatorToPage(e.href,2) 38 } 39 } 40 } 41 }; 42 </script> 43 44 <style scoped> 45 .ql-container.ql-snow{ 46 border-0; 47 height: auto; 48 min-height: auto; 49 } 50 .ql-editor{ 51 padding: 0; 52 } 53 </style>
imt-calendar.vue (uniapp 插件市场的插件修改的)
1 <template> 2 <view class="imt-calendar"> 3 <view class="calendar-month-wrapper align-center padding-lr"> 4 <view class="calendar-icon" @click="current&¤t--"> 5 <image src="/static/training/evaluation/left-arrow-red-icon.png" mode="aspectFit" v-if="current"></image> 6 <image src="/static/training/evaluation/left-arrow-icon.png" mode="aspectFit" v-else></image> 7 </view> 8 <view class="calendar-month">{{currentTime}}</view> 9 <view class="calendar-icon" @click="current == calendar.length-1 || current++"> 10 <image src="/static/training/evaluation/right-arrow-icon.png" mode="aspectFit" v-if="current == calendar.length-1"></image> 11 <image src="/static/training/evaluation/right-arrow-red-icon.png" mode="aspectFit" v-else></image> 12 </view> 13 </view> 14 <view class="calendar-week-wrapper justify-center"> 15 <view class="calendar-week" v-for="(item,index) in week" :key="index">{{item}}</view> 16 </view> 17 <swiper class="calendar-date-swiper" :current="current" @change="current = $event.detail.current"> 18 <swiper-item class="calendar-date-wrapper" v-for="(item,index) in calendar" :key="index"> 19 <view class="calendar-date" v-for="(value,key) in item" :key="key" @click="onclick(value.selected,value.date)" :style="{background:value.selected&&color,color:value.selected&&'#fff'}">{{value.date}}</view> 20 <view class="calendar-date" v-for="item in (35-item.length)"></view> 21 </swiper-item> 22 </swiper> 23 </view> 24 </template> 25 26 <script> 27 export default { 28 data() { 29 return { 30 week: ['日', '一', '二', '三', '四', '五', '六'], 31 current: '', 32 startYear: '', 33 startMonth: '', 34 calendar: [] 35 } 36 }, 37 props: { 38 selected: Array, 39 color: { 40 type: String, 41 default: '#EC2C5A' 42 } 43 }, 44 45 methods: { 46 init() { 47 let year = new Date().getFullYear() 48 let month = new Date().getMonth() 49 this.startYear = this.selected.length ? this.selected[0].substr(0, 4) : `${year}` 50 this.startMonth = this.selected.length ? this.selected[0].substr(5, 2) - 1 : month 51 this.calendar = [...Array((year - this.startYear) * 12 + month - this.startMonth + 1).keys()].map(i => this.getDate( 52 this.format(i))) 53 this.selected.forEach(i => { 54 let time = i.split('-') 55 this.calendar[time[1] - this.startMonth - 1 + (time[0] - this.startYear) * 12][time[2] - 1 + new Date( 56 `${time[0]}-${time[1]}`).getDay()].selected = true 57 }) 58 this.current = this.calendar.length - 1 59 }, 60 getDate(e) { 61 let time = e.split('-') 62 return [...Array(new Date(`${time[0]}-${time[1]}`).getDay())].map(i => ({ 63 date: '' 64 })).concat([...Array([4, 6, 9, 11].includes(time[1] * 1) ? 30 : (time[1] != 2 ? 31 : (time[0] % 4 == 0 ? 29 : 28))) 65 .keys() 66 ].map(i => ({ 67 date: i + 1 68 }))) 69 }, 70 format(e) { 71 let time = new Date(new Date(this.startYear).setMonth(this.startMonth + e)) 72 return `${time.getFullYear()}-${(time.getMonth()<9 && '0')+(time.getMonth()+1)}` 73 }, 74 // formatChar(e) { 75 // let time = new Date(new Date(this.startYear).setMonth(this.startMonth + e)) 76 // return `${time.getFullYear()}年${(time.getMonth()<9 && '0')+(time.getMonth()+1)}月` 77 // } 78 onclick(isSelected,day){ 79 if(isSelected){ 80 day = Number(day)<10?('0'+day):day; 81 this.$emit('click',{date:this.currentTime+'-'+day}) 82 } 83 } 84 }, 85 computed: { 86 currentTime() { 87 return this.format(this.current) 88 } 89 } 90 } 91 </script> 92 93 <style lang="scss" scoped> 94 .imt-calendar { 95 690upx; 96 padding-left: 10upx; 97 padding-right: 10upx; 98 margin: auto; 99 background: #fff; 100 text-align: center; 101 background:rgba(255,255,255,1); 102 box-shadow:0upx 8upx 10upx 0upx rgba(182, 184, 183, 0.35); 103 border-radius:18upx; 104 } 105 106 .calendar-month-wrapper { 107 display: flex; 108 justify-content: space-between; 109 } 110 111 .calendar-icon { 112 35upx; 113 height:35upx; 114 115 image{ 116 100%; 117 height:100%; 118 } 119 } 120 121 .calendar-month { 122 font-size: 32upx; 123 line-height: 100upx; 124 color: #EC2C5A; 125 } 126 127 .reserve { 128 transform: rotate(180deg); 129 } 130 131 .calendar-week-wrapper { 132 display: flex; 133 align-items: center; 134 justify-content: space-between; 135 } 136 137 .calendar-week { 138 font-size: 32upx; 139 48upx; 140 height: 48upx; 141 margin: 14upx 20upx; 142 color: #2E2F2F; 143 } 144 145 .calendar-date-swiper { 146 height: 500upx; 147 } 148 149 .calendar-date-wrapper { 150 display: flex; 151 flex-wrap: wrap; 152 justify-content: space-between; 153 } 154 155 .calendar-date { 156 48upx; 157 height: 48upx; 158 font-size: 32upx; 159 line-height: 48upx; 160 border-radius: 50%; 161 margin: 14upx 20upx; 162 color: #111111; 163 } 164 </style>
ruler.vue 量尺组件
1 <template> 2 <view class="box"> 3 <text class="cursor"></text> 4 <scroll-view scroll-x="true" :scroll-left="salNum" scroll-with-animation="true" @scroll="bindscroll" style="height:150rpx"> 5 <view class="scroller" :style="{scaleWidth}" > 6 <text v-for="(item,index) in count" :key="index" :class="{big:(((item+min)*step)% bigStep == 0), middle:(((item+min)*step) % middleStep == 0) }"> 7 <text v-if="(item+min)%10==0" class="scale_txt">{{(item + min) * step * currentStep}}</text> 8 </text> 9 </view> 10 </scroll-view> 11 </view> 12 </template> 13 14 <script> 15 export default{ 16 props:{ 17 min:{ 18 type: Number, 19 default: 0 20 }, 21 max:{ 22 type: Number, 23 default: 200 24 }, 25 def:{ 26 type: Number, 27 default: 30 28 }, 29 currentStep:{ 30 type: Number, 31 default: 1 32 }, 33 }, 34 data(){ 35 return{ 36 curVal: 0,//当前值 37 middleStep: 5, 38 bigStep: 10, 39 cellW: 10, 40 scaleWidth: "100px", 41 count: 300, 42 salNum: 0, 43 step: 1 //步长 每格代表的值 44 } 45 }, 46 created() { 47 //一共有多少格 48 this.$nextTick(()=>{ 49 let count = Math.ceil((this.max - this.min) / this.step) + 1; 50 this.count = count; 51 this.scaleWidth = (count * this.cellW) + 'px'; 52 this.salNum = (this.def - this.min) / this.step * this.cellW; 53 //初始值 54 this.setVal(this.salNum); 55 }) 56 }, 57 methods:{ 58 bindscroll(e){ 59 // 移动距离 60 let left = e.detail.scrollLeft; 61 this.setVal(left); 62 }, 63 setVal(left){ 64 let curVal = Math.round( left / this.cellW / this.step ) + this.min; 65 this.curVal = curVal > this.max ? this.max : (curVal < this.min ? this.min : curVal) 66 this.$emit('slide',{"curVal":this.curVal}); 67 }, 68 setDefVal(){ 69 //初始值 70 this.salNum = (this.curVal - this.min) * this.cellW * this.step 71 } 72 } 73 } 74 </script> 75 76 <style lang="scss" scoped> 77 /* 78 *滑动标尺样式 79 */ 80 .box { 81 90%; 82 height: 140upx; 83 margin:10upx auto 60upx; 84 overflow: hidden; 85 position: relative; 86 } 87 .cursor { 88 position: absolute; 89 top: 40upx; 90 left: 50%; 91 6upx; 92 height: 44upx; 93 background-color: #EC2C5A; 94 transform: translate(-50%,0); 95 z-index: 9 96 } 97 .wrapper { 98 100%; 99 margin-top: 0upx; 100 } 101 .scroller{ 102 // 1500upx; 103 padding: 40upx 47% 40upx 50%; 104 // transition: all 1s; 105 white-space: nowrap; 106 } 107 .scroller>text{ 108 font-size: 20upx; 109 color: #CCCCCC; 110 display: inline-block; 111 9px; 112 border-left: 1px solid #CCCCCC; 113 border-top: 1px solid #CCCCCC; 114 height: 14upx; 115 vertical-align: top; 116 position: relative; 117 } 118 .scroller>text:last-of-type{ 119 border-bottom: 0upx; 120 } 121 .scroller .scale_txt{ 122 font-size: 26upx; 123 font-style: normal; 124 position: absolute; 125 bottom: -40upx; 126 left: -8px; 127 color: #111111; 128 } 129 .scroller .middle{ 130 height: 28upx; 131 } 132 .scroller .big{ 133 height: 44upx; 134 } 135 </style>