12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- // components/dateselect/index.ts
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- g_cdn: String
- },
- /**
- * 组件的初始数据
- */
- data: {
- current: 0,
- date: [{
- key: 7,
- name: '最近7天'
- },
- {
- key: 14,
- name: '最近14天'
- },
- {
- key: 30,
- name: '最近30天'
- }]
- },
- /**
- * 组件的方法列表
- */
- methods: {
- swiperChange(e:any) {
- this.triggerEvent('dateselect',{current:this.data.date[e.detail.current]}, { bubbles: true, composed: true })
- },
- tabSwitch(e: any) {
- let idx = this.data.current
- let { oper } = e.currentTarget.dataset
- if (oper == 'prev') {
- idx -= 1
- if (idx < 0) {
- idx = this.data.date.length - 1
- }
- } else {
- idx += 1
- if (idx > this.data.date.length - 1) {
- idx = 0
- }
- }
- this.setData({
- current: idx
- })
- }
- }
- })
|