Browse Source

修改一些问题

master
1549469775 3 years ago
parent
commit
38d0ec3104
  1. 3
      main.js
  2. 6
      pages/Sub/Tabs/Tabs.vue
  3. 21
      pages/index/index.vue
  4. 2
      uni_modules/niu-ui/components/niu-navbar/niu-navbar.vue
  5. 29
      uni_modules/niu-ui/components/niu-tabbar/niu-tabbar.vue
  6. 15
      uni_modules/niu-ui/components/niu-tabs/niu-tabs.vue
  7. 16
      uni_modules/niu-ui/index.js

3
main.js

@ -1,5 +1,5 @@
import Vue from 'vue' import Vue from 'vue'
import niuUI from '@/uni_modules/niu-ui' import niuUI, {toast} from '@/uni_modules/niu-ui'
// import mock from '@/mock'. // import mock from '@/mock'.
import App from './App' import App from './App'
@ -13,4 +13,5 @@ Vue.use(niuUI)
const app = new Vue({ const app = new Vue({
...App ...App
}) })
setTimeout(function() {toast.success("asd")}, 10);
app.$mount() app.$mount()

6
pages/Sub/Tabs/Tabs.vue

@ -23,8 +23,9 @@
]"></view> ]"></view>
</template> </template>
</niu-tabs> </niu-tabs>
<niu-tabs :list="fiveList" full @change="change" v-model="active"></niu-tabs> <niu-tabs :list="fiveList" full :barPer=".8" @change="change" v-model="active"></niu-tabs>
<niu-tabs :list="colorList" :bar="false" @change="change" v-model="active"> <niu-tabs :list="fiveList" full :barPer=".8" @change="change" capsule v-model="active"></niu-tabs>
<niu-tabs :list="colorList" :active-color="colorList[active]&&colorList[active].color" :bar="false" @change="change" v-model="active">
<template #bar="{show, barLeft, barWidth, anim, props, item}"> <template #bar="{show, barLeft, barWidth, anim, props, item}">
<view v-if="show" :style="[ <view v-if="show" :style="[
{ {
@ -44,6 +45,7 @@
</niu-tabs> </niu-tabs>
<niu-tabs :list="fiveList" @change="change" v-model="active"></niu-tabs> <niu-tabs :list="fiveList" @change="change" v-model="active"></niu-tabs>
<button type="default" @click="cilck">点击</button> <button type="default" @click="cilck">点击</button>
<view>{{$n.data.navbarTop}}px</view>
<!-- <cell title="建筑面积(m²)" inputType="digit" oneline v-model="formData.buildingArea" placeholder="请输入"></cell> --> <!-- <cell title="建筑面积(m²)" inputType="digit" oneline v-model="formData.buildingArea" placeholder="请输入"></cell> -->
</niu-page> </niu-page>
</template> </template>

21
pages/index/index.vue

@ -25,7 +25,8 @@
</view> </view>
<view class=""> <view class="">
<text style="font-size:12rpx;">sadsa</text> <text style="font-size:12rpx;">sadsa</text>
<niu-image circle border="1px solid red" mode="aspectFill" inline rect="100rpx" preview src="https://i.loli.net/2021/08/02/PEKnxSkbAHdtFfi.png"></niu-image> <niu-image circle border="1px solid red" mode="aspectFill" inline rect="100rpx" preview
src="https://i.loli.net/2021/08/02/PEKnxSkbAHdtFfi.png"></niu-image>
</view> </view>
<!-- <niu-grid :num="4"> <!-- <niu-grid :num="4">
<niu-grid-item rect="100px" icon="https://i.loli.net/2021/08/02/PEKnxSkbAHdtFfi.png" text="1231"></niu-grid-item> <niu-grid-item rect="100px" icon="https://i.loli.net/2021/08/02/PEKnxSkbAHdtFfi.png" text="1231"></niu-grid-item>
@ -35,13 +36,14 @@
<niu-grid-item>11</niu-grid-item> <niu-grid-item>11</niu-grid-item>
<niu-grid-item>11</niu-grid-item> <niu-grid-item>11</niu-grid-item>
</niu-grid> --> </niu-grid> -->
{{$n}} <view>{{$n.data.navbarTop}}px</view>
<view>{{$n.data.navbarTop }}</view>
<view :style="{backgroundColor: 'red', height: $n.data.navbarTop +'px'}"></view>
<niu-tabbar></niu-tabbar> <niu-tabbar></niu-tabbar>
</niu-page> </niu-page>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
@ -49,7 +51,7 @@
} }
}, },
onReady() { onReady() {
console.log(this.$n.data.navbarTop);
}, },
methods: { methods: {
go(path) { go(path) {
@ -62,20 +64,23 @@
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.title{ .title {
font-size: 36rpx; font-size: 36rpx;
padding: 20rpx; padding: 20rpx;
color: #333333; color: #333333;
} }
.color-list{
.color-list {
display: flex; display: flex;
padding: 0 20rpx; padding: 0 20rpx;
text-align: center; text-align: center;
} }
.box-list{
.box-list {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
.box-item{
.box-item {
text-align: center; text-align: center;
width: 33.3333%; width: 33.3333%;
height: 100rpx; height: 100rpx;

2
uni_modules/niu-ui/components/niu-navbar/niu-navbar.vue

@ -175,6 +175,7 @@
// #endif // #endif
}, },
created() { created() {
this.$set(this.$n.data, "navbarTop", this.getNavbarHeight())
// #ifdef MP // #ifdef MP
let statusBarHeight = uni.getSystemInfoSync().statusBarHeight; let statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
let menuButtonInfo = uni.getMenuButtonBoundingClientRect() let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
@ -188,7 +189,6 @@
// #endif // #endif
}, },
mounted() { mounted() {
this.$set(this.$n.data, "navbarTop", this.getNavbarHeight())
let pages = getCurrentPages(); let pages = getCurrentPages();
if (pages.length == 1 && mainPagePath.includes(pages[0].route)) { if (pages.length == 1 && mainPagePath.includes(pages[0].route)) {
this.firstPage = true; this.firstPage = true;

29
uni_modules/niu-ui/components/niu-tabbar/niu-tabbar.vue

@ -2,7 +2,7 @@
<view class="niu-tabbar"> <view class="niu-tabbar">
<view class="niu-tabbar__block"></view> <view class="niu-tabbar__block"></view>
<view class="niu-tabbar__wrapper"> <view class="niu-tabbar__wrapper">
<view class="niu-tabbar__item__wrapper" v-for="(item,index) in list"> <view class="niu-tabbar__item__wrapper" v-for="(item,index) in list" :key="index">
<view class="niu-tabbar__item"> <view class="niu-tabbar__item">
<view class="niu-tabbar__icon"> <view class="niu-tabbar__icon">
<image src="https://i.loli.net/2021/08/02/PEKnxSkbAHdtFfi.png"></image> <image src="https://i.loli.net/2021/08/02/PEKnxSkbAHdtFfi.png"></image>
@ -17,7 +17,7 @@
</template> </template>
<script> <script>
export default{ export default {
data() { data() {
return { return {
list: [] list: []
@ -30,11 +30,13 @@
// TODO // TODO
$height: 110rpx; $height: 110rpx;
$bg: white; $bg: white;
.niu-tabbar{
.niu-tabbar__block{ .niu-tabbar {
.niu-tabbar__block {
height: $height; height: $height;
} }
.niu-tabbar__wrapper{
.niu-tabbar__wrapper {
position: fixed; position: fixed;
bottom: 0; bottom: 0;
left: 0; left: 0;
@ -45,16 +47,19 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
text-align: center; text-align: center;
.niu-tabbar__item__wrapper{
.niu-tabbar__item__wrapper {
flex: 1; flex: 1;
width: 0; width: 0;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
.niu-tabbar__item{
.niu-tabbar__item {
position: relative; position: relative;
padding: 10rpx 20rpx; padding: 10rpx 20rpx;
&::after{
&::after {
content: ""; content: "";
position: absolute; position: absolute;
right: 0; right: 0;
@ -63,13 +68,15 @@
height: 10rpx; height: 10rpx;
background-color: red; background-color: red;
} }
.niu-tabbar__icon{
image{ .niu-tabbar__icon {
image {
width: 55rpx; width: 55rpx;
height: 55rpx; height: 55rpx;
} }
} }
.niu-tabbar__text{
.niu-tabbar__text {
line-height: 1; line-height: 1;
font-size: 24rpx; font-size: 24rpx;
color: #333333; color: #333333;

15
uni_modules/niu-ui/components/niu-tabs/niu-tabs.vue

@ -106,6 +106,10 @@
type: Boolean, type: Boolean,
default: true default: true
}, },
barPer: {
type: Number,
default: 1
},
barColor: { barColor: {
type: String, type: String,
default: '#39b54a' default: '#39b54a'
@ -160,7 +164,12 @@
if (this.isRender) return if (this.isRender) return
if(newValue>=this.list.length) return if(newValue>=this.list.length) return
this.clickHere(newValue) this.clickHere(newValue)
} },
barPer(){
if (this.isRender) return
if(this.value>=this.list.length) return
this.clickHere(this.value)
},
}, },
methods: { methods: {
init(index = 0) { init(index = 0) {
@ -192,8 +201,8 @@
if (isClick && this.value == index) return if (isClick && this.value == index) return
if (this.allLeft.length) { if (this.allLeft.length) {
this.$emit("change", index) this.$emit("change", index)
this.barLeft = this.allLeft[index][0] this.barWidth = this.allLeft[index][1] * this.barPer
this.barWidth = this.allLeft[index][1] this.barLeft = this.allLeft[index][0] + (this.allLeft[index][1] - this.barWidth)/2
this.left = (this.allLeft[index][0] - this.allLeft[index][1] * 2) this.left = (this.allLeft[index][0] - this.allLeft[index][1] * 2)
} }

16
uni_modules/niu-ui/index.js

@ -1,12 +1,24 @@
import * as util from "./util" import * as util from "./util"
import toast from "./extensions/toast" import toast from "./extensions/toast"
export {
toast,
util
}
export default { export default {
install(Vue) { install(Vue) {
Vue.prototype.$n = Vue.observable({ const data = Vue.observable({
data: {}, data: {},
util: util, util: util,
toast: toast toast: toast
}) })
Vue.mixin({
computed: {
$n() {
return data
}
}
})
Vue.prototype.$n = data
} }
} }

Loading…
Cancel
Save