Browse Source

改了些东西

master
1549469775 3 years ago
parent
commit
9bb7fa08ef
  1. 11
      pages.json
  2. 54
      pages/Sub/Tabs/Tabs.vue
  3. 24
      pages/index/index.vue
  4. 29
      responsive/right-window.vue
  5. 2
      uni_modules/niu-ui/components/niu-navbar/niu-navbar.vue
  6. 32
      uni_modules/niu-ui/components/niu-tabs/niu-tabs.vue
  7. 9
      uni_modules/niu-ui/index.js

11
pages.json

@ -43,5 +43,14 @@
"navigationBarTitleText": "uni-app", "navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8", "navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8" "backgroundColor": "#F8F8F8"
} },
"rightWindow": {
"path": "responsive/right-window.vue",
"style": {
"width": "calc(100vw - 450px)"
},
"matchMedia": {
"minWidth": 768
}
}
} }

54
pages/Sub/Tabs/Tabs.vue

@ -4,31 +4,47 @@
Tabs Tabs
</niu-navbar> </niu-navbar>
<niu-tabs :list="colorList" @change="change" v-model="active"></niu-tabs> <niu-tabs :list="colorList" @change="change" v-model="active"></niu-tabs>
<niu-tabs :list="colorList" @change="change" capsule v-model="active"></niu-tabs> <niu-tabs :list="colorList" @change="change" capsule v-model="active"></niu-tabs>
<niu-tabs :list="fiveList" full @change="change" v-model="active"></niu-tabs> <niu-tabs :list="colorList" :bar="false" @change="change" v-model="active">
<niu-tabs :list="fiveList" :bar="false" full @change="change" v-model="active"> <template #bar="{show, barLeft, barWidth, anim, props}">
<template #default="{data, pData, index}"> <view v-if="show" :style="[
2{{data.text}} {
transition: anim?'left .3s ease':'',
position: 'absolute',
top: '50%',
transform: 'translateY(-50%)',
left: (barLeft+barWidth/4-9) + 'px',
height: '55%',
border: `1px solid ${props.activeColor}`,
borderRadius: '100rpx',
bottom: 0,
width: (barWidth/2 + 18) + 'px',
}
]"></view>
</template> </template>
<template #bar="{show, barLeft, barWidth}"> </niu-tabs>
<niu-tabs :list="fiveList" full @change="change" v-model="active"></niu-tabs>
<niu-tabs :list="colorList" :bar="false" @change="change" v-model="active">
<template #bar="{show, barLeft, barWidth, anim, props, item}">
<view v-if="show" :style="[ <view v-if="show" :style="[
{ {
transition: 'left .3s ease', transition: anim?'left .3s ease':'',
position: 'absolute', position: 'absolute',
top: '50%', top: '50%',
transform: 'translateY(-50%)', transform: 'translateY(-50%)',
left: barLeft+barWidth/4 + 'px', left: (barLeft+barWidth/4-9) + 'px',
height: '55%', height: '55%',
border: '1px solid red', border: `1px solid ${item.color || props.activeColor}`,
borderRadius: '100rpx', borderRadius: '100rpx',
bottom: 0, bottom: 0,
width: barWidth/2 + 'px', width: (barWidth/2 + 18) + 'px',
} }
]"></view> ]"></view>
</template> </template>
</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>
<cell title="建筑面积(m²)" inputType="digit" oneline v-model="formData.buildingArea" placeholder="请输入"></cell> <button type="default" @click="cilck">点击</button>
<!-- <cell title="建筑面积(m²)" inputType="digit" oneline v-model="formData.buildingArea" placeholder="请输入"></cell> -->
</niu-page> </niu-page>
</template> </template>
@ -43,7 +59,7 @@
formData:{ formData:{
buildingArea: '' buildingArea: ''
}, },
active: 0, active: 2,
fiveList: [ fiveList: [
{ text: "金吒" }, { text: "金吒" },
{ text: "木吒" }, { text: "木吒" },
@ -70,7 +86,21 @@
] ]
}; };
},methods: { },methods: {
cilck(){
this.fiveList = [
{ text: "金吒" },
{ text: "木吒" },
{ text: "土吒" },
{ text: "土吒" },
{ text: "土吒" },
{ text: "土吒22222" },
{ text: "土吒" },
{ text: "土吒" },
{ text: "土吒" },
]
},
change(index) { change(index) {
console.log(index);
} }
}, },
} }

24
pages/index/index.vue

@ -1,5 +1,5 @@
<template> <template>
<niu-page> <niu-page Tab className="wqeqw">
<niu-navbar fixed :back="false" color="white" bg="#39b54a"> <niu-navbar fixed :back="false" color="white" bg="#39b54a">
爱能森组件库 爱能森组件库
</niu-navbar> </niu-navbar>
@ -25,21 +25,18 @@
</view> </view>
<view class=""> <view class="">
<text style="font-size:12rpx;">sadsa</text> <text style="font-size:12rpx;">sadsa</text>
<niu-image circle border="2px 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>
<textarea style="width: 100%;" @blur="adjust" :maxlength="maxlength" placeholder="请输入" v-model="text"></textarea> <!-- <niu-grid :num="4">
<div style="text-align: right;">{{text.length}}/{{maxlength}}</div>
{{text}}
<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>
<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-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-item>11</niu-grid-item> <niu-grid-item>11</niu-grid-item>
</niu-grid> </niu-grid> -->
{{$n}}
<niu-tabbar></niu-tabbar> <niu-tabbar></niu-tabbar>
<view class="mask" style="position: fixed;left: 0;right: 0;top: 0;bottom: 0;background-color: rgba(#949494, 180);z-index: 1;"></view>
</niu-page> </niu-page>
</template> </template>
@ -48,22 +45,13 @@
export default { export default {
data() { data() {
return { return {
text: '', text: ''
maxlength: 200
} }
}, },
onReady() { onReady() {
}, },
methods: { methods: {
adjust(){
// let value = this.text
// value = value.replace(/\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F]/g, "");
// if(value.length>this.maxlength) {
// value = value.slice(0, this.maxlength);
// }
// this.text = value
},
go(path) { go(path) {
uni.navigateTo({ uni.navigateTo({
url: path url: path

29
responsive/right-window.vue

@ -0,0 +1,29 @@
<template>
<view>
<newDetail ref="detailPage"></newDetail>
</view>
</template>
<script>
import newDetail from '@/pages/Sub/Tabs/cell.vue'
export default {
components:{
newDetail
},
data() {
return {
title: 'Hello'
}
},
created(e) {
//
// uni.$on('updateDetail', (e) => {
// // /pages/news/detail.nvueload
// this.$refs.detailPage.load(e.detail);
// })
}
}
</script>
<style>
</style>

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

@ -175,7 +175,6 @@
// #endif // #endif
}, },
created() { created() {
this.$n.navbar.top = this.getNavbarHeight()
// #ifdef MP // #ifdef MP
let statusBarHeight = uni.getSystemInfoSync().statusBarHeight; let statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
let menuButtonInfo = uni.getMenuButtonBoundingClientRect() let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
@ -189,6 +188,7 @@
// #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;

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

@ -1,7 +1,7 @@
<template> <template>
<view class="niu-x-tabs component"> <view class="niu-x-tabs component" :style="{opacity: isShow?1:0}" multiSlots>
<!-- <view class="scroll-view"> --> <!-- <view class="scroll-view"> -->
<scroll-view :show-scrollbar="false" class="scroll-view" :scroll-x='!full' :scroll-with-animation='true' :scroll-left="left"> <scroll-view :show-scrollbar="false" class="scroll-view" :scroll-x='!full' :scroll-with-animation='anim' :scroll-left="left">
<view class="niu-x-tabs__wrapper"> <view class="niu-x-tabs__wrapper">
<view class="niu-x-tabs__inner" :class="{full,capsule}" :style="{backgroundColor: bg, height: height}"> <view class="niu-x-tabs__inner" :class="{full,capsule}" :style="{backgroundColor: bg, height: height}">
<view class="niu-x-tabs__item" :class="[ <view class="niu-x-tabs__item" :class="[
@ -9,18 +9,22 @@
value==index?activeClass:normalClass value==index?activeClass:normalClass
]" ]"
:style="[value==index?activeCustomStyle:normalCustomStyle, anim?{transition: '.3s linear'}:{}]" :key="index" v-for="(item,index) in list" @click="click(index,true)"> :style="[value==index?activeCustomStyle:normalCustomStyle, anim?{transition: '.3s linear'}:{}]" :key="index" v-for="(item,index) in list" @click="click(index,true)">
<slot :data="item" :pData="pData" :index="index"> <!-- 循环中使用slot会报警告暂时去除未找到处理办法 -->
<!-- <slot :data="item" :pData="pData" :index="index"> -->
<text>{{item[akey]}}</text> <text>{{item[akey]}}</text>
<view v-if="value==index && activeImage" class="niu-x-tabs__bg"> <view v-if="value==index && activeImage" class="niu-x-tabs__bg">
<image class="image" :src="activeImage" mode="widthFix"></image> <image class="image" :src="activeImage" mode="widthFix"></image>
</view> </view>
</slot> <!-- </slot> -->
</view> </view>
<!-- {{ !!(value<list.length) }} --> <!-- {{ !!(value<list.length) }} -->
<slot name="bar" <slot name="bar"
:show="barIsShow" :show="barIsShow"
:anim="anim"
:barLeft="barLeft" :barLeft="barLeft"
:barWidth="barWidth" :barWidth="barWidth"
:item="list[value]"
:props="{normalColor, activeColor}"
> >
<view v-if="bar&&value<list.length" class="niu-x-tabs__bar" :class="{capsule}" :style="[{left:barLeft + 'px',width:barWidth + 'px',backgroundColor: barColor},, anim?{transition: 'left .3s ease, width .3s ease'}:{}]"></view> <view v-if="bar&&value<list.length" class="niu-x-tabs__bar" :class="{capsule}" :style="[{left:barLeft + 'px',width:barWidth + 'px',backgroundColor: barColor},, anim?{transition: 'left .3s ease, width .3s ease'}:{}]"></view>
</slot> </slot>
@ -48,7 +52,7 @@
}, },
width: { width: {
type: String, type: String,
default: 'auto' default: ''
}, },
height: { height: {
type: String, type: String,
@ -116,9 +120,10 @@
anim: false, anim: false,
left: 0, left: 0,
isRender: false, isRender: false,
isShow: false,
allLeft: [], allLeft: [],
barLeft: 0, barLeft: 0,
barWidth: 200, barWidth: 0,
x_ml: 0 // x_ml: 0 //
}; };
}, },
@ -144,11 +149,12 @@
} }
}, },
mounted() { mounted() {
this.init() this.init(this.value)
}, },
watch: { watch: {
list(newValue, oldValue) { list(newValue, oldValue) {
this.init() this.anim = false
this.init(this.value)
}, },
value(newValue, oldValue) { value(newValue, oldValue) {
if (this.isRender) return if (this.isRender) return
@ -169,8 +175,11 @@
return [v.left - this.x_ml, v.width] return [v.left - this.x_ml, v.width]
}) })
this.isRender = false this.isRender = false
this.clickHere(index) if(index < this.list.length){
this.left = index != 0 ? (this.allLeft[index][0]) : 0; this.clickHere(index)
this.left = index != 0 ? (this.allLeft[index][0] - this.allLeft[index][1] * 2) : 0;
}
this.isShow = true
setTimeout(()=>{ setTimeout(()=>{
this.anim = true this.anim = true
},300) },300)
@ -254,6 +263,7 @@
.niu-x-tabs__item { .niu-x-tabs__item {
flex: 1; flex: 1;
width: 0;
text-align: center; text-align: center;
} }
} }
@ -297,7 +307,7 @@
position: absolute; position: absolute;
bottom: 0; bottom: 0;
left: 0; left: 0;
width: 50rpx; width: 0;
height: 2px; height: 2px;
background-color: $themeColor; background-color: $themeColor;

9
uni_modules/niu-ui/index.js

@ -3,13 +3,10 @@ import toast from "./extensions/toast"
export default { export default {
install(Vue) { install(Vue) {
const navbarData = Vue.observable({ Vue.prototype.$n = Vue.observable({
top: 0 data: {},
})
Vue.prototype.$n = {
navbar: navbarData,
util: util, util: util,
toast: toast toast: toast
} })
} }
} }

Loading…
Cancel
Save