初始化
This commit is contained in:
129
components/bottombbar.vue
Normal file
129
components/bottombbar.vue
Normal file
@@ -0,0 +1,129 @@
|
||||
<template>
|
||||
<view class="content">
|
||||
<view class="index">
|
||||
<u-tabbar :value="valuebbar" @change="name => value = name" :placeholder="false"
|
||||
activeColor="#66666" :safeAreaInsetBottom="false"
|
||||
inactiveColor="#333333">
|
||||
<u-tabbar-item v-for="(item,index) in bottomnavigations.list" :key="index" :text="item.name"
|
||||
:hidden="item.hidden" :badge="item.badge" :dot="item.dot" @click="click1(item,index)">
|
||||
<image v-if="valuebbar == item.tabbarindex" class="u-page__item__slot-icon" slot="active-icon"
|
||||
style="width: 40rpx;height: 40rpx;" :src="item.iconPath">
|
||||
</image>
|
||||
<image v-else class="u-page__item__slot-icon" slot="inactive-icon"
|
||||
style="width: 40rpx;height: 40rpx;" :src="item.selectedIconPath"></image>
|
||||
</u-tabbar-item>
|
||||
</u-tabbar>
|
||||
</view>
|
||||
<view class="" :style="'height:' + (100 + HeighT.bottompadding) +'rpx'">
|
||||
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
value: this.valuebbar,
|
||||
}
|
||||
},
|
||||
props: {
|
||||
// list:{
|
||||
// return[{
|
||||
// name: '首页',
|
||||
// iconPath: 'https://ointmentweapp.oss-cn-beijing.aliyuncs.com/icon/iconPath.png',
|
||||
// selectedIconPath: 'https://ointmentweapp.oss-cn-beijing.aliyuncs.com/icon/selectedIconPath.png',
|
||||
// badge: '0', //显示几条消息
|
||||
// dot: false, //是否有红点
|
||||
// hidden: true,
|
||||
// url: uni.cache.get('store_id') ? '/pages/index/indexInfo' : '/pages/index/index'
|
||||
|
||||
// },
|
||||
// {
|
||||
// name: '作品',
|
||||
// iconPath: 'https://ointmentweapp.oss-cn-beijing.aliyuncs.com/icon/iconPath1.png',
|
||||
// selectedIconPath: 'https://ointmentweapp.oss-cn-beijing.aliyuncs.com/icon/selectedIconPath1.png',
|
||||
// badge: '0', //显示几条消息
|
||||
// dot: false, //是否有红点
|
||||
// url: '/pages/task/index',
|
||||
// hidden: uni.cache.get('store_id') ? true : false
|
||||
// },
|
||||
// {
|
||||
// name: '订单',
|
||||
// iconPath: 'https://ointmentweapp.oss-cn-beijing.aliyuncs.com/icon/iconPath2.png',
|
||||
// selectedIconPath: 'https://ointmentweapp.oss-cn-beijing.aliyuncs.com/icon/selectedIconPath2.png',
|
||||
// badge: '0', //显示几条消息
|
||||
// dot: false, //是否有红点
|
||||
// url: '/pages/my/order/index?e=0',
|
||||
// hidden: true
|
||||
|
||||
// }, {
|
||||
// name: '我的',
|
||||
// iconPath: 'https://ointmentweapp.oss-cn-beijing.aliyuncs.com/icon/iconPath3.png',
|
||||
// selectedIconPath: 'https://ointmentweapp.oss-cn-beijing.aliyuncs.com/icon/selectedIconPath3.png',
|
||||
// badge: '0', //显示几条消息
|
||||
// dot: false, //是否有红点
|
||||
// url: '/pages/my/index',
|
||||
// hidden: true
|
||||
// }]
|
||||
// }
|
||||
// },
|
||||
valuebbar: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
|
||||
},
|
||||
computed: {
|
||||
HeighT() {
|
||||
return this.$store.getters.is_BarHeight
|
||||
},
|
||||
bottomnavigations() {
|
||||
return this.$store.getters.bottomnavigation
|
||||
},
|
||||
HeighTs() {
|
||||
let data = {
|
||||
"padding-bottom": this.$store.getters.is_BarHeight.bottompadding + 'rpx'
|
||||
}
|
||||
return data
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
click1(a, e) {
|
||||
this.value = e
|
||||
switch (a.type) {
|
||||
case 'reLaunch':
|
||||
uni.reLaunch({
|
||||
url: a.url
|
||||
});
|
||||
break;
|
||||
case 'navigateTo':
|
||||
uni.navigateTo({
|
||||
url: a.url
|
||||
});
|
||||
break;
|
||||
case 'redirectTo':
|
||||
uni.redirectTo({
|
||||
url: a.url
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.content {
|
||||
.index {
|
||||
z-index: 998;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
|
||||
.u-page__item__slot-icon {}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
192
components/countdown.vue
Normal file
192
components/countdown.vue
Normal file
@@ -0,0 +1,192 @@
|
||||
<template>
|
||||
<view class="uni-countdown">
|
||||
<text v-if="showDay" class="uni-countdown__number">{{ d }}</text>
|
||||
<text v-if="showDay" class="uni-countdown__splitor">天</text>
|
||||
<text class="uni-countdown__number">{{ h }}</text>
|
||||
<text class="uni-countdown__splitor">{{ showColon ? ':' : '时' }}</text>
|
||||
<text class="uni-countdown__number">{{ i }}</text>
|
||||
<text class="uni-countdown__splitor">{{ showColon ? ':' : '分' }}</text>
|
||||
<text class="uni-countdown__number">{{ s }}</text>
|
||||
<text v-if="!showColon" class="uni-countdown__splitor">秒</text>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
/**
|
||||
* Countdown 倒计时
|
||||
* @description 倒计时组件
|
||||
* @tutorial https://ext.dcloud.net.cn/plugin?id=25
|
||||
* @property {String} backgroundColor 背景色
|
||||
* @property {String} color 文字颜色
|
||||
* @property {Number} day 天数
|
||||
* @property {Number} hour 小时
|
||||
* @property {Number} minute 分钟
|
||||
* @property {Number} second 秒
|
||||
* @property {Boolean} showDay = [true|false] 是否显示天数
|
||||
* @property {Boolean} showColon = [true|false] 是否以冒号为分隔符
|
||||
* @property {String} splitorColor 分割符号颜色
|
||||
* @event {Function} timeup 倒计时时间到触发事件
|
||||
* @example <uni-countdown :day="1" :hour="1" :minute="12" :second="40"></uni-countdown>
|
||||
*/
|
||||
export default {
|
||||
name: 'UniCountdown',
|
||||
props: {
|
||||
showDay: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
showColon: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
backgroundColor: {
|
||||
type: String,
|
||||
default: '#FFFFFF'
|
||||
},
|
||||
borderColor: {
|
||||
type: String,
|
||||
default: '#000000'
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
default: '#000000'
|
||||
},
|
||||
splitorColor: {
|
||||
type: String,
|
||||
default: '#000000'
|
||||
},
|
||||
indexs: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
day: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
hour: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
minute: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
second: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
timer: null,
|
||||
syncFlag: false,
|
||||
d: '00',
|
||||
h: '00',
|
||||
i: '00',
|
||||
s: '00',
|
||||
leftTime: 0,
|
||||
seconds: 0
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
day(val) {
|
||||
this.changeFlag()
|
||||
},
|
||||
hour(val) {
|
||||
this.changeFlag()
|
||||
},
|
||||
minute(val) {
|
||||
this.changeFlag()
|
||||
},
|
||||
second(val) {
|
||||
this.changeFlag()
|
||||
}
|
||||
},
|
||||
created: function(e) {
|
||||
this.startData();
|
||||
},
|
||||
beforeDestroy() {
|
||||
clearInterval(this.timer)
|
||||
},
|
||||
methods: {
|
||||
toSeconds(day, hours, minutes, seconds) {
|
||||
return day * 60 * 60 * 24 + hours * 60 * 60 + minutes * 60 + seconds
|
||||
},
|
||||
timeUp() {
|
||||
console.log(1)
|
||||
clearInterval(this.timer)
|
||||
this.$emit('timeup',this.indexs)
|
||||
},
|
||||
countDown() {
|
||||
let seconds = this.seconds
|
||||
let [day, hour, minute, second] = [0, 0, 0, 0]
|
||||
if (seconds > 0) {
|
||||
day = Math.floor(seconds / (60 * 60 * 24))
|
||||
hour = Math.floor(seconds / (60 * 60)) - (day * 24)
|
||||
minute = Math.floor(seconds / 60) - (day * 24 * 60) - (hour * 60)
|
||||
second = Math.floor(seconds) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60)
|
||||
} else {
|
||||
this.timeUp()
|
||||
}
|
||||
if (day < 10) {
|
||||
day = '0' + day
|
||||
}
|
||||
if (hour < 10) {
|
||||
hour = '0' + hour
|
||||
}
|
||||
if (minute < 10) {
|
||||
minute = '0' + minute
|
||||
}
|
||||
if (second < 10) {
|
||||
second = '0' + second
|
||||
}
|
||||
this.d = day
|
||||
this.h = hour
|
||||
this.i = minute
|
||||
this.s = second
|
||||
},
|
||||
startData() {
|
||||
this.seconds = this.toSeconds(this.day, this.hour, this.minute, this.second)
|
||||
if (this.seconds <= 0) {
|
||||
return
|
||||
}
|
||||
this.countDown()
|
||||
this.timer = setInterval(() => {
|
||||
this.seconds--
|
||||
if (this.seconds < 0) {
|
||||
this.timeUp()
|
||||
return
|
||||
}
|
||||
this.countDown()
|
||||
}, 1000)
|
||||
},
|
||||
changeFlag() {
|
||||
console.log(this.syncFlag,111111)
|
||||
if (!this.syncFlag) {
|
||||
this.seconds = this.toSeconds(this.day, this.hour, this.minute, this.second)
|
||||
this.startData();
|
||||
this.syncFlag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.uni-countdown {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.uni-countdown__splitor {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.uni-countdown__number {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
156
components/navbar.vue
Normal file
156
components/navbar.vue
Normal file
@@ -0,0 +1,156 @@
|
||||
<template>
|
||||
<view class="index">
|
||||
<view class="navbar" :style="[{'background':Background},{'height':HeighT.customBar+'px'}]" >
|
||||
<!-- <view v-if="navboxshow == '0'" class="navbar_tow flex-between"
|
||||
:style="[{'background':Backgroundtow},{'padding-right':HeighT.custwidth + 'px'},{'top':HeighT.customBar+'rpx'}]"> -->
|
||||
<!-- #ifndef H5 -->
|
||||
<view v-if="navboxshow == '0'" class="navbar_tow flex-between"
|
||||
:style="[{'background':Backgroundtow},{'top':HeighT.customBar+'rpx'}]">
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef H5 -->
|
||||
<view v-if="navboxshow == '0'" class="navbar_tow flex-between" :style="[{'background':Backgroundtow}]">
|
||||
<!-- #endif -->
|
||||
<!-- 盒子1 返回标题 -->
|
||||
<view class="flex-between">
|
||||
<!-- <u-icon name="arrow-left" color="#000" size="22" @click="childMethod('left')"></u-icon> -->
|
||||
<text class="navbar_tow_one">{{navtitle}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="navboxshow == '1'" class="navbar_tow flex-between"
|
||||
:style="[{'background':Backgroundtow},{'padding-right':HeighT.custwidth + 'px'},{'top':HeighT.customBar+'px'}]">
|
||||
<!-- 盒子2 返回标题搜索框 -->
|
||||
<view class="flex-between">
|
||||
<u-icon name="arrow-left" color="#000" size="22"
|
||||
@click="childMethod('left',navMethodcan)"></u-icon>
|
||||
<u-search placeholder="请输入关键字" :showAction='false' v-model="keyword"></u-search>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="navboxshow == '4'" class="navbar_tow flex-between"
|
||||
:style="[{'background':Backgroundtow},{'padding-right':HeighT.custwidth + 'px'},{'top':HeighT.customBar+'rpx'}]">
|
||||
<view class="flex-between">
|
||||
<u-icon name="arrow-left" color="#000" size="22" @click="childMethod('left')"></u-icon>
|
||||
<text class="navbar_tow_one">{{navtitle}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="navboxshow == '3'" class="navbar_tow flex-between"
|
||||
:style="[{'background':Backgroundtow},{'padding-right':HeighT.custwidth + 'px'},{'top':HeighT.customBar+'rpx'}]">
|
||||
<!-- 盒子3 返回标题搜索框 -->
|
||||
<view class="flex-between">
|
||||
<u-icon style="z-index: 9999;" name="arrow-left" color="#000" size="22"
|
||||
@click="childMethod('left')"></u-icon>
|
||||
<text
|
||||
style="flex: 1; text-align: center;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;font-size: 28rpx;padding: 0 5rpx;">{{navtitle}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- #ifndef H5 -->
|
||||
<view v-if="navboxshow == '2'" class="navbar_tow flex-between"
|
||||
:style="[{'background':Backgroundtow},{'top':HeighT.customBar+'px'}]">
|
||||
<!-- #endif -->
|
||||
<!-- #ifdef H5 -->
|
||||
<view v-if="navboxshow == '2'" class="navbar_tow flex-between"
|
||||
:style="[{'background':Backgroundtow}]">
|
||||
<!-- #endif -->
|
||||
<!-- 盒子3 返回kongbai -->
|
||||
<view class="flex-between">
|
||||
<u-icon name="arrow-left" color="#000" size="22" @click="childMethod('left')"></u-icon>
|
||||
<text class="navbar_tow_there">{{navtitle}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<view v-if='collapse' :style="[{'padding-top':HeighT.customBar+'px'}]"></view>
|
||||
<!-- #endif -->
|
||||
<!-- #ifndef MP-WEIXIN -->
|
||||
<view v-if='collapse' style="padding-top:44px;"></view>
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import navbar from '../uni_modules/uview-ui/libs/config/props/navbar';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
Backgroundtow: 'none',
|
||||
keyword: ""
|
||||
}
|
||||
},
|
||||
props: {
|
||||
navboxshow: {
|
||||
type: String,
|
||||
default: '0'
|
||||
},
|
||||
navtitle: {
|
||||
type: String,
|
||||
default: '预约'
|
||||
},
|
||||
navMethodcan: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
Background: {
|
||||
type: String,
|
||||
default: '#fff'
|
||||
},
|
||||
collapse: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
HeighT() {
|
||||
return this.$store.getters.is_BarHeight
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
childMethod(a, b) {
|
||||
this.$emit('fatherMethod', a)
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.index {
|
||||
.navbar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
z-index: 999;
|
||||
|
||||
.navbar_one {}
|
||||
|
||||
.navbar_tow {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
background: none;
|
||||
height: $uni-height-nav;
|
||||
line-height: $uni-height-nav;
|
||||
font-size: 36rpx;
|
||||
|
||||
.flex-between {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
|
||||
.navbar_tow_one {
|
||||
flex: auto;
|
||||
text-align: center;
|
||||
font-size: 36rpx;
|
||||
font-family: PingFang SC, PingFang SC;
|
||||
font-weight: bold;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.navbar_tow_there {
|
||||
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
137
components/pick-regions/pick-regions.vue
Normal file
137
components/pick-regions/pick-regions.vue
Normal file
@@ -0,0 +1,137 @@
|
||||
<template>
|
||||
<picker mode="multiSelector"
|
||||
:value="multiIndex"
|
||||
:range="multiArray"
|
||||
@change="handleValueChange"
|
||||
@columnchange="handleColumnChange">
|
||||
<slot></slot>
|
||||
</picker>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const CHINA_REGIONS = require('./regions.json')
|
||||
export default {
|
||||
props:{
|
||||
defaultRegions:{
|
||||
type:Array,
|
||||
default(){
|
||||
return []
|
||||
}
|
||||
},
|
||||
defaultRegionCode:{
|
||||
type:String
|
||||
},
|
||||
defaultRegion:[String,Array]
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
cityArr:CHINA_REGIONS[0].childs,
|
||||
districtArr:CHINA_REGIONS[0].childs[0].childs,
|
||||
multiIndex: [0, 0, 0],
|
||||
isInitMultiArray:true,
|
||||
}
|
||||
},
|
||||
watch:{
|
||||
defaultRegion:{
|
||||
handler(region,oldRegion){
|
||||
if(Array.isArray(region)){
|
||||
// 避免传的是字面量的时候重复触发
|
||||
oldRegion = oldRegion || []
|
||||
if(region.join('')!==oldRegion.join('')){
|
||||
this.handleDefaultRegion(region)
|
||||
}
|
||||
}else if(region&®ion.length == 6){
|
||||
this.handleDefaultRegion(region)
|
||||
}else{
|
||||
console.warn('defaultRegion非有效格式')
|
||||
}
|
||||
},
|
||||
immediate:true,
|
||||
}
|
||||
},
|
||||
computed:{
|
||||
multiArray(){
|
||||
return this.pickedArr.map(arr=>arr.map(item=>item.name))
|
||||
},
|
||||
pickedArr(){
|
||||
// 进行初始化
|
||||
if(this.isInitMultiArray){
|
||||
return [
|
||||
CHINA_REGIONS,
|
||||
CHINA_REGIONS[0].childs,
|
||||
CHINA_REGIONS[0].childs[0].childs
|
||||
]
|
||||
}
|
||||
return [CHINA_REGIONS,this.cityArr,this.districtArr];
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleColumnChange(e){
|
||||
// console.log(e);
|
||||
this.isInitMultiArray = false;
|
||||
const that = this;
|
||||
let col = e.detail.column;
|
||||
let row = e.detail.value;
|
||||
that.multiIndex[col] = row;
|
||||
try{
|
||||
switch(col){
|
||||
case 0:
|
||||
if(CHINA_REGIONS[that.multiIndex[0]].childs.length==0){
|
||||
that.cityArr = that.districtArr = [CHINA_REGIONS[that.multiIndex[0]]]
|
||||
break;
|
||||
}
|
||||
that.cityArr = CHINA_REGIONS[that.multiIndex[0]].childs
|
||||
that.districtArr = CHINA_REGIONS[that.multiIndex[0]].childs[that.multiIndex[1]].childs
|
||||
break;
|
||||
case 1:
|
||||
that.districtArr = CHINA_REGIONS[that.multiIndex[0]].childs[that.multiIndex[1]].childs
|
||||
break;
|
||||
case 2:
|
||||
break;
|
||||
}
|
||||
}catch(e){
|
||||
// console.log(e);
|
||||
that.districtArr = CHINA_REGIONS[that.multiIndex[0]].childs[0].childs
|
||||
}
|
||||
|
||||
},
|
||||
handleValueChange(e){
|
||||
// 结构赋值
|
||||
let [index0,index1,index2] = e.detail.value;
|
||||
let [arr0,arr1,arr2] = this.pickedArr;
|
||||
let address = [arr0[index0],arr1[index1],arr2[index2]];
|
||||
// console.log(address);
|
||||
this.$emit('getRegion',address)
|
||||
},
|
||||
handleDefaultRegion(region){
|
||||
const isCode = !Array.isArray(region)
|
||||
this.isInitMultiArray = false;
|
||||
let children = CHINA_REGIONS
|
||||
for(let i=0;i<3;i++){
|
||||
for(let j=0;j<children.length;j++){
|
||||
let condition = isCode?children[j].code==region.slice(0,(i+1)*2):children[j].name.includes(region[i]);
|
||||
if(condition){
|
||||
// 匹配成功进行赋值
|
||||
// console.log(i,j,children.length-1);
|
||||
children = children[j].childs;
|
||||
if(i==0){
|
||||
this.cityArr = children
|
||||
}else if(i==1){
|
||||
this.districtArr = children
|
||||
}
|
||||
this.$set(this.multiIndex,i,j)
|
||||
// console.log(this.multiIndex);
|
||||
break;
|
||||
}else{
|
||||
// 首次匹配失败就用默认的初始化
|
||||
// console.log(i,j,children.length-1);
|
||||
if(i==0 && j==(children.length-1)){
|
||||
this.isInitMultiArray = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
1
components/pick-regions/regions.json
Normal file
1
components/pick-regions/regions.json
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user