Commit e56a2d02 by cen

Merge branch 'V4.56.0' of http://192.168.3.233:8090/glsx/gl_tape into V4.56.0

2 parents d24163bf 8fe8604c
......@@ -7,6 +7,7 @@ import pointApi from './point'
import receptionApi from './receptionApi'
import sceneMarketApi from './sceneMarketApi'
import interceptionApi from './interceptionApi'
import popupApi from './popupApi'
module.exports = {
commonApi,
systemApi,
......@@ -16,5 +17,6 @@ module.exports = {
pointApi,
receptionApi,
sceneMarketApi,
interceptionApi
interceptionApi,
popupApi
}
import http from '../request/http'
module.exports = {
/** 销售顾问/录单员 & 交付专员 */
getEmployeeList (data) {
return http.post({
method: 'dj.api.smartcarlife.employee.onTheJob.getByMerchantId',
projectName: 'boutique',
...data
})
},
/**
* 二级流量方
*/
getDiversionMerchantRef (data) {
return http.post({
method: 'dj.api.smartcarlife.diversionMerchant.getDiversionMerchantRef',
projectName: 'boutique',
...data
})
},
/**
* 获取门店品牌车型
*/
getMerchantCarBrandList (data) {
return http.post({
method: 'dj.api.get.car.brandList',
projectName: 'boutique',
needCarSeries: true,
...data
})
},
}
\ No newline at end of file
......@@ -24,7 +24,6 @@ export default {
})
},
mounted() {
console.log('消息')
this.getMessageSummary()
},
methods: {
......@@ -32,7 +31,6 @@ export default {
async getMessageSummary() {
const userInfo = uni.$storage.get('userInfo')
const res = await getMessageSummary({businessType: userInfo.sceneType})
console.log(res, '===')
this.messageList = res
},
handleClick(item) {
......
......@@ -45,7 +45,6 @@ export default {
},
inject: ['showPage'],
mounted() {
console.log(this.messageData)
},
methods: {
open() {
......@@ -55,7 +54,6 @@ export default {
this.$refs.popup.close()
},
toMessage() {
console.log(this.messageData)
const {messageData} = this
this.showPage('MessageDetail', {...messageData, type: 'read'})
this.close()
......
......@@ -279,7 +279,6 @@ export default {
},
backHome () {
this.showHome = true
console.log(this.$refs.pointRef)
Promise.resolve().then(() => {
this.$refs.pointRef?.$refs?.centerRef?.init && this.$refs.pointRef.$refs.centerRef.init()
})
......@@ -298,7 +297,6 @@ export default {
this.pointComponentName = name
},
handleOperation (val, data) {
console.log(val, data, 'val, data')
const { type } = val;
// 提取公共的webview设置逻辑
......@@ -326,9 +324,6 @@ export default {
if (!setWebviewStyleWithRetry()) {
// 如果未成功,继续重试
setTimeout(retrySetWebviewStyle, 50);
} else {
// 成功设置样式,结束循环
console.log('Webview样式设置成功');
}
};
......@@ -372,9 +367,7 @@ export default {
},
// 学习中心修改阅读状态,打开后才修改
async getStudyCenterRead (id) {
console.log(id, 'getStudyCenterRead')
const res = await uni.$api.commonApi.getStudyCenterRead({ id })
console.log(res)
},
showReadCountTips (res) {
......@@ -405,7 +398,7 @@ export default {
this.$emit('start')
},
async entranceClick (item) {
if (item.name != 'DailyReport' && (await this.checkDailyReport() || await this.inspectionOfProhibitionBill())) return
// if (item.name != 'DailyReport' && (await this.checkDailyReport() || await this.inspectionOfProhibitionBill())) return
uni.navigateTo({
url: `/pages/boutique/tool/index?componentName=${item.name}`
})
......@@ -594,6 +587,9 @@ export default {
}
.tool-box {
height: calc(100% - #{toRpx(712)});
.content-box{
margin: 0 toRpx(48);
}
}
}
.content-right {
......
<template>
<view class="car-model-box">
<scroll-view
class="scroll-view"
scroll-y
:scroll-into-view="letter"
>
<template v-for="(i, index) in list">
<view
class="item-box"
:key="index"
:id="i.letter"
>
<view class="letter-title flex">{{i.letter}}</view>
<template v-for="(c,cindex) in i.list">
<view
class="car-model"
:key="cindex"
>
<view class="brand-name">{{c.name}}</view>
<template v-for="(j, jindex) in c.childs">
<view
class="brand-list"
:key="jindex"
>
<view class="sub-brand-name">{{j.name}}</view>
<view class="car-model-list">
<template v-for="(k, kindex) in j.childs">
<view
:class="['item flex',{
active: currentId ? k.id == currentId : k.id == data.customer[params.idKey]
}]"
:key="`${k.id}_${kindex}`"
@click="choose(k , c)"
>{{k.name}}</view>
</template>
</view>
</view>
</template>
</view>
</template>
</view>
</template>
</scroll-view>
<view class="letter-list">
<template v-for="(i, index) in list">
<view
class="letter-item"
:key="index"
@click="letter = i.letter"
>
{{i.letter}}
</view>
</template>
</view>
</view>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'CarModelList',
inject: ['userInfo'],
data () {
return {
list: [],
currentId: '',
searchList: [],
letter: 'A'
}
},
props: {
params: Object,
data: Object,
apiData: Array
},
mounted () {
},
methods: {
async getList () {
const { userInfo, apiData } = this
this.currentId = ''
if (apiData && apiData.length) {
this.list = apiData
return
}
const { shopMerchantId } = userInfo,
data = await uni.$api.popupApi.getMerchantCarBrandList({
merchantId: shopMerchantId
})
if (data && data.length) this.initCarList(data)
},
initCarList (carData) {
let { params: { idKey }, data: { customer } } = this,
letterList = Array.from(new Set([...carData.map((e) => e.letter)])),
carModelList = letterList.map(e => {
let list = []
carData.map(i => {
if (e === i.letter) {
let c_list = []
i.childs.map(c => {
if (c.childs) {
c.childs.map((s) => {
s.carChildsBrandId = c.id;
s.carChildsBrandName = c.name;
if (customer[idKey]) {
if (s.id == customer[idKey]) {
s.active = true;
this.letter = i.letter;
}
}
});
let carSecondInfo = {
carChildsBrandId: c.id,
carChildsBrandName: c.name,
name: c.name,
isTitle: true,
};
c_list = [...c_list, carSecondInfo, ...c.childs];
}
})
i.childs_list = c_list;
list.push(i)
}
})
return {
letter: e,
list,
}
})
console.log(carModelList)
this.list = carModelList
this.$emit('update:apiData', carModelList)
},
handleSearch (searchValue) {
console.log(searchValue)
},
choose (that, item) {
let chooseItem = {
carBrandId: item.id,
carBrand: item.name,
carChildsBrandId: that.carChildsBrandId,
carChildsBrandName: that.carChildsBrandName,
carSeriesId: that.id,
carSeriesName: that.name,
}
this.currentId = that.id
this.$emit('choose', chooseItem)
}
}
}
</script>
<style scoped lang='scss'>
.car-model-box {
position: relative;
height: 100%;
width: 100%;
.scroll-view {
height: 100%;
}
.letter-list {
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 0;
color: #888888;
font-size: 28rpx;
line-height: 40rpx;
padding: 0 18rpx;
text-align: center;
}
.item-box {
margin-bottom: 32rpx;
.letter-title {
color: #888888;
font-size: 28rpx;
height: 40rpx;
background: #f5f7fa;
padding-left: 48rpx;
}
.car-model {
margin: 0 48rpx;
.brand-name {
color: #333333;
font-size: 32rpx;
line-height: 44rpx;
margin-top: 16rpx;
}
.sub-brand-name {
margin: 16rpx 0;
color: #888888;
font-size: 28rpx;
line-height: 40rpx;
}
}
}
.car-model-list {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 32rpx;
.item {
justify-content: center;
height: 72rpx;
border-radius: 8rpx;
border: 2rpx solid #dce0e6;
box-sizing: border-box;
position: relative;
color: #333333;
font-size: 32rpx;
.sprite-icon {
display: none;
position: absolute;
top: 0;
right: 0;
}
}
.active {
border-color: #2c66f7;
background: #ecf1ff;
color: #2c66f7;
.sprite-icon {
display: block;
}
}
}
}
</style>
\ No newline at end of file
<template>
<view class="merchant-list">
<template v-for="(i, index) in list">
<view
:key="index"
@click="choose(i)"
:class="['item flex',{active: currentId ? i.subMerchantId == currentId : i.subMerchantId == data[params.idKey]}]"
>
<view class="sprite-icon icon-tag-checked"></view>
{{i.subMerchantName}}
</view>
</template>
</view>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'DiversionMerchant',
inject: ['userInfo'],
data () {
return {
list: [],
currentId: ''
}
},
props: {
params: Object,
data: Object,
apiData: Array
},
mounted () {
},
methods: {
async getList () {
const { userInfo, apiData } = this,
{ shopMerchantId } = userInfo
this.currentId = ''
if (apiData && apiData.length) {
this.list = apiData
return
}
const data = await uni.$api.popupApi.getDiversionMerchantRef({
merchantId: shopMerchantId
})
if (data && data.length) {
this.list = data
this.$emit('update:apiData', data)
}
},
choose (i) {
this.currentId = i.subMerchantId
this.$emit('choose', i)
}
}
}
</script>
<style scoped lang='scss'>
.merchant-list {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 32rpx;
margin: 0 48rpx;
.item {
justify-content: center;
height: 72rpx;
border-radius: 8rpx;
border: 2rpx solid #dce0e6;
box-sizing: border-box;
position: relative;
color: #333333;
font-size: 32rpx;
.sprite-icon {
display: none;
position: absolute;
top: 0;
right: 0;
}
}
.active {
border-color: #2c66f7;
background: #ecf1ff;
color: #2c66f7;
.sprite-icon {
display: block;
}
}
}
</style>
\ No newline at end of file
<template>
<view class="employee-list">
<template v-for="(i, index) in list">
<view
:key="index"
@click="choose(i)"
:class="['item flex',{active: currentId ? i.uuid == currentId : i.uuid == data[params.idKey]}]"
>
<view class="sprite-icon icon-tag-checked"></view>
{{i.staffName}}
</view>
</template>
</view>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'EmployeeList',
inject: ['userInfo'],
data () {
return {
list: [],
currentId: ''
}
},
props: {
params: Object,
data: Object,
apiData: Array
},
mounted () {
},
methods: {
async getList (searchValue) {
const { userInfo, params, apiData } = this
this.currentId = ''
if (apiData && apiData.length) {
this.list = apiData
return
}
const { shopMerchantId, sceneType, merchantId } = userInfo,
data = await uni.$api.popupApi.getEmployeeList({
merchantId: params.idKey == 'sellerUserId' ? merchantId : shopMerchantId,
sceneList: params.idKey == 'sellerUserId' ? '' : [sceneType],
name: searchValue
})
if (data && data.length) {
this.list = data
if (!searchValue) this.$emit('update:apiData', data)
}
},
handleSearch (searchValue) {
this.list = []
this.getList(searchValue)
},
choose (i) {
this.currentId = i.uuid
this.$emit('choose', i)
}
}
}
</script>
<style scoped lang='scss'>
.employee-list {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 32rpx;
margin: 0 48rpx;
.item {
justify-content: center;
height: 72rpx;
border-radius: 8rpx;
border: 2rpx solid #dce0e6;
box-sizing: border-box;
position: relative;
color: #333333;
font-size: 32rpx;
.sprite-icon {
display: none;
position: absolute;
top: 0;
right: 0;
}
}
.active {
border-color: #2c66f7;
background: #ecf1ff;
color: #2c66f7;
.sprite-icon {
display: block;
}
}
}
</style>
\ No newline at end of file
/**
* 0:销售顾问/录单员
* 1:交付专员
* 2:二级流量方
* 3:转化人员
* 4:车品牌
*/
const componentConfig = {
0: {
name: 'EmployeeList',
title: '销售顾问/录单员',
placeholder: '请输入姓名',
idKey: 'userId'
},
1: {
name: 'EmployeeList',
title: '交付专员',
placeholder: '请输入姓名',
idKey: 'deliveryUserId'
},
2: {
name: 'DiversionMerchant',
title: '二级流量方',
hideSearch: true,
idKey: 'subShopMerchantId'
},
3: {
name: 'EmployeeList',
title: '转化人员',
placeholder: '请输入姓名',
idKey: 'sellerUserId',
},
4: {
name: 'CarModelList',
title: '选择车型',
placeholder: '查找',
idKey: 'carSeriesId'
},
}
import EmployeeList from './components/EmployeeList.vue'
import DiversionMerchant from './components/DiversionMerchant.vue'
import CarModelList from './components/CarModelList.vue'
export default {
data(){
return {
componentConfig
}
},
components: {
EmployeeList,
DiversionMerchant,
CarModelList
},
}
\ No newline at end of file
<template>
<uni-popup
ref="popup"
:type="position"
:is-mask-click="maskClick"
:animation="animation"
>
<view :class="['popup-box']">
<view class="popup-title flex">
{{title}}
<view
class="popup-close flex"
@click="close"
>
<uni-icons
type="closeempty"
size="16"
></uni-icons>
</view>
</view>
<template v-if="!componentObject.hideSearch">
<view class="popup-search">
<input
class="input"
type="text"
:placeholder="componentObject.placeholder || '请输入'"
placeholder-class="placeholder"
v-model="searchValue"
confirm-type="search"
@confirm="handleSearch"
>
</view>
</template>
<view :class="['popup-body',{ 'hide-search' :componentObject.hideSearch}]">
<scroll-view
scroll-y
class="popup-scroll-view"
>
<component
:is="componentObject.name"
:params="componentObject"
:data="data"
ref="componentRef"
@choose="chooseContent = $event"
:apiData.sync="apiData"
></component>
</scroll-view>
</view>
<view class="popup-footer flex">
<view
class="popup-btn popup-cancel"
@click="cancel"
>取消</view>
<view
class="popup-btn popup-confirm"
@click="confirm"
>确定</view>
</view>
</view>
</uni-popup>
</template>
<script type='text/ecmascript-6'>
import config from './config'
export default {
mixins: [config],
name: '',
props: {
animation: {
type: Boolean,
default: true
},
maskClick: {
type: Boolean,
default: false
},
/**
* 0:销售顾问/录单员
* 1:交付专员
* 2:二级流量方
* 3:转化专员
*/
popupType: {
type: [Number, String],
default: 0
},
data: {
type: Object,
default: () => ({})
},
},
provide () {
return {
userInfo: this.userInfo
}
},
data () {
return {
position: 'bottom',
searchValue: '',
chooseContent: null,
apiData: null
}
},
watch: {
popupType: {
handler (val) {
// console.log(val)
},
immediate: true
},
},
computed: {
componentObject () {
return this.componentConfig[this.popupType]
},
title () {
return this.componentConfig[this.popupType].title
},
userInfo () {
return uni.$storage.get("userInfo")
},
},
mounted () {
},
methods: {
componentRef () {
return this.$refs.componentRef
},
open () {
this.$refs.popup.open()
this.initPopupData()
},
cancel () {
this.$refs.popup.close()
this.$emit('cancel')
},
close () {
this.$refs.popup.close()
this.$emit('close')
},
initPopupData () {
let componentRef = this.componentRef()
if (!componentRef) setTimeout(this.initPopupData, .1e3)
else componentRef.getList && componentRef.getList()
},
handleSearch () {
let componentRef = this.componentRef()
if (!componentRef) uni.showToast({
title: '请稍后再试',
icon: 'none'
})
else componentRef.handleSearch(this.searchValue)
},
confirm () {
let { chooseContent } = this
if (chooseContent) {
this.$emit('onConfirm', chooseContent)
this.$refs.popup.close()
}
}
}
}
</script>
<style scoped lang='scss'>
.popup-box {
border-radius: 32rpx 32rpx 0 0;
background: #ffffff;
height: 70vh;
.popup-title {
height: 104rpx;
justify-content: center;
position: relative;
color: #333333;
font-size: 36rpx;
font-weight: 500;
.popup-close {
position: absolute;
height: 100%;
top: 0;
right: 0;
padding: 0 48rpx;
font-weight: 400;
color: #1a1a1a;
}
}
.popup-search {
height: 80rpx;
border-radius: 40rpx;
background: #f5f7fa;
margin: 0 48rpx;
.input {
height: 100%;
width: 100%;
text-align: center;
color: #333;
font-size: 32rpx;
}
.placeholder {
height: 100%;
color: #999ea8;
font-family: uniicons;
display: flex;
align-items: center;
justify-content: center;
&::after {
display: block;
content: '\e654';
margin-left: 16rpx;
height: 100%;
display: flex;
align-items: center;
font-size: 36rpx;
}
}
}
.popup-body {
height: calc(100% - 392rpx);
.popup-scroll-view {
height: 100%;
padding-top: 32rpx;
}
}
.hide-search {
height: calc(100% - 280rpx);
}
.popup-footer {
padding: 64rpx 0;
justify-content: center;
gap: 0 32rpx;
.popup-btn {
display: flex;
align-items: center;
justify-content: center;
width: 720rpx;
height: 80rpx;
border-radius: 64rpx;
background: #f0f1f5;
color: #333333;
font-size: 32rpx;
font-weight: 500;
}
.popup-confirm {
color: #fff;
background: linear-gradient(0deg, #2c66f7 0%, #48a6ff 100%);
}
}
}
</style>
\ No newline at end of file
......@@ -190,7 +190,6 @@ export default {
},
show: {
handler (newValue) {
console.log('案例视频', newValue)
if (newValue) this.init()
if (!newValue) this.handleLeavePage()
},
......@@ -201,7 +200,6 @@ export default {
const userInfo = uni.$storage.get("userInfo")
this.userInfo = userInfo
this.init()
console.log('案例视频')
this.getCategory()
},
methods: {
......@@ -209,14 +207,12 @@ export default {
async handleLeavePage() {
try {
const caseInfo = uni.$storage.get("caseInfo")
console.log(caseInfo, 'caseInfo')
if (caseInfo && caseInfo.length > 0) {
await this.uploadData(caseInfo)
uni.$storage.rm("caseInfo")
}
} catch (e) {
// 可选:错误处理
console.error('上传埋点失败', e)
} finally {
}
},
......@@ -241,7 +237,6 @@ export default {
// 查找是否有相同素材(id相同)
const idx = caseInfo.findIndex(item => item.materialId === params.materialId)
console.log(idx, 'idx')
if (idx !== -1) {
// 已存在,openCount+1
caseInfo[idx].openCount = (caseInfo[idx].openCount || 1) + 1
......@@ -257,7 +252,6 @@ export default {
},
// 上传埋点
async uploadData (caseInfo) {
console.log(caseInfo, 'caseInfo')
// const caseInfo = uni.$storage.get("caseInfo")
if (caseInfo && caseInfo.length > 0) {
......@@ -265,7 +259,6 @@ export default {
}
},
playVideo (item) {
console.log(item, 'item')
this.$emit('preview', item)
const params = {
materialId: item.id,
......
......@@ -25,6 +25,9 @@
<template v-if="toolComponentName !== 'DailyReport'">
<Entrance @entranceClick="entranceClick"></Entrance>
</template>
<template v-else>
</template>
</view>
</view>
<view class="detail-right">
......
......@@ -226,7 +226,6 @@ export default {
const res = await uni.$api.commonApi.updateMessageStatus({
idList: [row.boxId]
})
console.log(res, '===')
}
},
2: () => {
......
## 1.4.12(2024-09-21)
- 修复 calendar在选择日期范围后重新选择日期需要点两次的Bug
## 1.4.11(2024-01-10)
- 修复 回到今天时,月份显示不一致问题
## 1.4.10(2023-04-10)
- 修复 某些情况 monthSwitch 未触发的Bug
## 1.4.9(2023-02-02)
- 修复 某些情况切换月份错误的Bug
## 1.4.8(2023-01-30)
- 修复 某些情况切换月份错误的Bug [详情](https://ask.dcloud.net.cn/question/161964)
## 1.4.7(2022-09-16)
- 优化 支持使用 uni-scss 控制主题色
## 1.4.6(2022-09-08)
- 修复 表头年月切换,导致改变当前日期为选择月1号,且未触发change事件的Bug
## 1.4.5(2022-02-25)
- 修复 条件编译 nvue 不支持的 css 样式的Bug
## 1.4.4(2022-02-25)
- 修复 条件编译 nvue 不支持的 css 样式的Bug
## 1.4.3(2021-09-22)
- 修复 startDate、 endDate 属性失效的Bug
## 1.4.2(2021-08-24)
- 新增 支持国际化
## 1.4.1(2021-08-05)
- 修复 弹出层被 tabbar 遮盖的Bug
## 1.4.0(2021-07-30)
- 组件兼容 vue3,如何创建vue3项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
## 1.3.16(2021-05-12)
- 新增 组件示例地址
## 1.3.15(2021-02-04)
- 调整为uni_modules目录规范
{
"uni-calender.ok": "ok",
"uni-calender.cancel": "cancel",
"uni-calender.today": "today",
"uni-calender.MON": "MON",
"uni-calender.TUE": "TUE",
"uni-calender.WED": "WED",
"uni-calender.THU": "THU",
"uni-calender.FRI": "FRI",
"uni-calender.SAT": "SAT",
"uni-calender.SUN": "SUN"
}
import en from './en.json'
import zhHans from './zh-Hans.json'
import zhHant from './zh-Hant.json'
export default {
en,
'zh-Hans': zhHans,
'zh-Hant': zhHant
}
{
"uni-calender.ok": "确定",
"uni-calender.cancel": "取消",
"uni-calender.today": "今日",
"uni-calender.SUN": "日",
"uni-calender.MON": "一",
"uni-calender.TUE": "二",
"uni-calender.WED": "三",
"uni-calender.THU": "四",
"uni-calender.FRI": "五",
"uni-calender.SAT": "六"
}
{
"uni-calender.ok": "確定",
"uni-calender.cancel": "取消",
"uni-calender.today": "今日",
"uni-calender.SUN": "日",
"uni-calender.MON": "一",
"uni-calender.TUE": "二",
"uni-calender.WED": "三",
"uni-calender.THU": "四",
"uni-calender.FRI": "五",
"uni-calender.SAT": "六"
}
<template>
<view class="uni-calendar-item__weeks-box" :class="{
'uni-calendar-item--disable':weeks.disable,
'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
'uni-calendar-item--checked':(calendar.fullDate === weeks.fullDate && !weeks.isDay) ,
'uni-calendar-item--before-checked':weeks.beforeMultiple,
'uni-calendar-item--multiple': weeks.multiple,
'uni-calendar-item--after-checked':weeks.afterMultiple,
}"
@click="choiceDate(weeks)">
<view class="uni-calendar-item__weeks-box-item">
<text v-if="selected&&weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text>
<text class="uni-calendar-item__weeks-box-text" :class="{
'uni-calendar-item--isDay-text': weeks.isDay,
'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
'uni-calendar-item--before-checked':weeks.beforeMultiple,
'uni-calendar-item--multiple': weeks.multiple,
'uni-calendar-item--after-checked':weeks.afterMultiple,
'uni-calendar-item--disable':weeks.disable,
}">{{weeks.date}}</text>
<text v-if="!lunar&&!weeks.extraInfo && weeks.isDay" class="uni-calendar-item__weeks-lunar-text" :class="{
'uni-calendar-item--isDay-text':weeks.isDay,
'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
'uni-calendar-item--before-checked':weeks.beforeMultiple,
'uni-calendar-item--multiple': weeks.multiple,
'uni-calendar-item--after-checked':weeks.afterMultiple,
}">{{todayText}}</text>
<text v-if="lunar&&!weeks.extraInfo" class="uni-calendar-item__weeks-lunar-text" :class="{
'uni-calendar-item--isDay-text':weeks.isDay,
'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
'uni-calendar-item--before-checked':weeks.beforeMultiple,
'uni-calendar-item--multiple': weeks.multiple,
'uni-calendar-item--after-checked':weeks.afterMultiple,
'uni-calendar-item--disable':weeks.disable,
}">{{weeks.isDay ? todayText : (weeks.lunar.IDayCn === '初一'?weeks.lunar.IMonthCn:weeks.lunar.IDayCn)}}</text>
<text v-if="weeks.extraInfo&&weeks.extraInfo.info" class="uni-calendar-item__weeks-lunar-text" :class="{
'uni-calendar-item--extra':weeks.extraInfo.info,
'uni-calendar-item--isDay-text':weeks.isDay,
'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
'uni-calendar-item--before-checked':weeks.beforeMultiple,
'uni-calendar-item--multiple': weeks.multiple,
'uni-calendar-item--after-checked':weeks.afterMultiple,
'uni-calendar-item--disable':weeks.disable,
}">{{weeks.extraInfo.info}}</text>
</view>
</view>
</template>
<script>
import { initVueI18n } from '@dcloudio/uni-i18n'
import i18nMessages from './i18n/index.js'
const { t } = initVueI18n(i18nMessages)
export default {
emits:['change'],
props: {
weeks: {
type: Object,
default () {
return {}
}
},
calendar: {
type: Object,
default: () => {
return {}
}
},
selected: {
type: Array,
default: () => {
return []
}
},
lunar: {
type: Boolean,
default: false
}
},
computed: {
todayText() {
return t("uni-calender.today")
},
},
methods: {
choiceDate(weeks) {
this.$emit('change', weeks)
}
}
}
</script>
<style lang="scss" scoped>
$uni-font-size-base:14px;
$uni-text-color:#333;
$uni-font-size-sm:12px;
$uni-color-error: #e43d33;
$uni-opacity-disabled: 0.3;
$uni-text-color-disable:#c0c0c0;
$uni-primary: #2979ff !default;
.uni-calendar-item__weeks-box {
flex: 1;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
justify-content: center;
align-items: center;
}
.uni-calendar-item__weeks-box-text {
font-size: $uni-font-size-base;
color: $uni-text-color;
}
.uni-calendar-item__weeks-lunar-text {
font-size: $uni-font-size-sm;
color: $uni-text-color;
}
.uni-calendar-item__weeks-box-item {
position: relative;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
justify-content: center;
align-items: center;
width: 100rpx;
height: 100rpx;
}
.uni-calendar-item__weeks-box-circle {
position: absolute;
top: 5px;
right: 5px;
width: 8px;
height: 8px;
border-radius: 8px;
background-color: $uni-color-error;
}
.uni-calendar-item--disable {
background-color: rgba(249, 249, 249, $uni-opacity-disabled);
color: $uni-text-color-disable;
}
.uni-calendar-item--isDay-text {
color: $uni-primary;
}
.uni-calendar-item--isDay {
background-color: $uni-primary;
opacity: 0.8;
color: #fff;
}
.uni-calendar-item--extra {
color: $uni-color-error;
opacity: 0.8;
}
.uni-calendar-item--checked {
background-color: $uni-primary;
color: #fff;
opacity: 0.8;
}
.uni-calendar-item--multiple {
background-color: $uni-primary;
color: #fff;
opacity: 0.8;
}
.uni-calendar-item--before-checked {
background-color: #ff5a5f;
color: #fff;
}
.uni-calendar-item--after-checked {
background-color: #ff5a5f;
color: #fff;
}
</style>
import CALENDAR from './calendar.js'
class Calendar {
constructor({
date,
selected,
startDate,
endDate,
range
} = {}) {
// 当前日期
this.date = this.getDate(new Date()) // 当前初入日期
// 打点信息
this.selected = selected || [];
// 范围开始
this.startDate = startDate
// 范围结束
this.endDate = endDate
this.range = range
// 多选状态
this.cleanMultipleStatus()
// 每周日期
this.weeks = {}
// this._getWeek(this.date.fullDate)
}
/**
* 设置日期
* @param {Object} date
*/
setDate(date) {
this.selectDate = this.getDate(date)
this._getWeek(this.selectDate.fullDate)
}
/**
* 清理多选状态
*/
cleanMultipleStatus() {
this.multipleStatus = {
before: '',
after: '',
data: []
}
}
/**
* 重置开始日期
*/
resetSatrtDate(startDate) {
// 范围开始
this.startDate = startDate
}
/**
* 重置结束日期
*/
resetEndDate(endDate) {
// 范围结束
this.endDate = endDate
}
/**
* 获取任意时间
*/
getDate(date, AddDayCount = 0, str = 'day') {
if (!date) {
date = new Date()
}
if (typeof date !== 'object') {
date = date.replace(/-/g, '/')
}
const dd = new Date(date)
switch (str) {
case 'day':
dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
break
case 'month':
if (dd.getDate() === 31 && AddDayCount>0) {
dd.setDate(dd.getDate() + AddDayCount)
} else {
const preMonth = dd.getMonth()
dd.setMonth(preMonth + AddDayCount) // 获取AddDayCount天后的日期
const nextMonth = dd.getMonth()
// 处理 pre 切换月份目标月份为2月没有当前日(30 31) 切换错误问题
if(AddDayCount<0 && preMonth!==0 && nextMonth-preMonth>AddDayCount){
dd.setMonth(nextMonth+(nextMonth-preMonth+AddDayCount))
}
// 处理 next 切换月份目标月份为2月没有当前日(30 31) 切换错误问题
if(AddDayCount>0 && nextMonth-preMonth>AddDayCount){
dd.setMonth(nextMonth-(nextMonth-preMonth-AddDayCount))
}
}
break
case 'year':
dd.setFullYear(dd.getFullYear() + AddDayCount) // 获取AddDayCount天后的日期
break
}
const y = dd.getFullYear()
const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0
const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0
return {
fullDate: y + '-' + m + '-' + d,
year: y,
month: m,
date: d,
day: dd.getDay()
}
}
/**
* 获取上月剩余天数
*/
_getLastMonthDays(firstDay, full) {
let dateArr = []
for (let i = firstDay; i > 0; i--) {
const beforeDate = new Date(full.year, full.month - 1, -i + 1).getDate()
dateArr.push({
date: beforeDate,
month: full.month - 1,
lunar: this.getlunar(full.year, full.month - 1, beforeDate),
disable: true
})
}
return dateArr
}
/**
* 获取本月天数
*/
_currentMonthDys(dateData, full) {
let dateArr = []
let fullDate = this.date.fullDate
for (let i = 1; i <= dateData; i++) {
let nowDate = full.year + '-' + (full.month < 10 ?
full.month : full.month) + '-' + (i < 10 ?
'0' + i : i)
// 是否今天
let isDay = fullDate === nowDate
// 获取打点信息
let info = this.selected && this.selected.find((item) => {
if (this.dateEqual(nowDate, item.date)) {
return item
}
})
// 日期禁用
let disableBefore = true
let disableAfter = true
if (this.startDate) {
// let dateCompBefore = this.dateCompare(this.startDate, fullDate)
// disableBefore = this.dateCompare(dateCompBefore ? this.startDate : fullDate, nowDate)
disableBefore = this.dateCompare(this.startDate, nowDate)
}
if (this.endDate) {
// let dateCompAfter = this.dateCompare(fullDate, this.endDate)
// disableAfter = this.dateCompare(nowDate, dateCompAfter ? this.endDate : fullDate)
disableAfter = this.dateCompare(nowDate, this.endDate)
}
let multiples = this.multipleStatus.data
let checked = false
let multiplesStatus = -1
if (this.range) {
if (multiples) {
multiplesStatus = multiples.findIndex((item) => {
return this.dateEqual(item, nowDate)
})
}
if (multiplesStatus !== -1) {
checked = true
}
}
let data = {
fullDate: nowDate,
year: full.year,
date: i,
multiple: this.range ? checked : false,
beforeMultiple: this.dateEqual(this.multipleStatus.before, nowDate),
afterMultiple: this.dateEqual(this.multipleStatus.after, nowDate),
month: full.month,
lunar: this.getlunar(full.year, full.month, i),
disable: !(disableBefore && disableAfter),
isDay
}
if (info) {
data.extraInfo = info
}
dateArr.push(data)
}
return dateArr
}
/**
* 获取下月天数
*/
_getNextMonthDays(surplus, full) {
let dateArr = []
for (let i = 1; i < surplus + 1; i++) {
dateArr.push({
date: i,
month: Number(full.month) + 1,
lunar: this.getlunar(full.year, Number(full.month) + 1, i),
disable: true
})
}
return dateArr
}
/**
* 获取当前日期详情
* @param {Object} date
*/
getInfo(date) {
if (!date) {
date = new Date()
}
const dateInfo = this.canlender.find(item => item.fullDate === this.getDate(date).fullDate)
return dateInfo
}
/**
* 比较时间大小
*/
dateCompare(startDate, endDate) {
// 计算截止时间
startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
// 计算详细项的截止时间
endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
if (startDate <= endDate) {
return true
} else {
return false
}
}
/**
* 比较时间是否相等
*/
dateEqual(before, after) {
// 计算截止时间
before = new Date(before.replace('-', '/').replace('-', '/'))
// 计算详细项的截止时间
after = new Date(after.replace('-', '/').replace('-', '/'))
if (before.getTime() - after.getTime() === 0) {
return true
} else {
return false
}
}
/**
* 获取日期范围内所有日期
* @param {Object} begin
* @param {Object} end
*/
geDateAll(begin, end) {
var arr = []
var ab = begin.split('-')
var ae = end.split('-')
var db = new Date()
db.setFullYear(ab[0], ab[1] - 1, ab[2])
var de = new Date()
de.setFullYear(ae[0], ae[1] - 1, ae[2])
var unixDb = db.getTime() - 24 * 60 * 60 * 1000
var unixDe = de.getTime() - 24 * 60 * 60 * 1000
for (var k = unixDb; k <= unixDe;) {
k = k + 24 * 60 * 60 * 1000
arr.push(this.getDate(new Date(parseInt(k))).fullDate)
}
return arr
}
/**
* 计算阴历日期显示
*/
getlunar(year, month, date) {
return CALENDAR.solar2lunar(year, month, date)
}
/**
* 设置打点
*/
setSelectInfo(data, value) {
this.selected = value
this._getWeek(data)
}
/**
* 获取多选状态
*/
setMultiple(fullDate) {
let {
before,
after
} = this.multipleStatus
if (!this.range) return
if (before && after) {
this.multipleStatus.before = fullDate
this.multipleStatus.after = ''
this.multipleStatus.data = []
} else {
if (!before) {
this.multipleStatus.before = fullDate
} else {
this.multipleStatus.after = fullDate
if (this.dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after);
} else {
this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before);
}
}
}
this._getWeek(fullDate)
}
/**
* 获取每周数据
* @param {Object} dateData
*/
_getWeek(dateData) {
const {
year,
month
} = this.getDate(dateData)
let firstDay = new Date(year, month - 1, 1).getDay()
let currentDay = new Date(year, month, 0).getDate()
let dates = {
lastMonthDays: this._getLastMonthDays(firstDay, this.getDate(dateData)), // 上个月末尾几天
currentMonthDys: this._currentMonthDys(currentDay, this.getDate(dateData)), // 本月天数
nextMonthDays: [], // 下个月开始几天
weeks: []
}
let canlender = []
const surplus = 42 - (dates.lastMonthDays.length + dates.currentMonthDys.length)
dates.nextMonthDays = this._getNextMonthDays(surplus, this.getDate(dateData))
canlender = canlender.concat(dates.lastMonthDays, dates.currentMonthDys, dates.nextMonthDays)
let weeks = {}
// 拼接数组 上个月开始几天 + 本月天数+ 下个月开始几天
for (let i = 0; i < canlender.length; i++) {
if (i % 7 === 0) {
weeks[parseInt(i / 7)] = new Array(7)
}
weeks[parseInt(i / 7)][i % 7] = canlender[i]
}
this.canlender = canlender
this.weeks = weeks
}
//静态方法
// static init(date) {
// if (!this.instance) {
// this.instance = new Calendar(date);
// }
// return this.instance;
// }
}
export default Calendar
{
"id": "uni-calendar",
"displayName": "uni-calendar 日历",
"version": "1.4.12",
"description": "日历组件",
"keywords": [
"uni-ui",
"uniui",
"日历",
"",
"打卡",
"日历选择"
],
"repository": "https://github.com/dcloudio/uni-ui",
"engines": {
"HBuilderX": ""
},
"directories": {
"example": "../../temps/example_temps"
},
"dcloudext": {
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "无"
},
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
"type": "component-vue"
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y",
"alipay": "n"
},
"client": {
"App": {
"app-vue": "y",
"app-nvue": "y"
},
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
"微信浏览器(Android)": "y",
"QQ浏览器(Android)": "y"
},
"H5-pc": {
"Chrome": "y",
"IE": "y",
"Edge": "y",
"Firefox": "y",
"Safari": "y"
},
"小程序": {
"微信": "y",
"阿里": "y",
"百度": "y",
"字节跳动": "y",
"QQ": "y"
},
"快应用": {
"华为": "u",
"联盟": "u"
},
"Vue": {
"vue2": "y",
"vue3": "y"
}
}
}
}
}
## Calendar 日历
> **组件名:uni-calendar**
> 代码块: `uCalendar`
日历组件
> **注意事项**
> 为了避免错误使用,给大家带来不好的开发体验,请在使用组件前仔细阅读下面的注意事项,可以帮你避免一些错误。
> - 本组件农历转换使用的js是 [@1900-2100区间内的公历、农历互转](https://github.com/jjonline/calendar.js)
> - 仅支持自定义组件模式
> - `date`属性传入的应该是一个 String ,如: 2019-06-27 ,而不是 new Date()
> - 通过 `insert` 属性来确定当前的事件是 @change 还是 @confirm 。理应合并为一个事件,但是为了区分模式,现使用两个事件,这里需要注意
> - 弹窗模式下无法阻止后面的元素滚动,如有需要阻止,请在弹窗弹出后,手动设置滚动元素为不可滚动
### 安装方式
本组件符合[easycom](https://uniapp.dcloud.io/collocation/pages?id=easycom)规范,`HBuilderX 2.5.5`起,只需将本组件导入项目,在页面`template`中即可直接使用,无需在页面中`import`和注册`components`。
如需通过`npm`方式使用`uni-ui`组件,另见文档:[https://ext.dcloud.net.cn/plugin?id=55](https://ext.dcloud.net.cn/plugin?id=55)
### 基本用法
在 ``template`` 中使用组件
```html
<view>
<uni-calendar
:insert="true"
:lunar="true"
:start-date="'2019-3-2'"
:end-date="'2019-5-20'"
@change="change"
/>
</view>
```
### 通过方法打开日历
需要设置 `insert` 为 `false`
```html
<view>
<uni-calendar
ref="calendar"
:insert="false"
@confirm="confirm"
/>
<button @click="open">打开日历</button>
</view>
```
```javascript
export default {
data() {
return {};
},
methods: {
open(){
this.$refs.calendar.open();
},
confirm(e) {
console.log(e);
}
}
};
```
## API
### Calendar Props
| 属性名 | 类型 | 默认值| 说明 |
| - | - | - | - |
| date | String |- | 自定义当前时间,默认为今天 |
| lunar | Boolean | false | 显示农历 |
| startDate | String |- | 日期选择范围-开始日期 |
| endDate | String |- | 日期选择范围-结束日期 |
| range | Boolean | false | 范围选择 |
| insert | Boolean | false | 插入模式,可选值,ture:插入模式;false:弹窗模式;默认为插入模式 |
|clearDate |Boolean |true |弹窗模式是否清空上次选择内容 |
| selected | Array |- | 打点,期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}] |
|showMonth | Boolean | true | 是否显示月份为背景 |
### Calendar Events
| 事件名 | 说明 |返回值|
| - | - | - |
| open | 弹出日历组件,`insert :false` 时生效|- |
## 组件示例
点击查看:[https://hellouniapp.dcloud.net.cn/pages/extUI/calendar/calendar](https://hellouniapp.dcloud.net.cn/pages/extUI/calendar/calendar)
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!