提交 3e4e6aeb 编写于 作者: KK's avatar KK

主题组件 && 格式化代码

上级 264c1416
.app-mobile-select{ .app-mobile-theme{
width: 100%;
ion-icon{
position: absolute;
right: 15px;
bottom: 12px;
z-index: 2;
}
ion-select{
width: 100%;
max-width: 100%;
padding-left: 0;
}
ion-select::part(text) {
padding-right: 16px;
}
ion-select::part(icon) {
display: none;
}
.ion-select-icon{
right: 17px;
top: 50%;
margin-top: -3px;
position: absolute;
width: 0px;
height: 0px;
color: currentcolor;
pointer-events: none;
border-top: 5px solid;
border-right: 5px solid transparent;
border-left: 5px solid transparent;
color: #615e5ec4;
}
.activeoption{ .activeoption{
padding: 5px; padding: 5px;
font-size: 12px; font-size: 12px;
...@@ -39,4 +6,21 @@ ...@@ -39,4 +6,21 @@
text-align: center; text-align: center;
border-radius: 2px; border-radius: 2px;
} }
}
.theme {
display: flex;
justify-content: end;
align-items: center;
flex-wrap: wrap;
padding: 12px;
}
.theme_item {
width: 70px;
height: 70px;
border-radius: 50%;
text-align: center;
line-height: 70px;
font-size: 13px;
margin: 8px;
} }
\ No newline at end of file
<template> <template>
<div class="app-mobile-select"> <div class="app-mobile-theme">
<div class="activeoption" v-if="activeoption" :style="{'background':activeoption.background,'color':activeoption.color}">{{activeoption.text}}</div> <div class="activeoption" v-if="activeoption" :style="{'background':activeoption.background,'color':activeoption.color}">{{activeoption.text}}</div>
<ion-select v-show="false" ref="themeselect" :value="curValue" @ionChange="change" interface="action-sheet" :cancel-text="$t('app.button.cancel')"> <van-action-sheet get-container="#app" v-model="show" :cancel-text="$t('app.button.cancel')" close-on-click-action>
<ion-select-option v-for="option of options" :key="option.value" :value="option.value" class="mob-select-text">{{option.text}}</ion-select-option> <div class = "theme">
</ion-select> <div @click="themeChange(item.value)" v-for="item in options" :key="item.value" class="theme_item" :style="{background:item.background,color:item.color}">{{item.text}}</div>
</div>
</van-action-sheet>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { Vue, Component, Prop, Provide, Emit, Watch, } from "vue-property-decorator"; import { Vue, Component, Prop, Provide, Emit, Watch, } from "vue-property-decorator";
import { themeGroup } from './config'
@Component({ @Component({
components: {}, components: {},
}) })
export default class AppSelect extends Vue { export default class AppSelectTheme extends Vue {
/** /**
* 当前选中值 * 显示状态
* @memberof AppSelect *
* @memberof AppSelectTheme
*/ */
get curValue(){ public show = false;
return this.activeTheme;
}
set curValue(value:any){
this.themeChange(value.detail.value);
}
/**
* 当前激活主题
*
* @memberof AppSelectTheme
*/
public activeoption:any = {}; public activeoption:any = {};
/**
* 获取当前主题
*
* @memberof AppSelectTheme
*/
public getTheme(){ public getTheme(){
if (this.$router.app.$store.state.selectTheme) { if (this.$router.app.$store.state.selectTheme) {
return this.$router.app.$store.state.selectTheme; return this.$router.app.$store.state.selectTheme;
...@@ -40,34 +46,18 @@ export default class AppSelect extends Vue { ...@@ -40,34 +46,18 @@ export default class AppSelect extends Vue {
} }
} }
/**
* change事件
*
* @memberof AppSelect
*/
public change(value: any) {
this.themeChange(value.detail.value);
}
/** /**
* 下拉数据数组 * 下拉数据数组
* *
* @type {any[]} * @type {any[]}
* @memberof AppSelect * @memberof AppSelectTheme
*/ */
public options: any[] = [ public options: any[] = themeGroup;
{value:"app-blue-theme",text:"魅力紫",background:"#705697",color:"#fff"},
{value:"app-dark-blue-theme",text:"经典蓝",background:"#5475ab",color:"#fff"},
{value:"app-class-black-theme",text:"极致黑",background:"#282829",color:"#FFF"},
{value:"app-light-green-theme",text:"浅葱绿",background:"#05D2C2",color:"#FFF"},
{value:"app-peach-pink-theme",text:"桃桃粉",background:"#FD84A3",color:"#FFF"},
{value:"app-star-purple-theme",text:"星辰紫",background:"#6937D9",color:"#FFF"},
{value:"app-summer-yellow-theme",text:"盛夏黄",background:"#FEE45A",color:"#000"},
{value:"app-vital-red-theme",text:"元气红",background:"#FE657A",color:"#FFF"},
];
/** /**
* mounted * 声明周期钩子
*
* @memberof AppSelectTheme
*/ */
public mounted() { public mounted() {
this.activeTheme = this.getTheme(); this.activeTheme = this.getTheme();
...@@ -77,22 +67,21 @@ export default class AppSelect extends Vue { ...@@ -77,22 +67,21 @@ export default class AppSelect extends Vue {
/** /**
* 激活主题 * 激活主题
* *
* @type {any[]} * @memberof AppSelectTheme
* @memberof AppSelect
*/ */
public activeTheme = ""; public activeTheme = "";
/** /**
* 设置 * 设置
* *
* @type {any[]} * @memberof AppSelectTheme
* @memberof AppSelect
*/ */
public setActiveoption(){ public setActiveoption(){
let index = this.options.findIndex((item:any)=>{ let index = this.options.findIndex((item:any)=>{
return this.activeTheme == item.value; return this.activeTheme == item.value;
}) })
this.activeoption = index>-1? this.options[index]:null; this.activeoption = index>-1? this.options[index]:null;
this.show = false;
} }
/** /**
...@@ -117,11 +106,9 @@ export default class AppSelect extends Vue { ...@@ -117,11 +106,9 @@ export default class AppSelect extends Vue {
* @memberof AppTheme * @memberof AppTheme
*/ */
public open(){ public open(){
let select :any= this.$refs.themeselect; this.show = true;
if(select){
select.open();
}
} }
} }
</script> </script>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册