123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <template>
- <view class="tm-sliderNav fulled-height">
- <scroll-view scroll-y :style="{
- height:activeHeight+'px',
- width:activeWidth+'px',
- }">
- <tm-listitem :disabled="item['disabled']==true?true:false" :black="black_tmeme"
- @click="change(index)"
- v-for="(item,index) in formaData" :key='index'
- :color="activeIndex==index?(text?' text ' + color_tmeme:'white'):bgColor"
- :show-right-icon="false"
- :margin="[0,0]"
- :padding="[10,32]"
- :fontSize="fontSize"
- :class-style="activeIndex==index?`border-${color_tmeme}-l-2`:`border-${bgColor}-l-2`"
- round="0" shadow="0"
- >
- <tm-badges color='red' :fllowTheme="false" :offset="[12,-10]" v-if="item.dot>0&&dot" :dot="false" :label="item.dot"></tm-badges>
- <view class="" >
- <text :class="[`text-${activeIndex==index?color_tmeme:fontColor}`,item['disabled']?'opacity-3':'']">{{item[rangKey]}}</text>
- </view>
- </tm-listitem>
- </scroll-view>
- </view>
- </template>
- <script>
-
- import tmListitem from "@/tm-vuetify/components/tm-listitem/tm-listitem.vue"
- import tmGrouplist from "@/tm-vuetify/components/tm-grouplist/tm-grouplist.vue"
- import tmBadges from "@/tm-vuetify/components/tm-badges/tm-badges.vue"
- export default {
- components:{tmListitem,tmGrouplist,tmBadges},
- name:"tm-sliderNav",
- props:{
-
- height: {
- type: String | Number,
- default: 0
- },
-
- width: {
- type: String | Number,
- default: 190
- },
-
- round: {
- type: Number,
- default: 4
- },
-
- list:{
- type:Array,
- default:()=>{
- return [];
- }
- },
-
- rangKey:{
- type:String,
- default:'title'
- },
-
- color:{
- type:String,
- default:'primary'
- },
- fontColor:{
- type:String,
- default:'grey-darken-1'
- },
-
- black:{
- type:Boolean|String,
- default:null
- },
-
- dot:{
- type:Boolean,
- default:true
- },
-
- text:{
- type:Boolean,
- default:false
- },
- fontSize:{
- type:String|Number,
- default:'28'
- },
-
- bgColor:{
- type:String,
- default:'grey-lighten-5'
- },
-
- fllowTheme:{
- type:Boolean|String,
- default:true
- }
- },
- watch:{
- list:{
- deep:true,
- handler(){
- this.dataList = this.list;
- }
- }
- },
- data() {
- return {
- activeHeight:0,
- activeWidth:0,
- activeIndex:0,
- formaData:[]
- };
- },
- computed:{
- dataList:{
- get:function(){
-
- return this.formaData
- },
- set:function(val){
- let t = this;
- let p = [...val];
- for(let j=0;j<p.length;j++){
- if(!p[j].hasOwnProperty('dot')){
- p[j]['dot'] = 0;
- }
- }
-
- this.formaData = p;
- }
- },
- black_tmeme: function() {
- if (this.black !== null) return this.black;
- return this.$tm.vx.state().tmVuetify.black;
- },
- color_tmeme:function(){
- if(this.$tm.vx.state().tmVuetify.color!==null&&this.$tm.vx.state().tmVuetify.color && this.fllowTheme){
- return this.$tm.vx.state().tmVuetify.color;
- }
- return this.color;
- },
- },
- mounted() {
- let t = this;
- this.$nextTick(async function() {
- this.activeHeight = uni.upx2px(this.height);
- if (!this.activeHeight) {
- let wsz = await this.$Querey(".tm-sliderNav",this).catch(e=>{})
- this.activeHeight = wsz[0].height||250;
- this.activeWidth =uni.upx2px(this.width)||100;
- }
- this.dataList = this.list;
- });
- },
- methods: {
- change(index) {
- this.activeIndex=index;
- this.$emit('change',index);
- }
- },
- }
- </script>
- <style lang="scss">
- </style>
|