diff --git a/.vscode/settings.json b/.vscode/settings.json index 1185618..fba6882 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -48,5 +48,5 @@ "src/uni_modules/uni-search-bar/components/uni-search-bar/i18n", "src/uni_modules/z-paging/components/z-paging/i18n" ], - "cSpell.words": ["xuexiaole"] + "cSpell.words": ["iconfont", "pinia", "VITE", "xuexiaole"] } diff --git a/package.json b/package.json index 7e3b621..814bf1a 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "unplugin-vue-define-options": "^1.4.2", "vue": "^3.3.4", "vue-i18n": "^9.1.9", + "lodash": "4.17.21", "vue-qrcode-reader": "^5.5.7", "weixin-js-sdk": "^1.6.5" }, @@ -93,6 +94,7 @@ "prettier": "^3.0.3", "typescript": "^4.9.5", "vite": "4.1.4", + "@types/lodash": "4.17.16", "vue-eslint-parser": "^9.3.2", "vue-tsc": "^1.0.24" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f3b0851..ed436c3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -62,6 +62,9 @@ importers: lint-staged: specifier: ^15.0.1 version: 15.0.1 + lodash: + specifier: 4.17.21 + version: 4.17.21 pinia: specifier: ^2.0.36 version: 2.0.36(typescript@4.9.5)(vue@3.3.4) @@ -114,6 +117,9 @@ importers: '@dcloudio/vite-plugin-uni': specifier: 3.0.0-3081220230817001 version: 3.0.0-3081220230817001(postcss@8.4.38)(ts-node@10.9.1(@types/node@20.5.1)(typescript@4.9.5))(vite@4.1.4(@types/node@20.5.1)(sass@1.72.0)(terser@5.22.0))(vue@3.3.4) + '@types/lodash': + specifier: 4.17.16 + version: 4.17.16 '@typescript-eslint/eslint-plugin': specifier: ^6.8.0 version: 6.8.0(@typescript-eslint/parser@6.8.0(eslint@8.51.0)(typescript@4.9.5))(eslint@8.51.0)(typescript@4.9.5) @@ -1629,6 +1635,9 @@ packages: '@types/json5@0.0.29': resolution: {integrity: sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==} + '@types/lodash@4.17.16': + resolution: {integrity: sha512-HX7Em5NYQAXKW+1T+FiuG27NGwzJfCX3s1GjOa7ujxZa52kjJLOr4FUxT+giF6Tgxv1e+/czV/iTtBw27WTU9g==} + '@types/minimist@1.2.3': resolution: {integrity: sha512-ZYFzrvyWUNhaPomn80dsMNgMeXxNWZBdkuG/hWlUvXvbdUH8ZERNBGXnU87McuGcWDsyzX2aChCv/SVN348k3A==} @@ -7009,6 +7018,8 @@ snapshots: '@types/json5@0.0.29': {} + '@types/lodash@4.17.16': {} + '@types/minimist@1.2.3': {} '@types/node@20.5.1': {} diff --git a/src/api/global.ts b/src/api/global.ts index be8e4a0..e0ead3b 100644 --- a/src/api/global.ts +++ b/src/api/global.ts @@ -1,24 +1,24 @@ -import $req from './request'; +import $req from './request' // 获取用户信息 export const getUserInfo = () => $req({ url: '/sysUser/selectUser', - }); + }) // 获取客服信息 export const getCsInfo = (id: string) => $req({ url: `/customerService/getInfoByUserId/${id}`, - }); + }) // 更新用户信息 -export const updateUserInfo = (data: anyObj) => +export const updateUserInfo = (data: any) => $req({ url: '/sysUser/editPerfectMessage', method: 'post', data, - }); + }) // 获取协议 export const getAgreeInfo = (id: string, isChat = false) => @@ -27,30 +27,30 @@ export const getAgreeInfo = (id: string, isChat = false) => headers: { Authorization: '', }, - }); + }) // 获取字典 export const getDict = () => $req({ url: '/sysDictType/tree', - }); + }) // 设备通知注册 -export const bindRegId = (data: anyObj) => +export const bindRegId = (data: any) => $req({ url: '/sysUser/dealRegistrationId', method: 'post', data, - }); + }) // 获取未读消息数量 -export const getUnreadNum = () => $req({ url: '/customerService/getUnreadNum' }); +export const getUnreadNum = () => $req({ url: '/customerService/getUnreadNum' }) // 支付创建订单 -export const createInspectorPrepayOrder = (data: anyObj) => { +export const createInspectorPrepayOrder = (data: any) => { return $req({ method: 'post', url: '/orderManagement/createInspectorPrepayOrder', data, - }); -}; + }) +} diff --git a/src/api/login.ts b/src/api/login.ts index 07ed3ca..dc1800c 100644 --- a/src/api/login.ts +++ b/src/api/login.ts @@ -1,4 +1,4 @@ -import $req from './request'; +import $req from './request' /** * 手机号授权 * @param data 请求参数 @@ -8,18 +8,18 @@ export const getBindPhoneTypeApi = data => { method: 'post', url: '/xcx/login/getBindRelationList', data, - }); -}; + }) +} /** * 手机号获取用户身份 * @param data 请求参数 */ -export const getAdminTypeByPhoneApi = (params: anyObj) => +export const getAdminTypeByPhoneApi = (params: any) => $req({ method: 'get', url: '/sysUser/getAdminTypeByPhone', params, - }); + }) /** * 发送验证码 @@ -29,7 +29,7 @@ export const sendCodeMessageApi = data => $req({ method: 'post', url: `/sms/sendMessage?phoneNumbers=${data}`, - }); + }) /** * 手机号验证码登录 @@ -43,7 +43,7 @@ export const smsLoginApi = data => ...data, clientType: 'MOBILE', }, - }); + }) /** * 获取用户信息 @@ -53,17 +53,17 @@ export const getUserInfoApi = () => $req({ method: 'get', url: '/sysUser/selectUser', - }); + }) /** * 更新用户信息 * @param data 请求参数 */ -export const updateUserInfoApi = (data: anyObj) => +export const updateUserInfoApi = (data: any) => $req({ method: 'post', url: '/sysUser/updateInfo', data, - }); + }) /** * 授权用户绑定 * @param data 请求参数 @@ -73,7 +73,7 @@ export const bindAuthInfoApi = data => method: 'post', url: '/wechatPublic/bindAuthInfo', data, - }); + }) /** * 获取静默授权链接 * @param data 请求参数 @@ -82,10 +82,10 @@ export const getAuthUrlApi = () => $req({ method: 'get', url: '/wechatPublic/getAuthUrl', - }); + }) // 退出登录 export const logout = () => $req({ url: '/logout', - }); + }) diff --git a/src/api/modules/academicReport.ts b/src/api/modules/academicReport.ts index c3e6861..9022db1 100644 --- a/src/api/modules/academicReport.ts +++ b/src/api/modules/academicReport.ts @@ -1,60 +1,60 @@ -import $req from '../request'; +import $req from '../request' /** * 学情报告-学科目录 * @param data 请求参数 */ export const subjectApi = (gradeId: string) => - $req({ - method: 'get', - url: `/subject/list/${gradeId}`, - }); + $req({ + method: 'get', + url: `/subject/list/${gradeId}`, + }) /** * 学情报告-学习时长统计 * @param data 请求参数 */ -export const studyTimeStatApi = (params: anyobj) => - $req({ - method: 'get', - url: '/userSubjectReport/study/duration', - params, - }); +export const studyTimeStatApi = (params: any) => + $req({ + method: 'get', + url: '/userSubjectReport/study/duration', + params, + }) /** * 学情报告-视频学习统计 * @param data 请求参数 */ -export const videoStudyStatApi = (params: anyobj) => - $req({ - method: 'get', - url: '/userSubjectReport/study/video', - params, - }); +export const videoStudyStatApi = (params: any) => + $req({ + method: 'get', + url: '/userSubjectReport/study/video', + params, + }) /** * 学情报告-知识图谱统计 * @param data 请求参数 */ -export const knowledgeStudyStatApi = (params: anyobj) => - $req({ - method: 'get', - url: '/userSubjectReport/study/knowledge', - params, - }); +export const knowledgeStudyStatApi = (params: any) => + $req({ + method: 'get', + url: '/userSubjectReport/study/knowledge', + params, + }) /** * 学情报告-错题本统计 * @param data 请求参数 */ -export const studyErrorStatApi = (params: anyobj) => - $req({ - method: 'get', - url: '/userSubjectReport/study/error', - params, - }); +export const studyErrorStatApi = (params: any) => + $req({ + method: 'get', + url: '/userSubjectReport/study/error', + params, + }) /** * 学情报告-英语语感统计 * @param data 请求参数 */ -export const englishLanguageStatApi = (data: anyobj) => - $req({ - method: 'post', - url: '/userSentenceLearn/queryStatListByTimeType', - data, - }); +export const englishLanguageStatApi = (data: any) => + $req({ + method: 'post', + url: '/userSentenceLearn/queryStatListByTimeType', + data, + }) diff --git a/src/api/modules/inviteBind.ts b/src/api/modules/inviteBind.ts index b881d23..f90e644 100644 --- a/src/api/modules/inviteBind.ts +++ b/src/api/modules/inviteBind.ts @@ -1,30 +1,27 @@ -import $req from '../request'; +import $req from '../request' +import { request } from '../request/request' /** * 获取邀请配置 * @param data 请求参数 */ -export const getJsapiSignatureApi = (params: anyobj) => - $req({ - method: 'get', - url: '/wechatPublic/createJsapiSignature', - params, - }); +export const getJsapiSignatureApi = async (params: any) => + await request.get('/wechatPublic/createJsapiSignature', params) /** * 邀请绑定 * @param data 请求参数 */ -export const parentBindInviteApi = (data: anyobj) => - $req({ - method: 'post', - url: '/parentBindInvite', - data, - }); +export const parentBindInviteApi = (data: any) => + $req({ + method: 'post', + url: '/parentBindInvite', + data, + }) /** * 跳转邀请绑定页面后获取对应数据 * @param data 请求参数 */ export const getInviteInfoApi = id => - $req({ - method: 'get', - url: `/parentBindInvite/${id}`, - }); + $req({ + method: 'get', + url: `/parentBindInvite/${id}`, + }) diff --git a/src/api/modules/mine.ts b/src/api/modules/mine.ts index 2d89161..593f20c 100644 --- a/src/api/modules/mine.ts +++ b/src/api/modules/mine.ts @@ -5,7 +5,7 @@ import { request } from '../request/request' * 家长绑定的孩子 * @param params 请求参数 */ -export const getParentBindChildApi = (params: anyObj) => +export const getParentBindChildApi = (params: any) => $req({ method: 'get', url: '/parentBindChild/list', @@ -15,7 +15,7 @@ export const getParentBindChildApi = (params: anyObj) => * 家长绑定的设备 * @param params 请求参数 */ -export const getParentBindDeviceApi = async (params: anyObj) => +export const getParentBindDeviceApi = async (params: any) => await request.get('/parentBindDevice/list', params) /** * 我的孩子-绑定的家长 @@ -30,7 +30,7 @@ export const parentBindChildApi = (id: string) => * 我的孩子-解除绑定家长 * @param params 请求参数 */ -export const childUnBoundParentApi = (data: anyObj) => +export const childUnBoundParentApi = (data: any) => $req({ method: 'post', url: '/parentBindChild/unBound', @@ -40,7 +40,7 @@ export const childUnBoundParentApi = (data: anyObj) => * 我的设备-解除绑定 * @param params 请求参数 */ -export const parentUnBoundDeviceApi = (data: anyObj) => +export const parentUnBoundDeviceApi = (data: any) => $req({ method: 'post', url: '/parentBindDevice/unBound', diff --git a/src/api/modules/warranty.ts b/src/api/modules/warranty.ts index 61f6db3..9fad929 100644 --- a/src/api/modules/warranty.ts +++ b/src/api/modules/warranty.ts @@ -1,31 +1,31 @@ -import $req from '../request'; +import $req from '../request' /** * 家长端-电子保修卡信息 * @param data 请求参数 */ export const getWarrantyCardMsgApi = () => - $req({ - method: 'get', - url: '/parentBind/getBindDeviceList', - }); + $req({ + method: 'get', + url: '/parentBind/getBindDeviceList', + }) /** * 家长端-申请售后 * @param data 请求参数 */ -export const applyServiceApi = (data: anyObj) => - $req({ - method: 'post', - url: '/deviceWarrantyRecord', - data, - }); +export const applyServiceApi = (data: any) => + $req({ + method: 'post', + url: '/deviceWarrantyRecord', + data, + }) /** * 家长端-查询售后历史 * @param data 请求参数 */ -export const getServiceHistoryApi = (params: anyObj) => - $req({ - method: 'get', - url: '/deviceWarrantyRecord/list', - params, - }); +export const getServiceHistoryApi = (params: any) => + $req({ + method: 'get', + url: '/deviceWarrantyRecord/list', + params, + }) diff --git a/src/api/request.ts b/src/api/request.ts index 3ef936f..6528531 100644 --- a/src/api/request.ts +++ b/src/api/request.ts @@ -1,6 +1,7 @@ import { user } from '@/store' import { storeToRefs } from 'pinia' import { getCache } from '@/utils' +import router from '@/router/router' import db from '@/utils/db' const CONFIG = { @@ -50,7 +51,7 @@ const request = async (config: Record): Promise => { Authorization: mergerToken ? `Bearer ${mergerToken}` : '', ...config.headers, }, - complete(res: anyObj) { + complete(res: any) { if (res.statusCode === 200) { if (res.data.code === 200) { return resolve(res.data) @@ -68,9 +69,7 @@ const request = async (config: Record): Promise => { res.href = (config.baseURL || CONFIG.baseURL) + config.url if (res.statusCode === 401) { clear() - uni.reLaunch({ - url: '/pages/login/index', - }) + router.reLaunch('/pages/login/index') } else { uni.showToast({ icon: 'none', diff --git a/src/api/request/interceptor.ts b/src/api/request/interceptor.ts index d835705..324a0b1 100644 --- a/src/api/request/interceptor.ts +++ b/src/api/request/interceptor.ts @@ -2,7 +2,7 @@ import { type RequestOptions, type ResponseData, type ErrorResponse } from './ty import { HTTP_STATUS, ERROR_MSG } from './config' import router from '@/router/router' import db from '@/utils/db' -import toast from '@/utils/toast' +import toast from '@/utils/hud' // 请求拦截器 export const requestInterceptor = async (options: RequestOptions): Promise => { diff --git a/src/components/BackBar/index.vue b/src/components/BackBar/index.vue index 77e453e..ab66969 100644 --- a/src/components/BackBar/index.vue +++ b/src/components/BackBar/index.vue @@ -13,6 +13,8 @@ diff --git a/src/components/CalenderPopup/CalenderPopup.vue b/src/components/CalenderPopup/CalenderPopup.vue index 12f2bd6..c1521b1 100644 --- a/src/components/CalenderPopup/CalenderPopup.vue +++ b/src/components/CalenderPopup/CalenderPopup.vue @@ -8,7 +8,11 @@ - + 取消 @@ -18,22 +22,22 @@ - @@ -84,8 +92,8 @@ const confirm = () => { width: 230rpx; height: 90rpx; border-radius: 20rpx; - background-color: #EFEFFF; - color: #615DFF; + background-color: #efefff; + color: #615dff; font-size: 30rpx; font-weight: 500; } @@ -93,7 +101,7 @@ const confirm = () => { width: 440rpx; height: 90rpx; border-radius: 20rpx; - background-color: #615DFF; + background-color: #615dff; color: #fff; font-size: 30rpx; font-weight: 500; diff --git a/src/components/CustomNavbar/index.vue b/src/components/CustomNavbar/index.vue index 956cffb..4335686 100644 --- a/src/components/CustomNavbar/index.vue +++ b/src/components/CustomNavbar/index.vue @@ -1,46 +1,48 @@ diff --git a/src/components/Tabbar/index.vue b/src/components/Tabbar/index.vue index f5120cb..0fb8c8f 100644 --- a/src/components/Tabbar/index.vue +++ b/src/components/Tabbar/index.vue @@ -22,11 +22,10 @@ diff --git a/src/components/mjui/mj-empty/mj-empty.vue b/src/components/mjui/mj-empty/mj-empty.vue new file mode 100644 index 0000000..20300f1 --- /dev/null +++ b/src/components/mjui/mj-empty/mj-empty.vue @@ -0,0 +1,12 @@ + + + + + diff --git a/src/components/mjui/mj-list-cell/mj-list-cell.vue b/src/components/mjui/mj-list-cell/mj-list-cell.vue new file mode 100644 index 0000000..3d6e48b --- /dev/null +++ b/src/components/mjui/mj-list-cell/mj-list-cell.vue @@ -0,0 +1,80 @@ + + + + + diff --git a/src/components/mjui/mj-list/mj-list.vue b/src/components/mjui/mj-list/mj-list.vue new file mode 100644 index 0000000..66645b4 --- /dev/null +++ b/src/components/mjui/mj-list/mj-list.vue @@ -0,0 +1,28 @@ + + + + diff --git a/src/components/mjui/mj-page/mj-page.vue b/src/components/mjui/mj-page/mj-page.vue new file mode 100644 index 0000000..d8ef552 --- /dev/null +++ b/src/components/mjui/mj-page/mj-page.vue @@ -0,0 +1,188 @@ + + + diff --git a/src/components/mjui/mj-password/mj-password.vue b/src/components/mjui/mj-password/mj-password.vue new file mode 100644 index 0000000..aee06f2 --- /dev/null +++ b/src/components/mjui/mj-password/mj-password.vue @@ -0,0 +1,37 @@ + + + + + diff --git a/src/components/mjui/mj-tabbar/mj-tabbar.ts b/src/components/mjui/mj-tabbar/mj-tabbar.ts new file mode 100644 index 0000000..79f825e --- /dev/null +++ b/src/components/mjui/mj-tabbar/mj-tabbar.ts @@ -0,0 +1,41 @@ +import router from '@/router/router' +import page from '@/utils/page' +import { defineStore } from 'pinia' +import { ref, computed } from 'vue' + +export const useTabbarStore = defineStore('tabbar', () => { + const list = [ + { + pagePath: '/pages/home/home', + text: '首页', + iconPath: '/static/footerBar/home-icon-link.png', + selectedIconPath: '/static/footerBar/home-icon-active.png', + }, + { + pagePath: '/pages/bill/bill', + text: '学费账单', + iconPath: '/static/footerBar/tuitionBill-icon-link.png', + selectedIconPath: '/static/footerBar/tuitionBill-icon-active.png', + }, + { + pagePath: '/pages/mine/mine', + text: '我的', + iconPath: '/static/footerBar/main-icon-link.png', + selectedIconPath: '/static/footerBar/main-icon-active.png', + }, + ] + const currentUrl = page.getPagePath() + const current = ref(list.findIndex(item => item.pagePath === currentUrl)) + + function switchTab(e: any) { + if (current.value === e.index) return + current.value = e.index + router.switchTab(list[e.index].pagePath) + } + + return { + list, + current, + switchTab, + } +}) diff --git a/src/components/mjui/mj-tabbar/mj-tabbar.vue b/src/components/mjui/mj-tabbar/mj-tabbar.vue new file mode 100644 index 0000000..8454816 --- /dev/null +++ b/src/components/mjui/mj-tabbar/mj-tabbar.vue @@ -0,0 +1,23 @@ + + + + + diff --git a/src/components/mjui/mjui.scss b/src/components/mjui/mjui.scss new file mode 100644 index 0000000..4113392 --- /dev/null +++ b/src/components/mjui/mjui.scss @@ -0,0 +1,6 @@ +.mj-list.round { + .tui-list-content { + border-radius: 20rpx !important; + overflow: hidden !important; + } +} diff --git a/src/components/thorui/tui-actionsheet/tui-actionsheet.vue b/src/components/thorui/tui-actionsheet/tui-actionsheet.vue new file mode 100644 index 0000000..71e54f9 --- /dev/null +++ b/src/components/thorui/tui-actionsheet/tui-actionsheet.vue @@ -0,0 +1,219 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-alert/tui-alert.vue b/src/components/thorui/tui-alert/tui-alert.vue new file mode 100644 index 0000000..1a36314 --- /dev/null +++ b/src/components/thorui/tui-alert/tui-alert.vue @@ -0,0 +1,140 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-alerts/tui-alerts.vue b/src/components/thorui/tui-alerts/tui-alerts.vue new file mode 100644 index 0000000..8f4fec0 --- /dev/null +++ b/src/components/thorui/tui-alerts/tui-alerts.vue @@ -0,0 +1,205 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-amount-inwords/tui-amount-inwords.vue b/src/components/thorui/tui-amount-inwords/tui-amount-inwords.vue new file mode 100644 index 0000000..f820429 --- /dev/null +++ b/src/components/thorui/tui-amount-inwords/tui-amount-inwords.vue @@ -0,0 +1,151 @@ + + + + + diff --git a/src/components/thorui/tui-badge/tui-badge.vue b/src/components/thorui/tui-badge/tui-badge.vue new file mode 100644 index 0000000..d361637 --- /dev/null +++ b/src/components/thorui/tui-badge/tui-badge.vue @@ -0,0 +1,129 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-banner-arc/tui-banner-arc.vue b/src/components/thorui/tui-banner-arc/tui-banner-arc.vue new file mode 100644 index 0000000..c1acbc9 --- /dev/null +++ b/src/components/thorui/tui-banner-arc/tui-banner-arc.vue @@ -0,0 +1,72 @@ + + + + + diff --git a/src/components/thorui/tui-bottom-navigation/tui-bottom-navigation.vue b/src/components/thorui/tui-bottom-navigation/tui-bottom-navigation.vue new file mode 100644 index 0000000..d27e787 --- /dev/null +++ b/src/components/thorui/tui-bottom-navigation/tui-bottom-navigation.vue @@ -0,0 +1,392 @@ + + + + + diff --git a/src/components/thorui/tui-bottom-popup/tui-bottom-popup.vue b/src/components/thorui/tui-bottom-popup/tui-bottom-popup.vue new file mode 100644 index 0000000..c06e4ed --- /dev/null +++ b/src/components/thorui/tui-bottom-popup/tui-bottom-popup.vue @@ -0,0 +1,119 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-bubble-popup/tui-bubble-popup.vue b/src/components/thorui/tui-bubble-popup/tui-bubble-popup.vue new file mode 100644 index 0000000..dbb3cea --- /dev/null +++ b/src/components/thorui/tui-bubble-popup/tui-bubble-popup.vue @@ -0,0 +1,204 @@ + + + + diff --git a/src/components/thorui/tui-button/tui-button.vue b/src/components/thorui/tui-button/tui-button.vue new file mode 100644 index 0000000..0d8ba51 --- /dev/null +++ b/src/components/thorui/tui-button/tui-button.vue @@ -0,0 +1,405 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-calendar/tui-calendar.js b/src/components/thorui/tui-calendar/tui-calendar.js new file mode 100644 index 0000000..86522f1 --- /dev/null +++ b/src/components/thorui/tui-calendar/tui-calendar.js @@ -0,0 +1,562 @@ +/** + * @1900-2100区间内的公历、农历互转 + * @公历转农历:solar2lunar(1987,11,01); + * @农历转公历:lunar2solar(1987,09,10); + */ +let calendar = { + /** + * 农历1900-2100的润大小信息表 + * @Array Of Property + * @return Hex + */ + lunarInfo: [0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2, //1900-1909 + 0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977, //1910-1919 + 0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970, //1920-1929 + 0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950, //1930-1939 + 0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557, //1940-1949 + 0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5b0, 0x14573, 0x052b0, 0x0a9a8, 0x0e950, 0x06aa0, //1950-1959 + 0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0, //1960-1969 + 0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b6a0, 0x195a6, //1970-1979 + 0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570, //1980-1989 + 0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x055c0, 0x0ab60, 0x096d5, 0x092e0, //1990-1999 + 0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5, //2000-2009 + 0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930, //2010-2019 + 0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530, //2020-2029 + 0x05aa0, 0x076a3, 0x096d0, 0x04afb, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45, //2030-2039 + 0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0, //2040-2049 + 0x14b63, 0x09370, 0x049f8, 0x04970, 0x064b0, 0x168a6, 0x0ea50, 0x06b20, 0x1a6c4, 0x0aae0, //2050-2059 + 0x0a2e0, 0x0d2e3, 0x0c960, 0x0d557, 0x0d4a0, 0x0da50, 0x05d55, 0x056a0, 0x0a6d0, 0x055d4, //2060-2069 + 0x052d0, 0x0a9b8, 0x0a950, 0x0b4a0, 0x0b6a6, 0x0ad50, 0x055a0, 0x0aba4, 0x0a5b0, 0x052b0, //2070-2079 + 0x0b273, 0x06930, 0x07337, 0x06aa0, 0x0ad50, 0x14b55, 0x04b60, 0x0a570, 0x054e4, 0x0d160, //2080-2089 + 0x0e968, 0x0d520, 0x0daa0, 0x16aa6, 0x056d0, 0x04ae0, 0x0a9d4, 0x0a2d0, 0x0d150, 0x0f252, //2090-2099 + 0x0d520 + ], //2100 + /** + * 公历每个月份的天数普通表 + * @Array Of Property + * @return Number + */ + solarMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], + /** + * 天干地支之天干速查表 + * @Array Of Property trans["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"] + * @return Cn string + */ + Gan: ["\u7532", "\u4e59", "\u4e19", "\u4e01", "\u620a", "\u5df1", "\u5e9a", "\u8f9b", "\u58ec", "\u7678"], + /** + * 天干地支之地支速查表 + * @Array Of Property + * @trans["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"] + * @return Cn string + */ + Zhi: ["\u5b50", "\u4e11", "\u5bc5", "\u536f", "\u8fb0", "\u5df3", "\u5348", "\u672a", "\u7533", "\u9149", "\u620c", + "\u4ea5" + ], + /** + * 天干地支之地支速查表<=>生肖 + * @Array Of Property + * @trans["鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"] + * @return Cn string + */ + Animals: ["\u9f20", "\u725b", "\u864e", "\u5154", "\u9f99", "\u86c7", "\u9a6c", "\u7f8a", "\u7334", "\u9e21", + "\u72d7", "\u732a" + ], + /** + * 24节气速查表 + * @Array Of Property + * @trans["小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至"] + * @return Cn string + */ + solarTerm: ["\u5c0f\u5bd2", "\u5927\u5bd2", "\u7acb\u6625", "\u96e8\u6c34", "\u60ca\u86f0", "\u6625\u5206", + "\u6e05\u660e", "\u8c37\u96e8", "\u7acb\u590f", "\u5c0f\u6ee1", "\u8292\u79cd", "\u590f\u81f3", "\u5c0f\u6691", + "\u5927\u6691", "\u7acb\u79cb", "\u5904\u6691", "\u767d\u9732", "\u79cb\u5206", "\u5bd2\u9732", "\u971c\u964d", + "\u7acb\u51ac", "\u5c0f\u96ea", "\u5927\u96ea", "\u51ac\u81f3" + ], + /** + * 1900-2100各年的24节气日期速查表 + * @Array Of Property + * @return 0x string For splice + */ + sTermInfo: ['9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', '97bcf97c3598082c95f8c965cc920f', + '97bd0b06bdb0722c965ce1cfcc920f', 'b027097bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', + '97bcf97c359801ec95f8c965cc920f', '97bd0b06bdb0722c965ce1cfcc920f', 'b027097bd097c36b0b6fc9274c91aa', + '97b6b97bd19801ec9210c965cc920e', '97bcf97c359801ec95f8c965cc920f', '97bd0b06bdb0722c965ce1cfcc920f', + 'b027097bd097c36b0b6fc9274c91aa', '9778397bd19801ec9210c965cc920e', '97b6b97bd19801ec95f8c965cc920f', + '97bd09801d98082c95f8e1cfcc920f', '97bd097bd097c36b0b6fc9210c8dc2', '9778397bd197c36c9210c9274c91aa', + '97b6b97bd19801ec95f8c965cc920e', '97bd09801d98082c95f8e1cfcc920f', '97bd097bd097c36b0b6fc9210c8dc2', + '9778397bd097c36c9210c9274c91aa', '97b6b97bd19801ec95f8c965cc920e', '97bcf97c3598082c95f8e1cfcc920f', + '97bd097bd097c36b0b6fc9210c8dc2', '9778397bd097c36c9210c9274c91aa', '97b6b97bd19801ec9210c965cc920e', + '97bcf97c3598082c95f8c965cc920f', '97bd097bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', + '97b6b97bd19801ec9210c965cc920e', '97bcf97c3598082c95f8c965cc920f', '97bd097bd097c35b0b6fc920fb0722', + '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', '97bcf97c359801ec95f8c965cc920f', + '97bd097bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', + '97bcf97c359801ec95f8c965cc920f', '97bd097bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', + '97b6b97bd19801ec9210c965cc920e', '97bcf97c359801ec95f8c965cc920f', '97bd097bd07f595b0b6fc920fb0722', + '9778397bd097c36b0b6fc9210c8dc2', '9778397bd19801ec9210c9274c920e', '97b6b97bd19801ec95f8c965cc920f', + '97bd07f5307f595b0b0bc920fb0722', '7f0e397bd097c36b0b6fc9210c8dc2', '9778397bd097c36c9210c9274c920e', + '97b6b97bd19801ec95f8c965cc920f', '97bd07f5307f595b0b0bc920fb0722', '7f0e397bd097c36b0b6fc9210c8dc2', + '9778397bd097c36c9210c9274c91aa', '97b6b97bd19801ec9210c965cc920e', '97bd07f1487f595b0b0bc920fb0722', + '7f0e397bd097c36b0b6fc9210c8dc2', '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', + '97bcf7f1487f595b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', + '97b6b97bd19801ec9210c965cc920e', '97bcf7f1487f595b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', + '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', '97bcf7f1487f531b0b0bb0b6fb0722', + '7f0e397bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', '97b6b97bd19801ec9210c965cc920e', + '97bcf7f1487f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', + '97b6b97bd19801ec9210c9274c920e', '97bcf7f0e47f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', + '9778397bd097c36b0b6fc9210c91aa', '97b6b97bd197c36c9210c9274c920e', '97bcf7f0e47f531b0b0bb0b6fb0722', + '7f0e397bd07f595b0b0bc920fb0722', '9778397bd097c36b0b6fc9210c8dc2', '9778397bd097c36c9210c9274c920e', + '97b6b7f0e47f531b0723b0b6fb0722', '7f0e37f5307f595b0b0bc920fb0722', '7f0e397bd097c36b0b6fc9210c8dc2', + '9778397bd097c36b0b70c9274c91aa', '97b6b7f0e47f531b0723b0b6fb0721', '7f0e37f1487f595b0b0bb0b6fb0722', + '7f0e397bd097c35b0b6fc9210c8dc2', '9778397bd097c36b0b6fc9274c91aa', '97b6b7f0e47f531b0723b0b6fb0721', + '7f0e27f1487f595b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', + '97b6b7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', + '9778397bd097c36b0b6fc9274c91aa', '97b6b7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', + '7f0e397bd097c35b0b6fc920fb0722', '9778397bd097c36b0b6fc9274c91aa', '97b6b7f0e47f531b0723b0b6fb0721', + '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', '9778397bd097c36b0b6fc9274c91aa', + '97b6b7f0e47f531b0723b0787b0721', '7f0e27f0e47f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', + '9778397bd097c36b0b6fc9210c91aa', '97b6b7f0e47f149b0723b0787b0721', '7f0e27f0e47f531b0723b0b6fb0722', + '7f0e397bd07f595b0b0bc920fb0722', '9778397bd097c36b0b6fc9210c8dc2', '977837f0e37f149b0723b0787b0721', + '7f07e7f0e47f531b0723b0b6fb0722', '7f0e37f5307f595b0b0bc920fb0722', '7f0e397bd097c35b0b6fc9210c8dc2', + '977837f0e37f14998082b0787b0721', '7f07e7f0e47f531b0723b0b6fb0721', '7f0e37f1487f595b0b0bb0b6fb0722', + '7f0e397bd097c35b0b6fc9210c8dc2', '977837f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', + '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', '977837f0e37f14998082b0787b06bd', + '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd097c35b0b6fc920fb0722', + '977837f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', + '7f0e397bd07f595b0b0bc920fb0722', '977837f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', + '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', '977837f0e37f14998082b0787b06bd', + '7f07e7f0e47f149b0723b0787b0721', '7f0e27f0e47f531b0b0bb0b6fb0722', '7f0e397bd07f595b0b0bc920fb0722', + '977837f0e37f14998082b0723b06bd', '7f07e7f0e37f149b0723b0787b0721', '7f0e27f0e47f531b0723b0b6fb0722', + '7f0e397bd07f595b0b0bc920fb0722', '977837f0e37f14898082b0723b02d5', '7ec967f0e37f14998082b0787b0721', + '7f07e7f0e47f531b0723b0b6fb0722', '7f0e37f1487f595b0b0bb0b6fb0722', '7f0e37f0e37f14898082b0723b02d5', + '7ec967f0e37f14998082b0787b0721', '7f07e7f0e47f531b0723b0b6fb0722', '7f0e37f1487f531b0b0bb0b6fb0722', + '7f0e37f0e37f14898082b0723b02d5', '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', + '7f0e37f1487f531b0b0bb0b6fb0722', '7f0e37f0e37f14898082b072297c35', '7ec967f0e37f14998082b0787b06bd', + '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e37f0e37f14898082b072297c35', + '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722', + '7f0e37f0e366aa89801eb072297c35', '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f149b0723b0787b0721', + '7f0e27f1487f531b0b0bb0b6fb0722', '7f0e37f0e366aa89801eb072297c35', '7ec967f0e37f14998082b0723b06bd', + '7f07e7f0e47f149b0723b0787b0721', '7f0e27f0e47f531b0723b0b6fb0722', '7f0e37f0e366aa89801eb072297c35', + '7ec967f0e37f14998082b0723b06bd', '7f07e7f0e37f14998083b0787b0721', '7f0e27f0e47f531b0723b0b6fb0722', + '7f0e37f0e366aa89801eb072297c35', '7ec967f0e37f14898082b0723b02d5', '7f07e7f0e37f14998082b0787b0721', + '7f07e7f0e47f531b0723b0b6fb0722', '7f0e36665b66aa89801e9808297c35', '665f67f0e37f14898082b0723b02d5', + '7ec967f0e37f14998082b0787b0721', '7f07e7f0e47f531b0723b0b6fb0722', '7f0e36665b66a449801e9808297c35', + '665f67f0e37f14898082b0723b02d5', '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', + '7f0e36665b66a449801e9808297c35', '665f67f0e37f14898082b072297c35', '7ec967f0e37f14998082b0787b06bd', + '7f07e7f0e47f531b0723b0b6fb0721', '7f0e26665b66a449801e9808297c35', '665f67f0e37f1489801eb072297c35', + '7ec967f0e37f14998082b0787b06bd', '7f07e7f0e47f531b0723b0b6fb0721', '7f0e27f1487f531b0b0bb0b6fb0722' + ], + /** + * 数字转中文速查表 + * @Array Of Property + * @trans ['日','一','二','三','四','五','六','七','八','九','十'] + * @return Cn string + */ + nStr1: ["\u65e5", "\u4e00", "\u4e8c", "\u4e09", "\u56db", "\u4e94", "\u516d", "\u4e03", "\u516b", "\u4e5d", "\u5341"], + /** + * 日期转农历称呼速查表 + * @Array Of Property + * @trans ['初','十','廿','卅'] + * @return Cn string + */ + nStr2: ["\u521d", "\u5341", "\u5eff", "\u5345"], + /** + * 月份转农历称呼速查表 + * @Array Of Property + * @trans ['正','一','二','三','四','五','六','七','八','九','十','冬','腊'] + * @return Cn string + */ + nStr3: ["\u6b63", "\u4e8c", "\u4e09", "\u56db", "\u4e94", "\u516d", "\u4e03", "\u516b", "\u4e5d", "\u5341", "\u51ac", + "\u814a" + ], + /** + * 返回农历y年一整年的总天数 + * @param lunar Year + * @return Number + * @eg:let count = calendar.lYearDays(1987) ;//count=387 + */ + lYearDays: function(y) { + let i, sum = 348; + for (i = 0x8000; i > 0x8; i >>= 1) { + sum += (calendar.lunarInfo[y - 1900] & i) ? 1 : 0; + } + return (sum + calendar.leapDays(y)); + }, + /** + * 返回农历y年闰月是哪个月;若y年没有闰月 则返回0 + * @param lunar Year + * @return Number (0-12) + * @eg:let leapMonth = calendar.leapMonth(1987) ;//leapMonth=6 + */ + leapMonth: function(y) { //闰字编码 \u95f0 + return (calendar.lunarInfo[y - 1900] & 0xf); + }, + /** + * 返回农历y年闰月的天数 若该年没有闰月则返回0 + * @param lunar Year + * @return Number (0、29、30) + * @eg:let leapMonthDay = calendar.leapDays(1987) ;//leapMonthDay=29 + */ + leapDays: function(y) { + if (calendar.leapMonth(y)) { + return ((calendar.lunarInfo[y - 1900] & 0x10000) ? 30 : 29); + } + return (0); + }, + /** + * 返回农历y年m月(非闰月)的总天数,计算m为闰月时的天数请使用leapDays方法 + * @param lunar Year + * @return Number (-1、29、30) + * @eg:let MonthDay = calendar.monthDays(1987,9) ;//MonthDay=29 + */ + monthDays: function(y, m) { + if (m > 12 || m < 1) { + return -1 + } //月份参数从1至12,参数错误返回-1 + return ((calendar.lunarInfo[y - 1900] & (0x10000 >> m)) ? 30 : 29); + }, + /** + * 返回公历(!)y年m月的天数 + * @param solar Year + * @return Number (-1、28、29、30、31) + * @eg:let solarMonthDay = calendar.leapDays(1987) ;//solarMonthDay=30 + */ + solarDays: function(y, m) { + if (m > 12 || m < 1) { + return -1 + } //若参数错误 返回-1 + let ms = m - 1; + if (ms == 1) { //2月份的闰平规律测算后确认返回28或29 + return (((y % 4 == 0) && (y % 100 != 0) || (y % 400 == 0)) ? 29 : 28); + } else { + return (calendar.solarMonth[ms]); + } + }, + /** + * 农历年份转换为干支纪年 + * @param lYear 农历年的年份数 + * @return Cn string + */ + toGanZhiYear: function(lYear) { + let ganKey = (lYear - 3) % 10; + let zhiKey = (lYear - 3) % 12; + if (ganKey == 0) ganKey = 10; //如果余数为0则为最后一个天干 + if (zhiKey == 0) zhiKey = 12; //如果余数为0则为最后一个地支 + return calendar.Gan[ganKey - 1] + calendar.Zhi[zhiKey - 1]; + }, + /** + * 公历月、日判断所属星座 + * @param cMonth [description] + * @param cDay [description] + * @return Cn string + */ + toAstro: function(cMonth, cDay) { + let s = + "\u9b54\u7faf\u6c34\u74f6\u53cc\u9c7c\u767d\u7f8a\u91d1\u725b\u53cc\u5b50\u5de8\u87f9\u72ee\u5b50\u5904\u5973\u5929\u79e4\u5929\u874e\u5c04\u624b\u9b54\u7faf"; + let arr = [20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22]; + return s.substr(cMonth * 2 - (cDay < arr[cMonth - 1] ? 2 : 0), 2) + "\u5ea7"; //座 + }, + /** + * 传入offset偏移量返回干支 + * @param offset 相对甲子的偏移量 + * @return Cn string + */ + toGanZhi: function(offset) { + return calendar.Gan[offset % 10] + calendar.Zhi[offset % 12]; + }, + /** + * 传入公历(!)y年获得该年第n个节气的公历日期 + * @param y公历年(1900-2100);n二十四节气中的第几个节气(1~24);从n=1(小寒)算起 + * @return day Number + * @eg:let _24 = calendar.getTerm(1987,3) ;//_24=4;意即1987年2月4日立春 + */ + getTerm: function(y, n) { + if (y < 1900 || y > 2100) { + return -1; + } + if (n < 1 || n > 24) { + return -1; + } + let _table = calendar.sTermInfo[y - 1900]; + let _info = [ + parseInt('0x' + _table.substr(0, 5)).toString(), + parseInt('0x' + _table.substr(5, 5)).toString(), + parseInt('0x' + _table.substr(10, 5)).toString(), + parseInt('0x' + _table.substr(15, 5)).toString(), + parseInt('0x' + _table.substr(20, 5)).toString(), + parseInt('0x' + _table.substr(25, 5)).toString() + ]; + let _calday = [ + _info[0].substr(0, 1), + _info[0].substr(1, 2), + _info[0].substr(3, 1), + _info[0].substr(4, 2), + _info[1].substr(0, 1), + _info[1].substr(1, 2), + _info[1].substr(3, 1), + _info[1].substr(4, 2), + _info[2].substr(0, 1), + _info[2].substr(1, 2), + _info[2].substr(3, 1), + _info[2].substr(4, 2), + _info[3].substr(0, 1), + _info[3].substr(1, 2), + _info[3].substr(3, 1), + _info[3].substr(4, 2), + _info[4].substr(0, 1), + _info[4].substr(1, 2), + _info[4].substr(3, 1), + _info[4].substr(4, 2), + _info[5].substr(0, 1), + _info[5].substr(1, 2), + _info[5].substr(3, 1), + _info[5].substr(4, 2), + ]; + return parseInt(_calday[n - 1]); + }, + /** + * 传入农历数字月份返回汉语通俗表示法 + * @param lunar month + * @return Cn string + * @eg:let cnMonth = calendar.toChinaMonth(12) ;//cnMonth='腊月' + */ + toChinaMonth: function(m) { // 月 => \u6708 + if (m > 12 || m < 1) { + return -1 + } //若参数错误 返回-1 + let s = calendar.nStr3[m - 1]; + s += "\u6708"; //加上月字 + return s; + }, + /** + * 传入农历日期数字返回汉字表示法 + * @param lunar day + * @return Cn string + * @eg:let cnDay = calendar.toChinaDay(21) ;//cnMonth='廿一' + */ + toChinaDay: function(d) { //日 => \u65e5 + let s; + switch (d) { + case 10: + s = '\u521d\u5341'; + break; + case 20: + s = '\u4e8c\u5341'; + break; + break; + case 30: + s = '\u4e09\u5341'; + break; + break; + default: + s = calendar.nStr2[Math.floor(d / 10)]; + s += calendar.nStr1[d % 10]; + } + return (s); + }, + /** + * 年份转生肖[!仅能大致转换] => 精确划分生肖分界线是“立春” + * @param y year + * @return Cn string + * @eg:let animal = calendar.getAnimal(1987) ;//animal='兔' + */ + getAnimal: function(y) { + return calendar.Animals[(y - 4) % 12] + }, + /** + * 传入阳历年月日获得详细的公历、农历object信息 <=>JSON + * @param y solar year + * @param m solar month + * @param d solar day + * @return JSON object + * @eg:console.log(calendar.solar2lunar(1987,11,01)); + */ + solar2lunar: function(y, m, d) { //参数区间1900.1.31~2100.12.31 + if (y < 1900 || y > 2100) { + return -1; + } //年份限定、上限 + if (y == 1900 && m == 1 && d < 31) { + return -1; + } //下限 + let objDate; + if (!y) { //未传参 获得当天 + objDate = new Date(); + } else { + objDate = new Date(y, parseInt(m) - 1, d) + } + let i, leap = 0, + temp = 0; + //修正ymd参数 + y = objDate.getFullYear(); + m = objDate.getMonth() + 1; + d = objDate.getDate(); + let offset = (Date.UTC(objDate.getFullYear(), objDate.getMonth(), objDate.getDate()) - Date.UTC(1900, 0, 31)) / + 86400000; + for (i = 1900; i < 2101 && offset > 0; i++) { + temp = calendar.lYearDays(i); + offset -= temp; + } + if (offset < 0) { + offset += temp; + i--; + } + //是否今天 + let isTodayObj = new Date(), + isToday = false; + if (isTodayObj.getFullYear() == y && isTodayObj.getMonth() + 1 == m && isTodayObj.getDate() == d) { + isToday = true; + } + //星期几 + let nWeek = objDate.getDay(), + cWeek = calendar.nStr1[nWeek]; + if (nWeek == 0) { + nWeek = 7; + } //数字表示周几顺应天朝周一开始的惯例 + //农历年 + let year = i; + leap = calendar.leapMonth(i); //闰哪个月 + let isLeap = false; + //效验闰月 + for (i = 1; i < 13 && offset > 0; i++) { + //闰月 + if (leap > 0 && i == (leap + 1) && isLeap == false) { + --i; + isLeap = true; + temp = calendar.leapDays(year); //计算农历闰月天数 + } else { + temp = calendar.monthDays(year, i); //计算农历普通月天数 + } + //解除闰月 + if (isLeap == true && i == (leap + 1)) { + isLeap = false; + } + offset -= temp; + } + if (offset == 0 && leap > 0 && i == leap + 1) + if (isLeap) { + isLeap = false; + } else { + isLeap = true; + --i; + } + if (offset < 0) { + offset += temp; + --i; + } + //农历月 + let month = i; + //农历日 + let day = offset + 1; + //天干地支处理 + let sm = m - 1; + let gzY = calendar.toGanZhiYear(year); + //月柱 1900年1月小寒以前为 丙子月(60进制12) + let firstNode = calendar.getTerm(year, (m * 2 - 1)); //返回当月「节」为几日开始 + let secondNode = calendar.getTerm(year, (m * 2)); //返回当月「节」为几日开始 + //依据12节气修正干支月 + let gzM = calendar.toGanZhi((y - 1900) * 12 + m + 11); + if (d >= firstNode) { + gzM = calendar.toGanZhi((y - 1900) * 12 + m + 12); + } + //传入的日期的节气与否 + let isTerm = false; + let Term = null; + if (firstNode == d) { + isTerm = true; + Term = calendar.solarTerm[m * 2 - 2]; + } + if (secondNode == d) { + isTerm = true; + Term = calendar.solarTerm[m * 2 - 1]; + } + //日柱 当月一日与 1900/1/1 相差天数 + let dayCyclical = Date.UTC(y, sm, 1, 0, 0, 0, 0) / 86400000 + 25567 + 10; + let gzD = calendar.toGanZhi(dayCyclical + d - 1); + //该日期所属的星座 + let astro = calendar.toAstro(m, d); + return { + 'lYear': year, + 'lMonth': month, + 'lDay': day, + 'Animal': calendar.getAnimal(year), + 'IMonthCn': (isLeap ? "\u95f0" : '') + calendar.toChinaMonth(month), + 'IDayCn': calendar.toChinaDay(day), + 'cYear': y, + 'cMonth': m, + 'cDay': d, + 'gzYear': gzY, + 'gzMonth': gzM, + 'gzDay': gzD, + 'isToday': isToday, + 'isLeap': isLeap, + 'nWeek': nWeek, + 'ncWeek': "\u661f\u671f" + cWeek, + 'isTerm': isTerm, + 'Term': Term, + 'astro': astro + }; + }, + /** + * 传入农历年月日以及传入的月份是否闰月获得详细的公历、农历object信息 <=>JSON + * @param y lunar year + * @param m lunar month + * @param d lunar day + * @param isLeapMonth lunar month is leap or not.[如果是农历闰月第四个参数赋值true即可] + * @return JSON object + * @eg:console.log(calendar.lunar2solar(1987,9,10)); + */ + lunar2solar: function(y, m, d, isLeapMonth) { //参数区间1900.1.31~2100.12.1 + isLeapMonth = !!isLeapMonth; + let leapOffset = 0; + let leapMonth = calendar.leapMonth(y); + let leapDay = calendar.leapDays(y); + if (isLeapMonth && (leapMonth != m)) { + return -1; + } //传参要求计算该闰月公历 但该年得出的闰月与传参的月份并不同 + if (y == 2100 && m == 12 && d > 1 || y == 1900 && m == 1 && d < 31) { + return -1; + } //超出了最大极限值 + let day = calendar.monthDays(y, m); + let _day = day; + //bugFix 2016-9-25 + //if month is leap, _day use leapDays method + if (isLeapMonth) { + _day = calendar.leapDays(y, m); + } + if (y < 1900 || y > 2100 || d > _day) { + return -1; + } //参数合法性效验 + //计算农历的时间差 + let offset = 0; + for (let i = 1900; i < y; i++) { + offset += calendar.lYearDays(i); + } + let leap = 0, + isAdd = false; + for (let i = 1; i < m; i++) { + leap = calendar.leapMonth(y); + if (!isAdd) { //处理闰月 + if (leap <= i && leap > 0) { + offset += calendar.leapDays(y); + isAdd = true; + } + } + offset += calendar.monthDays(y, i); + } + //转换闰月农历 需补充该年闰月的前一个月的时差 + if (isLeapMonth) { + offset += day; + } + //1900年农历正月一日的公历时间为1900年1月30日0时0分0秒(该时间也是本农历的最开始起始点) + let stmap = Date.UTC(1900, 1, 30, 0, 0, 0); + let calObj = new Date((offset + d - 31) * 86400000 + stmap); + let cY = calObj.getUTCFullYear(); + let cM = calObj.getUTCMonth() + 1; + let cD = calObj.getUTCDate(); + return calendar.solar2lunar(cY, cM, cD); + } +}; + +export default { + solar2lunar: calendar.solar2lunar, + lunar2solar: calendar.lunar2solar +}; diff --git a/src/components/thorui/tui-calendar/tui-calendar.vue b/src/components/thorui/tui-calendar/tui-calendar.vue new file mode 100644 index 0000000..c726796 --- /dev/null +++ b/src/components/thorui/tui-calendar/tui-calendar.vue @@ -0,0 +1,964 @@ + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-card/tui-card.vue b/src/components/thorui/tui-card/tui-card.vue new file mode 100644 index 0000000..3b78343 --- /dev/null +++ b/src/components/thorui/tui-card/tui-card.vue @@ -0,0 +1,234 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-cascade-selection/tui-cascade-selection.vue b/src/components/thorui/tui-cascade-selection/tui-cascade-selection.vue new file mode 100644 index 0000000..5595a16 --- /dev/null +++ b/src/components/thorui/tui-cascade-selection/tui-cascade-selection.vue @@ -0,0 +1,615 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-charts-area/tui-charts-area.vue b/src/components/thorui/tui-charts-area/tui-charts-area.vue new file mode 100644 index 0000000..f0fa0d7 --- /dev/null +++ b/src/components/thorui/tui-charts-area/tui-charts-area.vue @@ -0,0 +1,703 @@ + + + + + diff --git a/src/components/thorui/tui-charts-bar/tui-charts-bar.vue b/src/components/thorui/tui-charts-bar/tui-charts-bar.vue new file mode 100644 index 0000000..09a4f04 --- /dev/null +++ b/src/components/thorui/tui-charts-bar/tui-charts-bar.vue @@ -0,0 +1,580 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-charts-column/tui-charts-column.vue b/src/components/thorui/tui-charts-column/tui-charts-column.vue new file mode 100644 index 0000000..8dbffd3 --- /dev/null +++ b/src/components/thorui/tui-charts-column/tui-charts-column.vue @@ -0,0 +1,609 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-charts-funnel/tui-charts-funnel.vue b/src/components/thorui/tui-charts-funnel/tui-charts-funnel.vue new file mode 100644 index 0000000..4943185 --- /dev/null +++ b/src/components/thorui/tui-charts-funnel/tui-charts-funnel.vue @@ -0,0 +1,273 @@ + + + + + diff --git a/src/components/thorui/tui-charts-line/tui-charts-line.vue b/src/components/thorui/tui-charts-line/tui-charts-line.vue new file mode 100644 index 0000000..a4b8967 --- /dev/null +++ b/src/components/thorui/tui-charts-line/tui-charts-line.vue @@ -0,0 +1,653 @@ + + + + + diff --git a/src/components/thorui/tui-charts-mixed/tui-charts-mixed.vue b/src/components/thorui/tui-charts-mixed/tui-charts-mixed.vue new file mode 100644 index 0000000..c11cd0c --- /dev/null +++ b/src/components/thorui/tui-charts-mixed/tui-charts-mixed.vue @@ -0,0 +1,20 @@ + + + + + diff --git a/src/components/thorui/tui-charts-pie/tui-charts-pie.vue b/src/components/thorui/tui-charts-pie/tui-charts-pie.vue new file mode 100644 index 0000000..ffae88a --- /dev/null +++ b/src/components/thorui/tui-charts-pie/tui-charts-pie.vue @@ -0,0 +1,282 @@ + + + + + diff --git a/src/components/thorui/tui-charts-radar/tui-charts-radar.vue b/src/components/thorui/tui-charts-radar/tui-charts-radar.vue new file mode 100644 index 0000000..0cb0a0c --- /dev/null +++ b/src/components/thorui/tui-charts-radar/tui-charts-radar.vue @@ -0,0 +1,371 @@ + + + + + diff --git a/src/components/thorui/tui-charts-scatter/tui-charts-scatter.vue b/src/components/thorui/tui-charts-scatter/tui-charts-scatter.vue new file mode 100644 index 0000000..abf6463 --- /dev/null +++ b/src/components/thorui/tui-charts-scatter/tui-charts-scatter.vue @@ -0,0 +1,392 @@ + + + + + diff --git a/src/components/thorui/tui-checkbox-group/tui-checkbox-group.vue b/src/components/thorui/tui-checkbox-group/tui-checkbox-group.vue new file mode 100644 index 0000000..e212f28 --- /dev/null +++ b/src/components/thorui/tui-checkbox-group/tui-checkbox-group.vue @@ -0,0 +1,105 @@ + + + + + diff --git a/src/components/thorui/tui-checkbox/tui-checkbox.vue b/src/components/thorui/tui-checkbox/tui-checkbox.vue new file mode 100644 index 0000000..03b577d --- /dev/null +++ b/src/components/thorui/tui-checkbox/tui-checkbox.vue @@ -0,0 +1,229 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-circular-progress/tui-circular-progress.vue b/src/components/thorui/tui-circular-progress/tui-circular-progress.vue new file mode 100644 index 0000000..5cc49c6 --- /dev/null +++ b/src/components/thorui/tui-circular-progress/tui-circular-progress.vue @@ -0,0 +1,309 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-code-input/tui-code-input.vue b/src/components/thorui/tui-code-input/tui-code-input.vue new file mode 100644 index 0000000..698115e --- /dev/null +++ b/src/components/thorui/tui-code-input/tui-code-input.vue @@ -0,0 +1,389 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-col/tui-col.vue b/src/components/thorui/tui-col/tui-col.vue new file mode 100644 index 0000000..64ad47e --- /dev/null +++ b/src/components/thorui/tui-col/tui-col.vue @@ -0,0 +1,3215 @@ + + + + + diff --git a/src/components/thorui/tui-collapse/tui-collapse.vue b/src/components/thorui/tui-collapse/tui-collapse.vue new file mode 100644 index 0000000..446c854 --- /dev/null +++ b/src/components/thorui/tui-collapse/tui-collapse.vue @@ -0,0 +1,167 @@ + + + + + diff --git a/src/components/thorui/tui-config/index.js b/src/components/thorui/tui-config/index.js new file mode 100644 index 0000000..7cd1ec1 --- /dev/null +++ b/src/components/thorui/tui-config/index.js @@ -0,0 +1,129 @@ +/* + 基础组件props属性全局配置文件。优先级:全局配置文件props < 单独设置组件props + 温馨提示:未设置则使用组件内默认值,避免出错,请勿删减以下配置 + 组件属性介绍请查看文档 +*/ + +//组件内主色配置 +const color = { + primary: '#5677fc', + success: '#07c160', + warning: '#ff7900', + danger: '#EB0909', + pink: '#f74d54', + blue: '#007AFF', + link: '#586c94' +} + +const propsConfig = { + //组件内主色配置 + color, + //组件名称,字体图标组件 tui-icon + tuiIcon: { + //组件属性值 + size: 32, + unit: 'px', + color: '#999' + }, + //按钮组件 tui-button + tuiButton: { + height: '96rpx', + size: 32 + }, + //列表项组件 tui-list-cell + tuiListCell: { + arrowColor: '#c0c0c0', + lineColor: '#eaeef1', + lineLeft: 30, + padding: '26rpx 44rpx', + color: '#333', + size: 28 + }, + //按钮组件 tui-form-button + tuiFormButton: { + background: color.primary, + color: '#fff', + height: '96rpx', + size: 32, + radius: '6rpx' + }, + //文本组件 tui-text + tuiText: { + size: 32, + unit: 'rpx', + color: '' + }, + //输入框组件 tui-input + tuiInput: { + requiredColor: color.danger, + labelSize: 32, + labelColor: '#333', + size: 32, + color: '#333', + padding: '26rpx 30rpx', + backgroundColor: '#FFFFFF', + radius: 0 + }, + //表单项组件 tui-form-item + tuiFormItem: { + padding: '28rpx 30rpx', + labelSize: 32, + labelColor: '#333', + labelFontWeight: 400, + asteriskColor: color.danger, + background: '#fff', + arrowColor: '#c0c0c0', + borderColor: '#eaeef1', + radius: '0rpx', + position: 2 + }, + //表单校验组件 tui-form + tuiForm: { + tipBackgroundColor: color.pink, + duration: 2000 + }, + //全局方法,调用 uni.$tui.toast + toast(text, duration, success) { + uni.showToast({ + // #ifndef MP-ALIPAY + duration: duration || 2000, + // #endif + title: text || "出错啦~", + icon: success ? 'success' : 'none' + }) + }, + modal(title, content, showCancel, callback, confirmColor, confirmText) { + uni.showModal({ + title: title || '提示', + content: content, + showCancel: showCancel, + cancelColor: "#555", + confirmColor: confirmColor || color.primary, + confirmText: confirmText || "确定", + success(res) { + if (res.confirm) { + callback && callback(true) + } else { + callback && callback(false) + } + } + }) + }, + //跳转页面 + href(url, isMain) { + if (isMain) { + uni.switchTab({ + url: url + }) + } else { + uni.navigateTo({ + url: url + }); + } + }, + rpx2px(value) { + return uni.upx2px(value) + } +} + +export default propsConfig \ No newline at end of file diff --git a/src/components/thorui/tui-copy-text/tui-copy-text.vue b/src/components/thorui/tui-copy-text/tui-copy-text.vue new file mode 100644 index 0000000..c9ee108 --- /dev/null +++ b/src/components/thorui/tui-copy-text/tui-copy-text.vue @@ -0,0 +1,279 @@ + + + + + diff --git a/src/components/thorui/tui-countdown-verify/tui-countdown-verify.vue b/src/components/thorui/tui-countdown-verify/tui-countdown-verify.vue new file mode 100644 index 0000000..7162321 --- /dev/null +++ b/src/components/thorui/tui-countdown-verify/tui-countdown-verify.vue @@ -0,0 +1,238 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-countdown/tui-countdown.vue b/src/components/thorui/tui-countdown/tui-countdown.vue new file mode 100644 index 0000000..cfc7fea --- /dev/null +++ b/src/components/thorui/tui-countdown/tui-countdown.vue @@ -0,0 +1,343 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-cropper-app/tui-cropper-app.vue b/src/components/thorui/tui-cropper-app/tui-cropper-app.vue new file mode 100644 index 0000000..feeca44 --- /dev/null +++ b/src/components/thorui/tui-cropper-app/tui-cropper-app.vue @@ -0,0 +1,763 @@ + + + + + diff --git a/src/components/thorui/tui-cropper-app/tui-cropper-app.wxs b/src/components/thorui/tui-cropper-app/tui-cropper-app.wxs new file mode 100644 index 0000000..5f2bf95 --- /dev/null +++ b/src/components/thorui/tui-cropper-app/tui-cropper-app.wxs @@ -0,0 +1,571 @@ +var cropper = { + CUT_START: null, + cutX: 0, //画布x轴起点 + cutY: 0, //画布y轴起点0 + touchRelative: [{ + x: 0, + y: 0 + }], //手指或鼠标和图片中心的相对位置 + flagCutTouch: false, //是否是拖动裁剪框 + hypotenuseLength: 0, //双指触摸时斜边长度 + flagEndTouch: false, //是否结束触摸 + canvasWidth: 0, + canvasHeight: 0, + imgWidth: 0, //图片宽度 + imgHeight: 0, //图片高度 + scale: 1, //图片缩放比 + angle: 0, //图片旋转角度 + imgTop: 0, //图片上边距 + imgLeft: 0, //图片左边距 + //是否限制移动范围(剪裁框只能在图片内,为true不可触摸转动图片) + limitMove: true, + minHeight: 0, + maxHeight: 0, + minWidth: 0, + maxWidth: 0, + windowHeight: 0, + windowWidth: 0, + init: true +} + +function bool(str) { + return str === 'true' || str == true ? true : false +} + +function touchstart(e, ins) { + //var instance = e.instance; + // var state = instance.getState(); + var touch = e.touches || e.changedTouches; + cropper.flagEndTouch = false; + if (touch.length == 1) { + cropper.touchRelative[0] = { + x: touch[0].pageX - cropper.imgLeft, + y: touch[0].pageY - cropper.imgTop + }; + } else { + var width = Math.abs(touch[0].pageX - touch[1].pageX); + var height = Math.abs(touch[0].pageY - touch[1].pageY); + cropper.touchRelative = [{ + x: touch[0].pageX - cropper.imgLeft, + y: touch[0].pageY - cropper.imgTop + }, + { + x: touch[1].pageX - cropper.imgLeft, + y: touch[1].pageY - cropper.imgTop + } + ]; + cropper.hypotenuseLength = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)); + } + +} + +function moveDuring(ins) { + if (!ins) return; + ins.callMethod('moveDuring') +} + +function moveStop(ins) { + if (!ins) return; + ins.callMethod('moveStop') +}; + +function setCutCenter(ins) { + var cutY = (cropper.windowHeight - cropper.canvasHeight) * 0.5; + var cutX = (cropper.windowWidth - cropper.canvasWidth) * 0.5; + //顺序不能变 + cropper.imgTop = cropper.imgTop - cropper.cutY + cutY; + cropper.cutY = cutY; //截取的框上边距 + cropper.imgLeft = cropper.imgLeft - cropper.cutX + cutX; + cropper.cutX = cutX; //截取的框左边距 + styleUpdate(ins) + cutDetectionPosition(ins) + imgTransform(ins) + updateData(ins) +} + +function touchmove(e, ins) { + var touch = e.touches || e.changedTouches; + if (cropper.flagEndTouch) return; + moveDuring(ins); + if (e.touches.length == 1) { + var left = touch[0].pageX - cropper.touchRelative[0].x, + top = touch[0].pageY - cropper.touchRelative[0].y; + cropper.imgLeft = left; + cropper.imgTop = top; + imgTransform(ins); + imgMarginDetectionPosition(ins); + } else { + var res = e.instance.getDataset(); + var minScale = +res.minscale; + var maxScale = +res.maxscale; + var disableRotate = bool(res.disablerotate) + var width = Math.abs(touch[0].pageX - touch[1].pageX), + height = Math.abs(touch[0].pageY - touch[1].pageY), + hypotenuse = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)), + scale = cropper.scale * (hypotenuse / cropper.hypotenuseLength), + current_deg = 0; + scale = scale <= minScale ? minScale : scale; + scale = scale >= maxScale ? maxScale : scale; + cropper.scale = scale; + imgMarginDetectionScale(ins, true); + var touchRelative = [{ + x: touch[0].pageX - cropper.imgLeft, + y: touch[0].pageY - cropper.imgTop + }, + { + x: touch[1].pageX - cropper.imgLeft, + y: touch[1].pageY - cropper.imgTop + } + ]; + if (!disableRotate) { + var first_atan = (180 / Math.PI) * Math.atan2(touchRelative[0].y, touchRelative[0].x); + var first_atan_old = (180 / Math.PI) * Math.atan2(cropper.touchRelative[0].y, cropper.touchRelative[0].x); + var second_atan = (180 / Math.PI) * Math.atan2(touchRelative[1].y, touchRelative[1].x); + var second_atan_old = (180 / Math.PI) * Math.atan2(cropper.touchRelative[1].y, cropper.touchRelative[1].x); + var first_deg = first_atan - first_atan_old, + second_deg = second_atan - second_atan_old; + if (first_deg != 0) { + current_deg = first_deg; + } else if (second_deg != 0) { + current_deg = second_deg; + } + } + cropper.touchRelative = touchRelative; + cropper.hypotenuseLength = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)); + //更新视图 + cropper.angle = cropper.angle + current_deg; + imgTransform(ins); + } +} + +function touchend(e, ins) { + cropper.flagEndTouch = true; + moveStop(ins); + updateData(ins) +} + + +function cutTouchStart(e, ins) { + var touch = e.touches || e.changedTouches; + var currentX = touch[0].pageX; + var currentY = touch[0].pageY; + + /* + * (右下-1 右上-2 左上-3 左下-4) + * left_x [3,4] + * top_y [2,3] + * right_x [1,2] + * bottom_y [1,4] + */ + var left_x1 = cropper.cutX - 30; + var left_x2 = cropper.cutX + 30; + + var top_y1 = cropper.cutY - 30; + var top_y2 = cropper.cutY + 30; + + var right_x1 = cropper.cutX + cropper.canvasWidth - 30; + var right_x2 = cropper.cutX + cropper.canvasWidth + 30; + + var bottom_y1 = cropper.cutY + cropper.canvasHeight - 30; + var bottom_y2 = cropper.cutY + cropper.canvasHeight + 30; + + if (currentX > right_x1 && currentX < right_x2 && currentY > bottom_y1 && currentY < bottom_y2) { + moveDuring(); + cropper.flagCutTouch = true; + cropper.flagEndTouch = true; + cropper.CUT_START = { + width: cropper.canvasWidth, + height: cropper.canvasHeight, + x: currentX, + y: currentY, + corner: 1 + }; + } else if (currentX > right_x1 && currentX < right_x2 && currentY > top_y1 && currentY < top_y2) { + moveDuring(); + cropper.flagCutTouch = true; + cropper.flagEndTouch = true; + cropper.CUT_START = { + width: cropper.canvasWidth, + height: cropper.canvasHeight, + x: currentX, + y: currentY, + cutY: cropper.cutY, + cutX: cropper.cutX, + corner: 2 + }; + } else if (currentX > left_x1 && currentX < left_x2 && currentY > top_y1 && currentY < top_y2) { + moveDuring(); + cropper.flagCutTouch = true; + cropper.flagEndTouch = true; + cropper.CUT_START = { + width: cropper.canvasWidth, + height: cropper.canvasHeight, + cutY: cropper.cutY, + cutX: cropper.cutX, + x: currentX, + y: currentY, + corner: 3 + }; + } else if (currentX > left_x1 && currentX < left_x2 && currentY > bottom_y1 && currentY < bottom_y2) { + moveDuring(); + cropper.flagCutTouch = true; + cropper.flagEndTouch = true; + cropper.CUT_START = { + width: cropper.canvasWidth, + height: cropper.canvasHeight, + cutY: cropper.cutY, + cutX: cropper.cutX, + x: currentX, + y: currentY, + corner: 4 + }; + } +} + +function cutTouchMove(e, ins) { + if (!cropper.CUT_START || cropper.CUT_START === 'null') return; + if (cropper.flagCutTouch) { + var touch = e.touches || e.changedTouches; + var res = e.instance.getDataset(); + var lockRatio = bool(res.lockratio); + var lockWidth = bool(res.lockwidth); + var lockHeight = bool(res.lockheight); + if (lockRatio && (lockWidth || lockHeight)) return; + var width = cropper.canvasWidth, + height = cropper.canvasHeight, + cutY = cropper.cutY, + cutX = cropper.cutX; + + var size_correct = function() { + width = width <= cropper.maxWidth ? (width >= cropper.minWidth ? width : cropper.minWidth) : cropper + .maxWidth; + height = height <= cropper.maxHeight ? (height >= cropper.minHeight ? height : cropper.minHeight) : + cropper.maxHeight; + } + + var size_inspect = function() { + if ((width > cropper.maxWidth || width < cropper.minWidth || height > cropper.maxHeight || height < + cropper.minHeight) && + lockRatio) { + size_correct(); + return false; + } else { + size_correct(); + return true; + } + }; + height = cropper.CUT_START.height + (cropper.CUT_START.corner > 1 && cropper.CUT_START.corner < 4 ? 1 : -1) * ( + cropper.CUT_START.y - touch[0].pageY); + switch (cropper.CUT_START.corner) { + case 1: + width = cropper.CUT_START.width - cropper.CUT_START.x + touch[0].pageX; + if (lockRatio) { + height = width / (cropper.canvasWidth / cropper.canvasHeight); + } + if (!size_inspect()) return; + break; + case 2: + width = cropper.CUT_START.width - cropper.CUT_START.x + touch[0].pageX; + if (lockRatio) { + height = width / (cropper.canvasWidth / cropper.canvasHeight); + } + if (!size_inspect()) return; + cutY = cropper.CUT_START.cutY - (height - cropper.CUT_START.height); + break; + case 3: + width = cropper.CUT_START.width + cropper.CUT_START.x - touch[0].pageX; + if (lockRatio) { + height = width / (cropper.canvasWidth / cropper.canvasHeight); + } + if (!size_inspect()) return; + cutY = cropper.CUT_START.cutY - (height - cropper.CUT_START.height); + cutX = cropper.CUT_START.cutX - (width - cropper.CUT_START.width); + break; + case 4: + width = cropper.CUT_START.width + cropper.CUT_START.x - touch[0].pageX; + if (lockRatio) { + height = width / (cropper.canvasWidth / cropper.canvasHeight); + } + if (!size_inspect()) return; + cutX = cropper.CUT_START.cutX - (width - cropper.CUT_START.width); + break; + default: + break; + } + if (!lockWidth && !lockHeight) { + cropper.canvasWidth = width; + cropper.cutX = cutX; + cropper.canvasHeight = height; + cropper.cutY = cutY; + canvasHeight(ins); + canvasWidth(ins); + } else if (!lockWidth) { + cropper.canvasWidth = width; + cropper.cutX = cutX; + canvasWidth(ins); + } else if (!lockHeight) { + cropper.canvasHeight = height; + cropper.cutY = cutY; + canvasHeight(ins); + } + styleUpdate(ins) + imgMarginDetectionScale(ins); + } +} + +//检测剪裁框位置是否在允许的范围内(屏幕内) +function cutDetectionPosition(ins) { + var windowHeight = cropper.windowHeight, + windowWidth = cropper.windowWidth; + + var cutDetectionPositionTop = function() { + //检测上边距是否在范围内 + if (cropper.cutY < 0) { + cropper.cutY = 0; + } + if (cropper.cutY > windowHeight - cropper.canvasHeight) { + cropper.cutY = windowHeight - cropper.canvasHeight; + } + } + + var cutDetectionPositionLeft = function() { + //检测左边距是否在范围内 + if (cropper.cutX < 0) { + cropper.cutX = 0; + } + if (cropper.cutX > windowWidth - cropper.canvasWidth) { + cropper.cutX = windowWidth - cropper.canvasWidth; + } + } + //裁剪框坐标处理(如果只写一个参数则另一个默认为0,都不写默认居中) + if (cropper.cutY == null && cropper.cutX == null) { + var cutY = (windowHeight - cropper.canvasHeight) * 0.5; + var cutX = (windowWidth - cropper.canvasWidth) * 0.5; + cropper.cutY = cutY; //截取的框上边距 + cropper.cutX = cutX; //截取的框左边距 + } else if (cropper.cutY != null && cropper.cutX != null) { + cutDetectionPositionTop(); + cutDetectionPositionLeft(); + } else if (cropper.cutY != null && cropper.cutX == null) { + cutDetectionPositionTop(); + cropper.cutX = (windowWidth - cropper.canvasWidth) / 2; + } else if (cropper.cutY == null && cropper.cutX != null) { + cutDetectionPositionLeft(); + cropper.cutY = (windowHeight - cropper.canvasHeight) / 2; + } + + styleUpdate(ins) +} + +/** + * 图片边缘检测-缩放 + */ +function imgMarginDetectionScale(ins, delay) { + if (!cropper.limitMove) return; + var scale = cropper.scale; + var imgWidth = cropper.imgWidth; + var imgHeight = cropper.imgHeight; + if ((cropper.angle / 90) % 2) { + imgWidth = cropper.imgHeight; + imgHeight = cropper.imgWidth; + } + if (imgWidth * scale < cropper.canvasWidth) { + scale = cropper.canvasWidth / imgWidth; + } + if (imgHeight * scale < cropper.canvasHeight) { + scale = Math.max(scale, cropper.canvasHeight / imgHeight); + } + imgMarginDetectionPosition(ins, scale, delay); +} +/** + * 图片边缘检测-位置 + */ +function imgMarginDetectionPosition(ins, scale, delay) { + if (!cropper.limitMove) return; + var left = cropper.imgLeft; + var top = cropper.imgTop; + scale = scale || cropper.scale; + var imgWidth = cropper.imgWidth; + var imgHeight = cropper.imgHeight; + if ((cropper.angle / 90) % 2) { + imgWidth = cropper.imgHeight; + imgHeight = cropper.imgWidth; + } + left = cropper.cutX + (imgWidth * scale) / 2 >= left ? left : cropper.cutX + (imgWidth * scale) / 2; + left = cropper.cutX + cropper.canvasWidth - (imgWidth * scale) / 2 <= left ? left : cropper.cutX + cropper + .canvasWidth - + (imgWidth * scale) / 2; + top = cropper.cutY + (imgHeight * scale) / 2 >= top ? top : cropper.cutY + (imgHeight * scale) / 2; + top = cropper.cutY + cropper.canvasHeight - (imgHeight * scale) / 2 <= top ? top : cropper.cutY + cropper + .canvasHeight - + (imgHeight * scale) / 2; + + cropper.imgLeft = left; + cropper.imgTop = top; + cropper.scale = scale; + styleUpdate(ins) + if (!delay || delay === 'null') { + imgTransform(ins); + } +} + + +function cutTouchEnd(e, ins) { + moveStop(ins); + cropper.flagCutTouch = false; + updateData(ins) +} + + +//改变截取框大小 +function computeCutSize(ins) { + if (cropper.canvasWidth > cropper.windowWidth) { + cropper.canvasWidth = cropper.windowWidth; + // canvasWidth(ins) + } else if (cropper.canvasWidth + cropper.cutX > cropper.windowWidth) { + cropper.cutX = cropper.windowWidth - cropper.cutX; + } + if (cropper.canvasHeight > cropper.windowHeight) { + cropper.canvasHeight = cropper.windowHeight; + // canvasHeight(ins) + } else if (cropper.canvasHeight + cropper.cutY > cropper.windowHeight) { + cropper.cutY = cropper.windowHeight - cropper.cutY; + } + // styleUpdate(ins) +} + +function styleUpdate(ins) { + if (!ins) return; + var tcb = ins.selectComponent('.tui-cropper-box') + var tcm = ins.selectComponent('.tui-content-middle') + var tct = ins.selectComponent('.tui-content-top') + var twb = ins.selectComponent('.tui-wxs-bg') + if (!tcb || !tcm || !tct || !twb) return; + tcb.setStyle({ + 'width': cropper.canvasWidth + 'px', + 'height': cropper.canvasHeight + 'px' + }) + tcm.setStyle({ + 'height': cropper.canvasHeight + 'px' + }) + tct.setStyle({ + 'height': cropper.cutY + 'px' + }) + twb.setStyle({ + 'width': cropper.cutX + 'px' + }) + +} + +function imgTransform(ins) { + var owner = ins.selectComponent('.tui-cropper-image') + if (!owner) return + var x = cropper.imgLeft - cropper.imgWidth / 2; + var y = cropper.imgTop - cropper.imgHeight / 2; + owner.setStyle({ + 'transform': 'translate3d(' + x + 'px,' + y + 'px,0) scale(' + cropper.scale + ') rotate(' + cropper + .angle + 'deg)' + }) +} + +function imageReset(ins) { + cropper.scale = 1; + cropper.angle = 0; + imgTransform(ins); +} +//监听截取框宽高变化 +function canvasWidth(ins) { + if (cropper.canvasWidth < cropper.minWidth) { + cropper.canvasWidth = cropper.minWidth; + } + if (!ins) return; + computeCutSize(ins); +} + +function canvasHeight(ins) { + if (cropper.canvasHeight < cropper.minHeight) { + cropper.canvasHeight = cropper.minHeight; + } + if (!ins) return; + computeCutSize(ins); +} + +function updateData(ins) { + if (!ins) return; + ins.callMethod('change', { + cutX: cropper.cutX, + cutY: cropper.cutY, + canvasWidth: cropper.canvasWidth, + canvasHeight: cropper.canvasHeight, + imgWidth: cropper.imgWidth, + imgHeight: cropper.imgHeight, + scale: cropper.scale, + angle: cropper.angle, + imgTop: cropper.imgTop, + imgLeft: cropper.imgLeft + }) +} + +function propsChange(prop, oldProp, ownerInstance, ins) { + if (prop && prop !== 'null') { + var params = prop.split(',') + var type = +params[0] + var dataset = ins.getDataset(); + if (cropper.init || type == 4) { + cropper.maxHeight = +dataset.maxheight; + cropper.minHeight = +dataset.minheight; + cropper.maxWidth = +dataset.maxwidth; + cropper.minWidth = +dataset.minwidth; + cropper.canvasWidth = +dataset.width; + cropper.canvasHeight = +dataset.height; + cropper.imgTop = dataset.windowheight / 2; + cropper.imgLeft = dataset.windowwidth / 2; + cropper.imgWidth = +dataset.imgwidth; + cropper.imgHeight = +dataset.imgheight; + cropper.windowHeight = +dataset.windowheight; + cropper.windowWidth = +dataset.windowwidth; + cropper.init = false + } else if (type == 2 || type == 3) { + cropper.imgWidth = +dataset.imgwidth; + cropper.imgHeight = +dataset.imgheight; + } + cropper.limitMove = bool(dataset.limitmove); + cropper.angle = +dataset.angle; + if (type == 3) { + imgTransform(ownerInstance); + } + switch (type) { + case 1: + setCutCenter(ownerInstance); + //设置裁剪框大小>设置图片尺寸>绘制canvas + computeCutSize(ownerInstance); + //检查裁剪框是否在范围内 + cutDetectionPosition(ownerInstance); + break; + case 2: + setCutCenter(ownerInstance); + break; + case 3: + imgMarginDetectionScale(ownerInstance) + break; + case 4: + imageReset(ownerInstance); + break; + case 5: + setCutCenter(ownerInstance); + break; + default: + break; + } + } +} + +module.exports = { + touchstart: touchstart, + touchmove: touchmove, + touchend: touchend, + cutTouchStart: cutTouchStart, + cutTouchMove: cutTouchMove, + cutTouchEnd: cutTouchEnd, + propsChange: propsChange +} diff --git a/src/components/thorui/tui-cropper-app/tui-virtual-table/debounce.js b/src/components/thorui/tui-cropper-app/tui-virtual-table/debounce.js new file mode 100644 index 0000000..eea27ad --- /dev/null +++ b/src/components/thorui/tui-cropper-app/tui-virtual-table/debounce.js @@ -0,0 +1,147 @@ +function isObject(value) { + let type = typeof value + return !!value && (type == 'object' || type == 'function') +} + +function debounce(func, wait, options) { + let lastArgs, + lastThis, + maxWait, + result, + timerId, + lastCallTime + + let lastInvokeTime = 0 + let leading = false + let maxing = false + let trailing = true + + // Bypass `requestAnimationFrame` by explicitly setting `wait=0`. + const useRAF = false + + if (typeof func !== 'function') { + throw new TypeError('Expected a function') + } + wait = +wait || 0 + if (isObject(options)) { + leading = !!options.leading + maxing = 'maxWait' in options + maxWait = maxing ? Math.max(+options.maxWait || 0, wait) : maxWait + trailing = 'trailing' in options ? !!options.trailing : trailing + } + + function invokeFunc(time) { + const args = lastArgs + const thisArg = lastThis + + lastArgs = lastThis = undefined + lastInvokeTime = time + result = func.apply(thisArg, args) + return result + } + + function startTimer(pendingFunc, wait) { + return setTimeout(pendingFunc, wait) + } + + function cancelTimer(id) { + clearTimeout(id) + } + + function leadingEdge(time) { + // Reset any `maxWait` timer. + lastInvokeTime = time + // Start the timer for the trailing edge. + timerId = startTimer(timerExpired, wait) + // Invoke the leading edge. + return leading ? invokeFunc(time) : result + } + + function remainingWait(time) { + const timeSinceLastCall = time - lastCallTime + const timeSinceLastInvoke = time - lastInvokeTime + const timeWaiting = wait - timeSinceLastCall + + return maxing + ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke) + : timeWaiting + } + + function shouldInvoke(time) { + const timeSinceLastCall = time - lastCallTime + const timeSinceLastInvoke = time - lastInvokeTime + + // Either this is the first call, activity has stopped and we're at the + // trailing edge, the system time has gone backwards and we're treating + // it as the trailing edge, or we've hit the `maxWait` limit. + return (lastCallTime === undefined || (timeSinceLastCall >= wait) || + (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)) + } + + function timerExpired() { + const time = Date.now() + if (shouldInvoke(time)) { + return trailingEdge(time) + } + // Restart the timer. + timerId = startTimer(timerExpired, remainingWait(time)) + } + + function trailingEdge(time) { + timerId = undefined + + // Only invoke if we have `lastArgs` which means `func` has been + // debounced at least once. + if (trailing && lastArgs) { + return invokeFunc(time) + } + lastArgs = lastThis = undefined + return result + } + + function cancel() { + if (timerId !== undefined) { + cancelTimer(timerId) + } + lastInvokeTime = 0 + lastArgs = lastCallTime = lastThis = timerId = undefined + } + + function flush() { + return timerId === undefined ? result : trailingEdge(Date.now()) + } + + function pending() { + return timerId !== undefined + } + + function debounced(...args) { + const time = Date.now() + const isInvoking = shouldInvoke(time) + + lastArgs = args + lastThis = this + lastCallTime = time + + if (isInvoking) { + if (timerId === undefined) { + return leadingEdge(lastCallTime) + } + if (maxing) { + // Handle invocations in a tight loop. + timerId = startTimer(timerExpired, wait) + return invokeFunc(lastCallTime) + } + } + if (timerId === undefined) { + timerId = startTimer(timerExpired, wait) + } + return result + } + debounced.cancel = cancel + debounced.flush = flush + debounced.pending = pending + return debounced +} + +export default debounce diff --git a/src/components/thorui/tui-cropper-app/tui-virtual-table/index.js b/src/components/thorui/tui-cropper-app/tui-virtual-table/index.js new file mode 100644 index 0000000..1d211ad --- /dev/null +++ b/src/components/thorui/tui-cropper-app/tui-virtual-table/index.js @@ -0,0 +1,32 @@ +export const mapVirtualToProps = ({ + items, + itemHeight +}, { + startIndex, + endIndex +}) => { + const visibleItems = endIndex > -1 ? items.slice(startIndex, endIndex + 1) : [] + + // style + const height = items.length * itemHeight + const paddingTop = startIndex * itemHeight + + return { + items: visibleItems, + style: `height: ${height}px; padding-top: ${paddingTop}px; box-sizing: border-box;` + } +} + +export const getVisibleItemBounds = (viewTop, viewHeight, itemCount, itemHeight, itemBuffer) => { + // visible list inside view + const listViewTop = Math.max(0, viewTop) + + // visible item indexes + const startIndex = Math.max(0, Math.floor(listViewTop / itemHeight) - 12) + const endIndex = Math.min(startIndex + Math.ceil(viewHeight / itemHeight) + itemBuffer - 1, itemCount) + + return { + startIndex, + endIndex, + } +} \ No newline at end of file diff --git a/src/components/thorui/tui-cropper-app/tui-virtual-table/tui-virtual-table.vue b/src/components/thorui/tui-cropper-app/tui-virtual-table/tui-virtual-table.vue new file mode 100644 index 0000000..c5a66dd --- /dev/null +++ b/src/components/thorui/tui-cropper-app/tui-virtual-table/tui-virtual-table.vue @@ -0,0 +1,1285 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-cropper/tui-cropper.vue b/src/components/thorui/tui-cropper/tui-cropper.vue new file mode 100644 index 0000000..1e7696e --- /dev/null +++ b/src/components/thorui/tui-cropper/tui-cropper.vue @@ -0,0 +1,517 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-cropper/tui-cropper.wxs b/src/components/thorui/tui-cropper/tui-cropper.wxs new file mode 100644 index 0000000..122e5d9 --- /dev/null +++ b/src/components/thorui/tui-cropper/tui-cropper.wxs @@ -0,0 +1,321 @@ +var cropper = { + cutX: 0, //画布x轴起点 + cutY: 0, //画布y轴起点0 + touchRelative: [{ + x: 0, + y: 0 + }], //手指或鼠标和图片中心的相对位置 + hypotenuseLength: 0, //双指触摸时斜边长度 + flagEndTouch: false, //是否结束触摸 + canvasWidth: 0, + canvasHeight: 0, + imgWidth: 0, //图片宽度 + imgHeight: 0, //图片高度 + scale: 1, //图片缩放比 + angle: 0, //图片旋转角度 + imgTop: 0, //图片上边距 + imgLeft: 0, //图片左边距 + windowHeight: 0, + windowWidth: 0, + init: true +} + +function bool(str) { + return str === 'true' || str == true ? true : false +} + +function touchstart(e, ins) { + var touch = e.touches || e.changedTouches; + cropper.flagEndTouch = false; + if (touch.length == 1) { + cropper.touchRelative[0] = { + x: touch[0].pageX - cropper.imgLeft, + y: touch[0].pageY - cropper.imgTop + }; + } else { + var width = Math.abs(touch[0].pageX - touch[1].pageX); + var height = Math.abs(touch[0].pageY - touch[1].pageY); + cropper.touchRelative = [{ + x: touch[0].pageX - cropper.imgLeft, + y: touch[0].pageY - cropper.imgTop + }, + { + x: touch[1].pageX - cropper.imgLeft, + y: touch[1].pageY - cropper.imgTop + } + ]; + cropper.hypotenuseLength = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)); + } + +} + +function moveDuring(ins) { + if (!ins) return; + ins.callMethod('moveDuring') +} + +function moveStop(ins) { + if (!ins) return; + ins.callMethod('moveStop') +}; + +function setCutCenter(ins) { + var cutY = (cropper.windowHeight - cropper.canvasHeight) * 0.5; + var cutX = (cropper.windowWidth - cropper.canvasWidth) * 0.5; + //顺序不能变 + cropper.imgTop = cropper.imgTop - cropper.cutY + cutY; + cropper.cutY = cutY; //截取的框上边距 + cropper.imgLeft = cropper.imgLeft - cropper.cutX + cutX; + cropper.cutX = cutX; //截取的框左边距 + cutDetectionPosition(ins) + imgTransform(ins) + updateData(ins) +} + +function touchmove(e, ins) { + var touch = e.touches || e.changedTouches; + if (cropper.flagEndTouch) return; + moveDuring(ins); + if (e.touches.length == 1) { + var left = touch[0].pageX - cropper.touchRelative[0].x, + top = touch[0].pageY - cropper.touchRelative[0].y; + cropper.imgLeft = left; + cropper.imgTop = top; + imgTransform(ins); + imgMarginDetectionPosition(ins); + } else { + var res = e.instance.getDataset(); + var minScale = +res.minscale; + var maxScale = +res.maxscale; + var width = Math.abs(touch[0].pageX - touch[1].pageX), + height = Math.abs(touch[0].pageY - touch[1].pageY), + hypotenuse = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)), + scale = cropper.scale * (hypotenuse / cropper.hypotenuseLength), + current_deg = 0; + scale = scale <= minScale ? minScale : scale; + scale = scale >= maxScale ? maxScale : scale; + cropper.scale = scale; + imgMarginDetectionScale(ins, true); + var touchRelative = [{ + x: touch[0].pageX - cropper.imgLeft, + y: touch[0].pageY - cropper.imgTop + }, + { + x: touch[1].pageX - cropper.imgLeft, + y: touch[1].pageY - cropper.imgTop + } + ]; + cropper.touchRelative = touchRelative; + cropper.hypotenuseLength = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)); + //更新视图 + cropper.angle = cropper.angle + current_deg; + imgTransform(ins); + } +} + +function touchend(e, ins) { + cropper.flagEndTouch = true; + moveStop(ins); + updateData(ins) +} + + +//检测剪裁框位置是否在允许的范围内(屏幕内) +function cutDetectionPosition(ins) { + var windowHeight = cropper.windowHeight, + windowWidth = cropper.windowWidth; + + var cutDetectionPositionTop = function() { + //检测上边距是否在范围内 + if (cropper.cutY < 0) { + cropper.cutY = 0; + } + if (cropper.cutY > windowHeight - cropper.canvasHeight) { + cropper.cutY = windowHeight - cropper.canvasHeight; + } + } + + var cutDetectionPositionLeft = function() { + //检测左边距是否在范围内 + if (cropper.cutX < 0) { + cropper.cutX = 0; + } + if (cropper.cutX > windowWidth - cropper.canvasWidth) { + cropper.cutX = windowWidth - cropper.canvasWidth; + } + } + //裁剪框坐标处理(如果只写一个参数则另一个默认为0,都不写默认居中) + if (cropper.cutY == null && cropper.cutX == null) { + var cutY = (windowHeight - cropper.canvasHeight) * 0.5; + var cutX = (windowWidth - cropper.canvasWidth) * 0.5; + cropper.cutY = cutY; //截取的框上边距 + cropper.cutX = cutX; //截取的框左边距 + } else if (cropper.cutY != null && cropper.cutX != null) { + cutDetectionPositionTop(); + cutDetectionPositionLeft(); + } else if (cropper.cutY != null && cropper.cutX == null) { + cutDetectionPositionTop(); + cropper.cutX = (windowWidth - cropper.canvasWidth) / 2; + } else if (cropper.cutY == null && cropper.cutX != null) { + cutDetectionPositionLeft(); + cropper.cutY = (windowHeight - cropper.canvasHeight) / 2; + } +} + +/** + * 图片边缘检测-缩放 + */ +function imgMarginDetectionScale(ins, delay) { + var scale = cropper.scale; + var imgWidth = cropper.imgWidth; + var imgHeight = cropper.imgHeight; + if ((cropper.angle / 90) % 2) { + imgWidth = cropper.imgHeight; + imgHeight = cropper.imgWidth; + } + if (imgWidth * scale < cropper.canvasWidth) { + scale = cropper.canvasWidth / imgWidth; + } + if (imgHeight * scale < cropper.canvasHeight) { + scale = Math.max(scale, cropper.canvasHeight / imgHeight); + } + imgMarginDetectionPosition(ins, scale, delay); +} +/** + * 图片边缘检测-位置 + */ +function imgMarginDetectionPosition(ins, scale, delay) { + var left = cropper.imgLeft; + var top = cropper.imgTop; + scale = scale || cropper.scale; + var imgWidth = cropper.imgWidth; + var imgHeight = cropper.imgHeight; + if ((cropper.angle / 90) % 2) { + imgWidth = cropper.imgHeight; + imgHeight = cropper.imgWidth; + } + left = cropper.cutX + (imgWidth * scale) / 2 >= left ? left : cropper.cutX + (imgWidth * scale) / 2; + left = cropper.cutX + cropper.canvasWidth - (imgWidth * scale) / 2 <= left ? left : cropper.cutX + cropper.canvasWidth - + (imgWidth * scale) / 2; + top = cropper.cutY + (imgHeight * scale) / 2 >= top ? top : cropper.cutY + (imgHeight * scale) / 2; + top = cropper.cutY + cropper.canvasHeight - (imgHeight * scale) / 2 <= top ? top : cropper.cutY + cropper.canvasHeight - + (imgHeight * scale) / 2; + + cropper.imgLeft = left; + cropper.imgTop = top; + cropper.scale = scale; + if (!delay || delay === 'null') { + imgTransform(ins); + } +} + + +//改变截取框大小 +function computeCutSize(ins) { + if (cropper.canvasWidth > cropper.windowWidth) { + cropper.canvasWidth = cropper.windowWidth; + } else if (cropper.canvasWidth + cropper.cutX > cropper.windowWidth) { + cropper.cutX = cropper.windowWidth - cropper.cutX; + } + if (cropper.canvasHeight > cropper.windowHeight) { + cropper.canvasHeight = cropper.windowHeight; + } else if (cropper.canvasHeight + cropper.cutY > cropper.windowHeight) { + cropper.cutY = cropper.windowHeight - cropper.cutY; + } +} + +function imgTransform(ins) { + var owner = ins.selectComponent('.tui-cropper__image') + if (!owner) return + var x = cropper.imgLeft - cropper.imgWidth / 2; + var y = cropper.imgTop - cropper.imgHeight / 2; + owner.setStyle({ + 'transform': 'translate3d(' + x + 'px,' + y + 'px,0) scale(' + cropper.scale + ') rotate(' + cropper.angle + 'deg)' + }) +} + +function imageReset(ins) { + cropper.scale = 1; + cropper.angle = 0; + imgTransform(ins); +} +//监听截取框宽高变化 +function canvasWidth(ins) { + if (!ins) return; + computeCutSize(ins); +} + +function canvasHeight(ins) { + if (!ins) return; + computeCutSize(ins); +} + +function updateData(ins) { + if (!ins) return; + ins.callMethod('change', { + cutX: cropper.cutX, + cutY: cropper.cutY, + imgWidth: cropper.imgWidth, + imgHeight: cropper.imgHeight, + scale: cropper.scale, + angle: cropper.angle, + imgTop: cropper.imgTop, + imgLeft: cropper.imgLeft + }) +} + +function propsChange(prop, oldProp, ownerInstance, ins) { + if (prop && prop !== 'null') { + var params = prop.split(',') + var type = +params[0] + var dataset = ins.getDataset(); + if (cropper.init || type == 4) { + cropper.canvasWidth = +dataset.width; + cropper.canvasHeight = +dataset.height; + cropper.imgTop = dataset.windowheight / 2; + cropper.imgLeft = dataset.windowwidth / 2; + cropper.imgWidth = +dataset.imgwidth; + cropper.imgHeight = +dataset.imgheight; + cropper.windowHeight = +dataset.windowheight; + cropper.windowWidth = +dataset.windowwidth; + cropper.init = false + } else if (type == 2 || type == 3) { + cropper.imgWidth = +dataset.imgwidth; + cropper.imgHeight = +dataset.imgheight; + } + cropper.angle = +dataset.angle; + if (type == 3) { + imgTransform(ownerInstance); + } + switch (type) { + case 1: + setCutCenter(ownerInstance); + //设置裁剪框大小>设置图片尺寸>绘制canvas + computeCutSize(ownerInstance); + //检查裁剪框是否在范围内 + cutDetectionPosition(ownerInstance); + break; + case 2: + setCutCenter(ownerInstance); + break; + case 3: + imgMarginDetectionScale(ownerInstance) + break; + case 4: + imageReset(ownerInstance); + break; + case 5: + setCutCenter(ownerInstance); + break; + default: + break; + } + } +} + +module.exports = { + touchstart: touchstart, + touchmove: touchmove, + touchend: touchend, + propsChange: propsChange +} diff --git a/src/components/thorui/tui-cubic-bezier/tui-cubic-bezier.vue b/src/components/thorui/tui-cubic-bezier/tui-cubic-bezier.vue new file mode 100644 index 0000000..a70fa3b --- /dev/null +++ b/src/components/thorui/tui-cubic-bezier/tui-cubic-bezier.vue @@ -0,0 +1,196 @@ + + + + + diff --git a/src/components/thorui/tui-data-checkbox/tui-data-checkbox.vue b/src/components/thorui/tui-data-checkbox/tui-data-checkbox.vue new file mode 100644 index 0000000..5448127 --- /dev/null +++ b/src/components/thorui/tui-data-checkbox/tui-data-checkbox.vue @@ -0,0 +1,321 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-datetime/tui-datetime.vue b/src/components/thorui/tui-datetime/tui-datetime.vue new file mode 100644 index 0000000..bbafacc --- /dev/null +++ b/src/components/thorui/tui-datetime/tui-datetime.vue @@ -0,0 +1,775 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-dialog/tui-dialog.vue b/src/components/thorui/tui-dialog/tui-dialog.vue new file mode 100644 index 0000000..376c5f0 --- /dev/null +++ b/src/components/thorui/tui-dialog/tui-dialog.vue @@ -0,0 +1,193 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-digital-keyboard/tui-digital-keyboard.vue b/src/components/thorui/tui-digital-keyboard/tui-digital-keyboard.vue new file mode 100644 index 0000000..384a4cc --- /dev/null +++ b/src/components/thorui/tui-digital-keyboard/tui-digital-keyboard.vue @@ -0,0 +1,276 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-digital-roller/tui-digital-roller.vue b/src/components/thorui/tui-digital-roller/tui-digital-roller.vue new file mode 100644 index 0000000..0f1bc6f --- /dev/null +++ b/src/components/thorui/tui-digital-roller/tui-digital-roller.vue @@ -0,0 +1,147 @@ + + + + + diff --git a/src/components/thorui/tui-divide-list/tui-divide-list.vue b/src/components/thorui/tui-divide-list/tui-divide-list.vue new file mode 100644 index 0000000..578210c --- /dev/null +++ b/src/components/thorui/tui-divide-list/tui-divide-list.vue @@ -0,0 +1,198 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-divider/tui-divider.vue b/src/components/thorui/tui-divider/tui-divider.vue new file mode 100644 index 0000000..5b359ec --- /dev/null +++ b/src/components/thorui/tui-divider/tui-divider.vue @@ -0,0 +1,103 @@ + + + + + diff --git a/src/components/thorui/tui-drag/tui-drag.js b/src/components/thorui/tui-drag/tui-drag.js new file mode 100644 index 0000000..174f2de --- /dev/null +++ b/src/components/thorui/tui-drag/tui-drag.js @@ -0,0 +1,158 @@ +// #ifndef APP-PLUS || MP-WEIXIN || H5 + +export default { + data() { + return { + current: -1, + transX: '0px', + transY: '0px', + startTouch: null, + tDragging: false, + sId: null, + preStartKey: null + } + }, + methods: { + isOutRange(x1, y1, x2, y2, x3, y3) { + return x1 < 0 || x1 >= y1 || x2 < 0 || x2 >= y2 || x3 < 0 || x3 >= y3 + }, + sortCore(sKey, eKey) { + var excludeFix = (cKey, type) => { + // fixed 元素位置不会变化, 这里直接用 cKey(sortKey) 获取, 更加快捷 + if (this.list[cKey].fixed) { + var _cKey = type ? --cKey : ++cKey; + return excludeFix(cKey, type); + } + return cKey; + } + let endRealKey = -1; + this.list.forEach((item) => { + if (item.sortKey === eKey) endRealKey = item.realKey; + }); + + return this.list.map((item) => { + let cKey = item.sortKey; + let rKey = item.realKey; + if (sKey < eKey) { + if (cKey > sKey && cKey <= eKey) { + --rKey; + cKey = excludeFix(--cKey, true); + } else if (cKey === sKey) { + rKey = endRealKey; + cKey = eKey; + } + } else if (sKey > eKey) { + if (cKey >= eKey && cKey < sKey) { + ++rKey; + cKey = excludeFix(++cKey, false); + } else if (cKey === sKey) { + rKey = endRealKey; + cKey = eKey; + } + } + if (item.sortKey !== cKey && !item.fixed) { + let columns = Number(this.columns) + item.transX = (cKey % columns) * this.baseData.itemWidth + "px"; + item.transY = Math.floor(cKey / columns) * this.baseData.itemHeight + "px"; + item.sortKey = cKey; + item.realKey = rKey; + } + return item; + }); + }, + emitsEvent(list, type) { + let changeList = [], + itemList = []; + + list.forEach((item) => { + changeList[item.sortKey] = item; + }); + + changeList.forEach((item) => { + itemList.push(item.data); + }); + if (type == "change") { + this.change({ + listData: itemList + }); + } else { + this.sort_end({ + listData: itemList + }); + } + }, + longPress(e) { + if (!this.isEdit) return; + let touch = e.changedTouches && e.changedTouches[0] ? e.changedTouches[0] : this.startTouch; + if (!touch) return; + this.current = Number(e.currentTarget.dataset.index); + // 初始项是固定项则返回 + let item = this.list[this.current]; + if (item && item.fixed) return; + + if (this.tDragging) return; + //pageX + this.transX = this.columns == 1 ? 0 : touch.clientX - (this.baseData.itemWidth / 2 + this.baseData.wrapLeft) + 'px'; + this.transY = touch.clientY - (this.baseData.itemHeight / 2 + this.baseData.wrapTop) + 'px'; + this.sId = touch.identifier; + this.tDragging = true; + }, + touchstart(e) { + if (!this.isEdit) return; + this.startTouch = e.changedTouches[0] || e.touches[0]; + }, + touchmove(e) { + if (!this.isEdit || !this.tDragging) return; + let touch = e.changedTouches[0] || e.touches[0]; + if (!touch || this.sId !== touch.identifier) return; + let transX = this.columns == 1 ? 0 : touch.clientX - (this.baseData.itemWidth / 2 + this.baseData.wrapLeft); + let transY = touch.clientY - (this.baseData.itemHeight / 2 + this.baseData.wrapTop); + + if (touch.clientY > this.baseData.windowHeight - this.baseData.itemHeight) { + this.pageScroll({ + scrollTop: touch.pageY + this.baseData.itemHeight - this.baseData.windowHeight + }) + } else if (touch.clientY < this.baseData.itemHeight) { + this.pageScroll({ + scrollTop: touch.pageY - this.baseData.itemHeight + }) + } + this.transX = transX + 'px' + this.transY = transY + 'px' + + let startKey = this.list[this.current].sortKey; + let curX = Math.round(transX / this.baseData.itemWidth); + let curY = Math.round(transY / this.baseData.itemHeight); + let endKey = curX + Number(this.columns) * curY; + // 目标项是固定项则返回 + var item = this.list[endKey]; + if (item && item.fixed) return; + + if (this.isOutRange(curX, Number(this.columns), curY, this.rows, endKey, this.list.length)) return; + + if (startKey === endKey || startKey === this.preStartKey) return; + this.preStartKey = startKey; + + let list = this.sortCore(startKey, endKey); + this.listChange({ + list: list + }) + this.emitsEvent(list, "change"); + }, + touchend(e) { + if (!this.isEdit || !this.tDragging) return; + this.emitsEvent(this.list, "sortend"); + this.preStartKey = -1; + this.tDragging = false; + this.current = -1; + this.transX = '0px'; + this.transY = '0px'; + } + } +} + +// #endif + +// #ifdef APP-PLUS|| MP-WEIXIN || H5 +export default {} +// #endif diff --git a/src/components/thorui/tui-drag/tui-drag.vue b/src/components/thorui/tui-drag/tui-drag.vue new file mode 100644 index 0000000..2fc8d4d --- /dev/null +++ b/src/components/thorui/tui-drag/tui-drag.vue @@ -0,0 +1,310 @@ + + + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-drag/tui-drag.wxs b/src/components/thorui/tui-drag/tui-drag.wxs new file mode 100644 index 0000000..765e29b --- /dev/null +++ b/src/components/thorui/tui-drag/tui-drag.wxs @@ -0,0 +1,343 @@ +var _st = {} + +function isPC() { + if (typeof navigator !== 'object') return false; + var userAgentInfo = navigator.userAgent; + var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; + var flag = true; + for (var v = 0; v < Agents.length - 1; v++) { + if (userAgentInfo.indexOf(Agents[v]) > 0) { + flag = false; + break; + } + } + return flag; +} +var isH5 = false +if (typeof window === 'object') isH5 = true + +var isOutRange = function(x1, y1, x2, y2, x3, y3) { + return x1 < 0 || x1 >= y1 || x2 < 0 || x2 >= y2 || x3 < 0 || x3 >= y3 +}; +var isEdit = false; + +function bool(str) { + return str === 'true' || str == true ? true : false +} + +var sortCore = function(sKey, eKey, st) { + var _ = st.basedata; + var excludeFix = function(cKey, type) { + // fixed 元素位置不会变化, 这里直接用 cKey(sortKey) 获取, 更加快捷 + if (st.list[cKey].fixed) { + var _cKey = type ? --cKey : ++cKey; + return excludeFix(cKey, type); + } + return cKey; + } + + // 先获取到 endKey 对应的 realKey, 防止下面排序过程中该 realKey 被修改 + var endRealKey = -1; + st.list.forEach(function(item) { + if (item.sortKey === eKey) endRealKey = item.realKey; + }); + + return st.list.map(function(item) { + if (item.fixed) return item; + var cKey = item.sortKey; + var rKey = item.realKey; + + if (sKey < eKey) { + // 正序拖动 + if (cKey > sKey && cKey <= eKey) { + --rKey; + cKey = excludeFix(--cKey, true); + } else if (cKey === sKey) { + rKey = endRealKey; + cKey = eKey; + } + } else if (sKey > eKey) { + // 倒序拖动 + if (cKey >= eKey && cKey < sKey) { + ++rKey + cKey = excludeFix(++cKey, false); + } else if (cKey === sKey) { + rKey = endRealKey; + cKey = eKey; + } + } + + if (item.sortKey !== cKey) { + item.tranX = (cKey % _.columns) * 100 + "%"; + item.tranY = Math.floor(cKey / _.columns) * 100 + "%"; + item.sortKey = cKey; + item.realKey = rKey; + } + return item; + }); +} + +var triggerCustomEvent = function(list, type, ins) { + if (!ins) return; + var _list = [], + listData = []; + + list.forEach(function(item) { + _list[item.sortKey] = item; + }); + + _list.forEach(function(item) { + listData.push(item.data); + }); + + //编译到小程序 funcName作为参数传递导致事件不执行 + if (type == "change") { + ins.callMethod("change", { + listData: listData + }); + } else { + ins.callMethod("sort_end", { + listData: listData + }); + } +} + +var longPress = function(event, ownerInstance) { + var ins = event.instance; + var dataset = ins.getDataset() + isEdit = bool(dataset.edit) + if (!isEdit) return; + var st = ins.getState(); + if (!st.basedata || st.basedata == 'undefined') { + st.basedata = JSON.parse(dataset.basedata) + } + var _ = st.basedata; + var sTouch = null; + if (isH5 && isPC()) { + sTouch = event; + } else { + sTouch = event.changedTouches ? event.changedTouches[0] : st.sTouch; + } + if (!sTouch) return; + + st.cur = +dataset.index; + + st.app = +dataset.app == 1 ? true : false; + + // 初始项是固定项则返回 + var item = st.list[st.cur]; + if (item && item.fixed) return; + + // 如果已经在 drag 中则返回, 防止多指触发 drag 动作, touchstart 事件中有效果 + if (st.dragging) return; + + // #ifdef MP-WEIXIN + ownerInstance.callMethod("drag", { + wxdrag: true + }); + // #endif + + // 计算X,Y轴初始位移, 使 item 中心移动到点击处, 单列时候X轴初始不做位移 + st.tranX = _.columns === 1 ? 0 : sTouch.pageX - (_.itemWidth / 2 + _.wrapLeft); + st.tranY = sTouch.pageY - (_.itemHeight / 2 + _.wrapTop); + st.sId = sTouch.identifier; + + ins.setStyle({ + 'transform': 'translate3d(' + st.tranX + 'px, ' + st.tranY + 'px, 0)' + }); + st.itemsInstance.forEach(function(item, index) { + item.removeClass("tui-drag__transition").removeClass("tui-drag__current"); + item.addClass(index == st.cur ? "tui-drag__current" : "tui-drag__transition"); + }) + + ownerInstance.callMethod("vibrate"); + st.dragging = true; +}; + +var touchStart = function(event, ownerInstance) { + var ins = event.instance; + var state = ins.getState() + state.list = _st.list + state.itemsInstance = _st.itemsInstance + state.basedata = _st.basedata + if (isH5 && isPC()) { + state.sTouch = event; + } else { + state.sTouch = event.changedTouches[0] || event.touches[0] + } + var dataset = ins.getDataset() + isEdit = bool(dataset.edit) + // #ifdef MP-WEIXIN + ownerInstance.callMethod("drag", { + wxdrag: false + }); + // #endif +} + +var touchMove = function(e, ownerInstance, pc_e) { + var ins = null + var st = {} + var mTouch = null; + if (isH5 && isPC()) { + mTouch = e; + st = pc_e.instance.getState() + ins = pc_e.instance; + } else { + mTouch = e.changedTouches[0] || e.touches[0] + ins = e.instance + st = ins.getState() + } + if (e.preventDefault && st.dragging) { + e.preventDefault() + } + if (st.app && st.dragging && event && event.preventDefault) { + event.preventDefault() + } + var _ = st.basedata; + + if (!st.dragging || !isEdit || !mTouch) return; + + // 如果不是同一个触发点则返回 + if (st.sId !== mTouch.identifier) return; + + // 计算X,Y轴位移, 单列时候X轴初始不做位移 + var tranX = _.columns === 1 ? 0 : mTouch.pageX - (_.itemWidth / 2 + _.wrapLeft); + var tranY = mTouch.pageY - (_.itemHeight / 2 + _.wrapTop); + + // 到顶到底自动滑动 + if (mTouch.clientY > _.windowHeight - _.itemHeight - _.realBottomSize) { + // 当前触摸点pageY + item高度 - (屏幕高度 - 底部固定区域高度) + ownerInstance.callMethod("pageScroll", { + scrollTop: mTouch.pageY + _.itemHeight - (_.windowHeight - _.realBottomSize) + }); + } else if (mTouch.clientY < _.itemHeight + _.realTopSize) { + // 当前触摸点pageY - item高度 - 顶部固定区域高度 + ownerInstance.callMethod("pageScroll", { + scrollTop: mTouch.pageY - _.itemHeight - _.realTopSize + }); + } + + // 设置当前激活元素偏移量 + ins.setStyle({ + 'transform': 'translate3d(' + tranX + 'px, ' + tranY + 'px, 0)' + }) + + var startKey = st.list[st.cur].sortKey; + var curX = Math.round(tranX / _.itemWidth); + var curY = Math.round(tranY / _.itemHeight); + var endKey = curX + _.columns * curY; + + // 目标项是固定项则返回 + var item = st.list[endKey]; + if (item && item.fixed) return; + + // X轴或Y轴超出范围则返回 + if (isOutRange(curX, _.columns, curY, _.rows, endKey, st.list.length)) return; + + // 防止拖拽过程中发生乱序问题 + if (startKey === endKey || startKey === st.preStartKey) return; + st.preStartKey = startKey; + + var list = sortCore(startKey, endKey, st); + st.itemsInstance.forEach(function(itemIns, index) { + var item = list[index]; + if (index !== st.cur) { + itemIns.setStyle({ + 'transform': 'translate3d(' + item.tranX + ',' + item.tranY + ', 0)' + }); + } + }); + + ownerInstance.callMethod("vibrate"); + ownerInstance.callMethod("listChange", { + list: list + }); + triggerCustomEvent(list, "change", ownerInstance); +} + +var touchEnd = function(event, ownerInstance, pc_e) { + var ins = null + var st = {} + if (isH5 && isPC()) { + ins = pc_e.instance + st = pc_e.instance.getState() + } else { + st = event.instance.getState() + ins = event.instance + } + + if (!st.dragging || !isEdit) return; + triggerCustomEvent(st.list, "sort_end", ownerInstance); + + ins.addClass("tui-drag__transition"); + ins.setStyle({ + 'transform': 'translate3d(' + st.list[st.cur].tranX + ',' + st.list[st.cur].tranY + ', 0)' + }); + st.itemsInstance.forEach(function(item, index) { + item.removeClass("tui-drag__transition"); + }) + st.preStartKey = -1; + st.dragging = false; + // #ifdef MP-WEIXIN + ownerInstance.callMethod("drag", { + wxdrag: false + }); + // #endif + st.cur = -1; + st.tranX = 0; + st.tranY = 0; +} + +var baseDataObserver = function(newVal, oldVal, ownerInstance, ins) { + // var st = ownerInstance.getState(); + _st.basedata = newVal; +} + +var listObserver = function(newVal, oldVal, ownerInstance, ins) { + // var st = ownerInstance.getState(); + _st.itemsInstance = ownerInstance.selectAllComponents('.tui-drag__item'); + + _st.list = newVal || []; + if (!_st.itemsInstance || _st.itemsInstance.length === 0) return; + _st.list.forEach(function(item, index) { + var itemIns = _st.itemsInstance[index]; + if (item && itemIns) { + itemIns.setStyle({ + 'transform': 'translate3d(' + item.tranX + ',' + item.tranY + ', 0)' + }); + if (item.fixed) itemIns.addClass("tui-drag__fixed"); + } + }) +} +var movable = false; + +function mousedown(e, ins) { + if (!isH5 || !isPC()) return + touchStart(e, ins) + longPress(e, ins) + movable = true + window.onmousemove = function(event) { + if (!isH5 || !isPC() || !movable) return + touchMove(event, ins, e) + } + window.onmouseup = function(event) { + if (!isH5 || !isPC() || !movable) return + touchEnd(event, ins, e) + movable = false + } +} + +function stopMove() { + return true +} + +module.exports = { + longPress: longPress, + touchStart: touchStart, + touchMove: touchMove, + touchEnd: touchEnd, + mousedown: mousedown, + baseDataObserver: baseDataObserver, + listObserver: listObserver, + stopMove: stopMove +} \ No newline at end of file diff --git a/src/components/thorui/tui-drawer/tui-drawer.vue b/src/components/thorui/tui-drawer/tui-drawer.vue new file mode 100644 index 0000000..3fc87a8 --- /dev/null +++ b/src/components/thorui/tui-drawer/tui-drawer.vue @@ -0,0 +1,140 @@ + + + + + diff --git a/src/components/thorui/tui-dropdown-list/tui-dropdown-list.vue b/src/components/thorui/tui-dropdown-list/tui-dropdown-list.vue new file mode 100644 index 0000000..da3665c --- /dev/null +++ b/src/components/thorui/tui-dropdown-list/tui-dropdown-list.vue @@ -0,0 +1,98 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-fab/tui-fab.vue b/src/components/thorui/tui-fab/tui-fab.vue new file mode 100644 index 0000000..4b9deca --- /dev/null +++ b/src/components/thorui/tui-fab/tui-fab.vue @@ -0,0 +1,308 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-footer/tui-footer.vue b/src/components/thorui/tui-footer/tui-footer.vue new file mode 100644 index 0000000..1ad9346 --- /dev/null +++ b/src/components/thorui/tui-footer/tui-footer.vue @@ -0,0 +1,137 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-form-button/tui-form-button.vue b/src/components/thorui/tui-form-button/tui-form-button.vue new file mode 100644 index 0000000..74621f4 --- /dev/null +++ b/src/components/thorui/tui-form-button/tui-form-button.vue @@ -0,0 +1,349 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-form-field/tui-form-field.vue b/src/components/thorui/tui-form-field/tui-form-field.vue new file mode 100644 index 0000000..6d4a20d --- /dev/null +++ b/src/components/thorui/tui-form-field/tui-form-field.vue @@ -0,0 +1,47 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-form-item/tui-form-item.vue b/src/components/thorui/tui-form-item/tui-form-item.vue new file mode 100644 index 0000000..291efeb --- /dev/null +++ b/src/components/thorui/tui-form-item/tui-form-item.vue @@ -0,0 +1,482 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-form/tui-form.vue b/src/components/thorui/tui-form/tui-form.vue new file mode 100644 index 0000000..1122650 --- /dev/null +++ b/src/components/thorui/tui-form/tui-form.vue @@ -0,0 +1,370 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-form/tui-validation.js b/src/components/thorui/tui-form/tui-validation.js new file mode 100644 index 0000000..8828af4 --- /dev/null +++ b/src/components/thorui/tui-form/tui-validation.js @@ -0,0 +1,346 @@ +/** + * 表单验证 + * @author echo. + * @version 2.9.2+ + **/ + +const form = { + //非必填情况下,如果值为空,则不进行校验 + //当出现错误时返回错误消息,否则返回空即为验证通过 + /* + formData:Object 表单对象。{key:value,key:value},key==rules.name + rules: Array [{name:name,rule:[],msg:[],validator:[],{name:name,rule:[],msg:[],validator:[]}] + name:name 属性=> 元素的名称 + rule:字符串数组 ["required","isMobile","isEmail","isCarNo","isIdCard","isAmount","isNum","isChinese","isNotChinese","isEnglish",isEnAndNo","isSpecial","isEmoji",""isDate","isUrl","isSame:key","range:[1,9]","minLength:9","maxLength:Number","isKeyword:key1,key2,key3..."] + msg:数组 []。 与数组 rule 长度相同,对应的错误提示信息 + validator:[{msg:'错误消息',method:Function}],自定义验证方法组,函数约定:(value)=>{ return true or false} + checkAll:是否返回所有错误信息 + */ + validation: function(formData, rules, checkAll = false) { + let result = { + isPass: true, + errorMsg: checkAll ? [] : '' + }; + for (let item of rules) { + let key = item.name; + let rule = item.rule || []; + let validator = item.validator || []; + let msgArr = item.msg; + const ruleLen = rule.length; + const validatorLen = validator.length; + let itemVal = formData[key]; + itemVal = (itemVal === null || itemVal === undefined ? '' : itemVal).toString(); + if (!key || (ruleLen === 0 && validatorLen === 0) || (!~rule.indexOf("required") && + itemVal.length === 0)) { + continue; + } + for (let i = 0, length = rule.length; i < length; i++) { + let ruleItem = rule[i]; + let msg = msgArr[i]; + if (!msg || !ruleItem) continue; + //数据处理 + let value = null; + if (~ruleItem.indexOf(":")) { + let temp = ruleItem.split(":"); + ruleItem = temp[0]; + value = temp[1]; + } + let isError = false; + switch (ruleItem) { + case "required": + isError = form._isNullOrEmpty(formData[key]); + break; + case "isMobile": + isError = !form._isMobile(formData[key]); + break; + case "isEmail": + isError = !form._isEmail(formData[key]); + break; + case "isCarNo": + isError = !form._isCarNo(formData[key]); + break; + case "isIdCard": + isError = !form._isIdCard(formData[key]); + break; + case "isAmount": + isError = !form._isAmount(formData[key]); + break; + case "isNum": + isError = !form._isNum(formData[key]); + break; + case "isChinese": + isError = !form._isChinese(formData[key]); + break; + case "isNotChinese": + isError = !form._isNotChinese(formData[key]); + break; + case "isEnglish": + isError = !form._isEnglish(formData[key]); + break; + case "isEnAndNo": + isError = !form._isEnAndNo(formData[key]); + break; + case "isEnOrNo": + isError = !form._isEnOrNo(formData[key]); + break; + case "isSpecial": + isError = form._isSpecial(formData[key]); + break; + case "isEmoji": + isError = form._isEmoji(formData[key]); + break; + case "isDate": + isError = !form._isDate(formData[key]); + break; + case "isUrl": + isError = !form._isUrl(formData[key]); + break; + case "isSame": + isError = !form._isSame(formData[key], formData[value]); + break; + case "range": + let range = null; + try { + range = JSON.parse(value); + if (range.length <= 1) { + throw new Error("range值传入有误!") + } + } catch (e) { + return "range值传入有误!" + } + isError = !form._isRange(formData[key], range[0], range[1]) + break; + case "minLength": + isError = !form._minLength(formData[key], value) + break; + case "maxLength": + isError = !form._maxLength(formData[key], value) + break; + case "isKeyword": + isError = !form._isKeyword(formData[key], value) + break; + default: + break; + } + + if (isError) { + result.isPass = false; + if (checkAll) { + result.errorMsg.push({ + name: key, + msg: msg + }) + break; + } else { + result.errorMsg = msg; + return result; + } + } + } + if (validator && validator.length > 0) { + for (let model of validator) { + let func = model.method; + if (func && !func(formData[key])) { + result.isPass = false; + if (checkAll) { + const index = result.errorMsg.findIndex(item => item.name === key) + if (index === -1) { + result.errorMsg.push({ + name: key, + msg: model.msg || `${key} error !` + }) + } + break; + } else { + result.errorMsg = model.msg || `${key} error !`; + return result; + } + } + } + + } + } + return result; + }, + //允许填写字符串null或者undefined + _isNullOrEmpty: function(value) { + return (value === null || value === '' || value === undefined) ? true : false; + }, + _isMobile: function(value) { + return /^(?:13\d|14\d|15\d|16\d|17\d|18\d|19\d)\d{5}(\d{3}|\*{3})$/.test(value); + }, + _isEmail: function(value) { + return /^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(value); + }, + _isCarNo: function(value) { + // 新能源车牌 + const xreg = + /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/; + // 旧车牌 + const creg = + /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/; + if (value.length === 7) { + return creg.test(value); + } else if (value.length === 8) { + return xreg.test(value); + } else { + return false; + } + }, + _isIdCard: function(value) { + let idCard = value; + if (idCard.length == 15) { + return this.__isValidityBrithBy15IdCard; + } else if (idCard.length == 18) { + let arrIdCard = idCard.split(""); + if (this.__isValidityBrithBy18IdCard(idCard) && this.__isTrueValidateCodeBy18IdCard(arrIdCard)) { + return true; + } else { + return false; + } + } else { + return false; + } + }, + __isTrueValidateCodeBy18IdCard: function(arrIdCard) { + let sum = 0; + let Wi = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1]; + let ValideCode = [1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2]; + if (arrIdCard[17].toLowerCase() == 'x') { + arrIdCard[17] = 10; + } + for (let i = 0; i < 17; i++) { + sum += Wi[i] * arrIdCard[i]; + } + let valCodePosition = sum % 11; + if (arrIdCard[17] == ValideCode[valCodePosition]) { + return true; + } else { + return false; + } + }, + __isValidityBrithBy18IdCard: function(idCard18) { + let year = idCard18.substring(6, 10); + let month = idCard18.substring(10, 12); + let day = idCard18.substring(12, 14); + let temp_date = new Date(year, parseFloat(month) - 1, parseFloat(day)); + if (temp_date.getFullYear() != parseFloat(year) || temp_date.getMonth() != parseFloat(month) - 1 || + temp_date.getDate() != + parseFloat(day)) { + return false; + } else { + return true; + } + }, + __isValidityBrithBy15IdCard: function(idCard15) { + let year = idCard15.substring(6, 8); + let month = idCard15.substring(8, 10); + let day = idCard15.substring(10, 12); + let temp_date = new Date(year, parseFloat(month) - 1, parseFloat(day)); + + if (temp_date.getFullYear() != parseFloat(year) || temp_date.getMonth() != parseFloat(month) - 1 || + temp_date.getDate() != + parseFloat(day)) { + return false; + } else { + return true; + } + }, + _isAmount: function(value) { + //金额,只允许保留两位小数 + return /^([0-9]*[.]?[0-9])[0-9]{0,1}$/.test(value); + }, + _isNum: function(value) { + //只能为数字 + return /^[0-9]+$/.test(value); + }, + //是否全部为中文 + _isChinese: function(value) { + let reg = /^[\u4e00-\u9fa5]+$/; + return value !== "" && reg.test(value) && !form._isSpecial(value) && !form._isEmoji(value) + }, + //是否不包含中文,可以有特殊字符 + _isNotChinese: function(value) { + let reg = /.*[\u4e00-\u9fa5]+.*$/; + let result = true; + if (reg.test(value)) { + result = false + } + return result + }, + _isEnglish: function(value) { + return /^[a-zA-Z]*$/.test(value) + }, + _isEnAndNo: function(value) { + //8~20位数字和字母组合 + return /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,20}$/.test(value); + }, + _isEnOrNo: function(value) { + //英文或者数字 + let reg = /.*[\u4e00-\u9fa5]+.*$/; + let result = true; + if (reg.test(value) || form._isSpecial(value) || form._isEmoji(value)) { + result = false + } + return result + }, + _isSpecial: function(value) { + //是否包含特殊字符 + let regEn = /[`~!@#$%^&*()_+<>?:"{},.\/;'[\]]/im, + regCn = /[·!#¥(——):;“”‘、,|《。》?、【】[\]]/im; + if (regEn.test(value) || regCn.test(value)) { + return true; + } + return false; + }, + _isEmoji: function(value) { + //是否包含表情 + return /\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F]/g.test(value); + }, + _isDate: function(value) { + //2019-10-12 + const reg = + /^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$/; + return reg.test(value); + }, + _isUrl: function(value) { + return /^((https?|ftp|file):\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})(:[0-9]{1,5})?((\/?)|(\/[\\\w_!~*\\'()\\\.;?:@&=+$,%#-]+)+\/?)$/ + .test(value); + }, + _isSame: function(value1, value2) { + return value1 === value2 + }, + _isRange: function(value, range1, range2) { + if ((!range1 && range1 != 0) && (!range2 && range2 != 0)) { + return true; + } else if (!range1 && range1 != 0) { + return value <= range2 + } else if (!range2 && range2 != 0) { + return value >= range1 + } else { + return value >= range1 && value <= range2 + } + }, + _minLength: function(value, min) { + return value.length >= Number(min) + }, + _maxLength: function(value, max) { + return value.length <= Number(max) + }, + _isKeyword: function(value, keywords) { + //是否包含关键词,敏感词,多个以英文逗号分隔,包含则为false,弹出提示语! + let result = true; + if (!keywords) return result; + let key = keywords.split(','); + for (let i = 0, len = key.length; i < len; i++) { + if (~value.indexOf(key[i])) { + result = false; + break; + } + } + return result; + } +}; +export default { + validation: form.validation +}; \ No newline at end of file diff --git a/src/components/thorui/tui-gallery/tui-gallery.vue b/src/components/thorui/tui-gallery/tui-gallery.vue new file mode 100644 index 0000000..f73c19a --- /dev/null +++ b/src/components/thorui/tui-gallery/tui-gallery.vue @@ -0,0 +1,212 @@ + + + + + diff --git a/src/components/thorui/tui-grade/tui-grade.vue b/src/components/thorui/tui-grade/tui-grade.vue new file mode 100644 index 0000000..e5df3b0 --- /dev/null +++ b/src/components/thorui/tui-grade/tui-grade.vue @@ -0,0 +1,215 @@ + + + + + diff --git a/src/components/thorui/tui-grid-item/tui-grid-item.vue b/src/components/thorui/tui-grid-item/tui-grid-item.vue new file mode 100644 index 0000000..2fdde18 --- /dev/null +++ b/src/components/thorui/tui-grid-item/tui-grid-item.vue @@ -0,0 +1,153 @@ + + + + + diff --git a/src/components/thorui/tui-grid/tui-grid.vue b/src/components/thorui/tui-grid/tui-grid.vue new file mode 100644 index 0000000..f4f189a --- /dev/null +++ b/src/components/thorui/tui-grid/tui-grid.vue @@ -0,0 +1,44 @@ + + + + + diff --git a/src/components/thorui/tui-icon/tui-icon.js b/src/components/thorui/tui-icon/tui-icon.js new file mode 100644 index 0000000..36549d2 --- /dev/null +++ b/src/components/thorui/tui-icon/tui-icon.js @@ -0,0 +1,190 @@ +export default { + "about": "\ue772", + "about-fill": "\ue771", + "add": "\ue770", + "add-fill": "\ue76f", + "addmessage": "\ue76e", + "addressbook": "\ue76d", + "agree": "\ue76c", + "agree-fill": "\ue76b", + "alarm": "\ue76a", + "alarm-fill": "\ue769", + "alipay": "\ue768", + "android": "\ue767", + "applets": "\ue766", + "arrowdown": "\ue765", + "arrowleft": "\ue764", + "arrowright": "\ue763", + "arrowup": "\ue762", + "attestation": "\ue761", + "back": "\ue760", + "bag": "\ue75f", + "bag-fill": "\ue75e", + "balloon": "\ue75d", + "bankcard": "\ue75c", + "bankcard-fill": "\ue75b", + "bottom": "\ue75a", + "calendar": "\ue759", + "camera": "\ue758", + "camera-fill": "\ue757", + "camera-add": "\ue756", + "card": "\ue755", + "card-fill": "\ue754", + "cart": "\ue753", + "cart-fill": "\ue752", + "category": "\ue751", + "category-fill": "\ue750", + "check": "\ue74f", + "circle": "\ue74e", + "circle-fill": "\ue74d", + "circle-selected": "\ue74c", + "clock": "\ue74b", + "clock-fill": "\ue74a", + "close": "\ue749", + "close-fill": "\ue748", + "community": "\ue747", + "community-fill": "\ue746", + "computer": "\ue745", + "computer-fill": "\ue744", + "coupon": "\ue743", + "delete": "\ue742", + "deletekey": "\ue741", + "dingtalk": "\ue740", + "dissatisfied": "\ue73f", + "down": "\ue73e", + "download": "\ue73d", + "edit": "\ue73c", + "ellipsis": "\ue73b", + "enlarge": "\ue73a", + "evaluate": "\ue739", + "exchange": "\ue738", + "explain": "\ue737", + "explain-fill": "\ue736", + "explore": "\ue735", + "explore-fill": "\ue734", + "eye": "\ue733", + "feedback": "\ue732", + "fingerprint": "\ue730", + "friendadd": "\ue72f", + "friendadd-fill": "\ue72e", + "gps": "\ue72d", + "histogram": "\ue72c", + "home": "\ue72b", + "home-fill": "\ue72a", + "house": "\ue729", + "imface": "\ue728", + "imkeyboard": "\ue727", + "immore": "\ue726", + "imvoice": "\ue725", + "ios": "\ue724", + "kefu": "\ue723", + "label": "\ue722", + "label-fill": "\ue721", + "like": "\ue720", + "like-fill": "\ue71f", + "link": "\ue71e", + "listview": "\ue71d", + "loading": "\ue71c", + "location": "\ue71b", + "mail": "\ue71a", + "mail-fill": "\ue719", + "manage": "\ue718", + "manage-fill": "\ue717", + "member": "\ue716", + "member-fill": "\ue715", + "message": "\ue714", + "message-fill": "\ue713", + "mobile": "\ue712", + "moments": "\ue711", + "more": "\ue710", + "more-fill": "\ue70f", + "narrow": "\ue70e", + "news": "\ue70d", + "news-fill": "\ue70c", + "nodata": "\ue70b", + "notice": "\ue699", + "notice-fill": "\ue698", + "offline": "\ue697", + "offline-fill": "\ue696", + "oppose": "\ue695", + "oppose-fill": "\ue694", + "order": "\ue693", + "partake": "\ue692", + "people": "\ue691", + "people-fill": "\ue690", + "pic": "\ue68f", + "pic-fill": "\ue68e", + "picture": "\ue68d", + "pie": "\ue68c", + "plus": "\ue689", + "polygonal": "\ue688", + "position": "\ue686", + "pwd": "\ue685", + "qq": "\ue684", + "qrcode": "\ue682", + "redpacket": "\ue681", + "redpacket-fill": "\ue680", + "reduce": "\ue67f", + "refresh": "\ue67e", + "revoke": "\ue67d", + "satisfied": "\ue67c", + "screen": "\ue67b", + "search": "\ue67a", + "search-2": "\ue679", + "send": "\ue678", + "service": "\ue677", + "service-fill": "\ue676", + "setup": "\ue675", + "setup-fill": "\ue674", + "share": "\ue673", + "share-fill": "\ue672", + "shield": "\ue671", + "shop": "\ue670", + "shop-fill": "\ue66f", + "shut": "\ue66e", + "signin": "\ue66d", + "sina": "\ue66c", + "skin": "\ue66b", + "soso": "\ue669", + "square": "\ue668", + "square-fill": "\ue667", + "square-selected": "\ue666", + "star": "\ue665", + "star-fill": "\ue664", + "strategy": "\ue663", + "sweep": "\ue662", + "time": "\ue661", + "time-fill": "\ue660", + "todown": "\ue65f", + "toleft": "\ue65e", + "tool": "\ue65d", + "top": "\ue65c", + "toright": "\ue65b", + "towardsleft": "\ue65a", + "towardsright": "\ue659", + "towardsright-fill": "\ue658", + "transport": "\ue657", + "transport-fill": "\ue656", + "turningdown": "\ue654", + "turningleft": "\ue653", + "turningright": "\ue652", + "turningup": "\ue651", + "unreceive": "\ue650", + "seen": "\ue7d2", + "unseen": "\ue7d1", + "up": "\ue64e", + "upload": "\ue64c", + "video": "\ue64b", + "voice": "\ue649", + "voice-fill": "\ue648", + "voipphone": "\ue647", + "wallet": "\ue646", + "warning": "\ue645", + "wealth": "\ue644", + "wealth-fill": "\ue643", + "weather": "\ue642", + "wechat": "\ue641", + "wifi": "\ue640", + "play": "\ue7d5", + "suspend": "\ue7d4" +} diff --git a/src/components/thorui/tui-icon/tui-icon.vue b/src/components/thorui/tui-icon/tui-icon.vue new file mode 100644 index 0000000..ba2d472 --- /dev/null +++ b/src/components/thorui/tui-icon/tui-icon.vue @@ -0,0 +1,95 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-image-cropper/tui-image-cropper.vue b/src/components/thorui/tui-image-cropper/tui-image-cropper.vue new file mode 100644 index 0000000..8628a0c --- /dev/null +++ b/src/components/thorui/tui-image-cropper/tui-image-cropper.vue @@ -0,0 +1,1116 @@ + + + + + diff --git a/src/components/thorui/tui-image-group/tui-image-group.vue b/src/components/thorui/tui-image-group/tui-image-group.vue new file mode 100644 index 0000000..65d9716 --- /dev/null +++ b/src/components/thorui/tui-image-group/tui-image-group.vue @@ -0,0 +1,164 @@ + + + + + diff --git a/src/components/thorui/tui-index-list/tui-index-list.vue b/src/components/thorui/tui-index-list/tui-index-list.vue new file mode 100644 index 0000000..bbdf848 --- /dev/null +++ b/src/components/thorui/tui-index-list/tui-index-list.vue @@ -0,0 +1,629 @@ + + + + + diff --git a/src/components/thorui/tui-input/tui-input.vue b/src/components/thorui/tui-input/tui-input.vue new file mode 100644 index 0000000..f5affda --- /dev/null +++ b/src/components/thorui/tui-input/tui-input.vue @@ -0,0 +1,578 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-keyboard-input/tui-keyboard-input.vue b/src/components/thorui/tui-keyboard-input/tui-keyboard-input.vue new file mode 100644 index 0000000..143bc6c --- /dev/null +++ b/src/components/thorui/tui-keyboard-input/tui-keyboard-input.vue @@ -0,0 +1,73 @@ + + + + + diff --git a/src/components/thorui/tui-keyboard/tui-keyboard.vue b/src/components/thorui/tui-keyboard/tui-keyboard.vue new file mode 100644 index 0000000..65bc3d9 --- /dev/null +++ b/src/components/thorui/tui-keyboard/tui-keyboard.vue @@ -0,0 +1,241 @@ + + + + + diff --git a/src/components/thorui/tui-label/tui-label.vue b/src/components/thorui/tui-label/tui-label.vue new file mode 100644 index 0000000..363585f --- /dev/null +++ b/src/components/thorui/tui-label/tui-label.vue @@ -0,0 +1,54 @@ + + + + + diff --git a/src/components/thorui/tui-landscape/tui-landscape.vue b/src/components/thorui/tui-landscape/tui-landscape.vue new file mode 100644 index 0000000..baccfe5 --- /dev/null +++ b/src/components/thorui/tui-landscape/tui-landscape.vue @@ -0,0 +1,158 @@ + + + + + diff --git a/src/components/thorui/tui-lazyload-img/tui-lazyload-img.vue b/src/components/thorui/tui-lazyload-img/tui-lazyload-img.vue new file mode 100644 index 0000000..04bfa14 --- /dev/null +++ b/src/components/thorui/tui-lazyload-img/tui-lazyload-img.vue @@ -0,0 +1,225 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-link/tui-link.vue b/src/components/thorui/tui-link/tui-link.vue new file mode 100644 index 0000000..57c9dab --- /dev/null +++ b/src/components/thorui/tui-link/tui-link.vue @@ -0,0 +1,119 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-list-cell/tui-list-cell.vue b/src/components/thorui/tui-list-cell/tui-list-cell.vue new file mode 100644 index 0000000..5cd30bd --- /dev/null +++ b/src/components/thorui/tui-list-cell/tui-list-cell.vue @@ -0,0 +1,177 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-list-view/tui-list-view.vue b/src/components/thorui/tui-list-view/tui-list-view.vue new file mode 100644 index 0000000..91b16be --- /dev/null +++ b/src/components/thorui/tui-list-view/tui-list-view.vue @@ -0,0 +1,109 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-loading/tui-loading.vue b/src/components/thorui/tui-loading/tui-loading.vue new file mode 100644 index 0000000..8f42318 --- /dev/null +++ b/src/components/thorui/tui-loading/tui-loading.vue @@ -0,0 +1,149 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-loadmore/tui-loadmore.vue b/src/components/thorui/tui-loadmore/tui-loadmore.vue new file mode 100644 index 0000000..0172310 --- /dev/null +++ b/src/components/thorui/tui-loadmore/tui-loadmore.vue @@ -0,0 +1,176 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-lottie/lottie.mp.js b/src/components/thorui/tui-lottie/lottie.mp.js new file mode 100644 index 0000000..298e457 --- /dev/null +++ b/src/components/thorui/tui-lottie/lottie.mp.js @@ -0,0 +1,12 @@ +// #ifdef MP +function evil(fn) {var Fn = Function;return new Fn('return ' + fn)();}function evilExecute(fn) {var Fn = Function;return new Fn('return ' + fn)()();}; +!function(t,e){for(var r in e)t[r]=e[r]}(exports,function(t){var e={};function r(i){if(e[i])return e[i].exports;var s=e[i]={i:i,l:!1,exports:{}};return t[i].call(s.exports,s,s.exports,r),s.l=!0,s.exports}return r.m=t,r.c=e,r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)r.d(i,s,function(e){return t[e]}.bind(null,s));return i},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}([function(t,e,r){"use strict";function i(t,e){for(var r=0;r1?e-1:0),i=1;i0&&void 0!==arguments[0]?arguments[0]:"";if(this.readyState!==t.OPENED)throw new Error("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.");uni.request({data:r,url:a.get(this),method:n.get(this),header:o.get(this),success:function(r){var i=r.data,s=r.statusCode,a=r.header;if("string"!=typeof i&&!(i instanceof ArrayBuffer))try{i=JSON.stringify(i)}catch(t){}if(e.status=s,h.set(e,a),p.call(e,"loadstart"),f.call(e,t.HEADERS_RECEIVED),f.call(e,t.LOADING),e.response=i,i instanceof ArrayBuffer){e.responseText="";for(var n=new Uint8Array(i),o=n.byteLength,l=0;l1?r[1]=1:r[1]<=0&&(r[1]=0),HSVtoRGB(r[0],r[1],r[2])}function addBrightnessToRGB(t,e){var r=RGBtoHSV(255*t[0],255*t[1],255*t[2]);return r[2]+=e,r[2]>1?r[2]=1:r[2]<0&&(r[2]=0),HSVtoRGB(r[0],r[1],r[2])}function addHueToRGB(t,e){var r=RGBtoHSV(255*t[0],255*t[1],255*t[2]);return r[0]+=e/360,r[0]>1?r[0]-=1:r[0]<0&&(r[0]+=1),HSVtoRGB(r[0],r[1],r[2])}var rgbToHex=function(){var t,e,r=[];for(t=0;t<256;t+=1)e=t.toString(16),r[t]=1==e.length?"0"+e:e;return function(t,e,i){return t<0&&(t=0),e<0&&(e=0),i<0&&(i=0),"#"+r[t]+r[e]+r[i]}}();function BaseEvent(){}BaseEvent.prototype={triggerEvent:function(t,e){if(this._cbs[t])for(var r=this._cbs[t].length,i=0;i0||t>-1e-6&&t<0?i(1e4*t)/1e4:t}function I(){var t=this.props;return"matrix("+M(t[0])+","+M(t[1])+","+M(t[4])+","+M(t[5])+","+M(t[12])+","+M(t[13])+")"}return function(){this.reset=s,this.rotate=a,this.rotateX=n,this.rotateY=o,this.rotateZ=h,this.skew=p,this.skewFromAxis=f,this.shear=l,this.scale=m,this.setTransform=c,this.translate=d,this.transform=u,this.applyToPoint=P,this.applyToX=_,this.applyToY=x,this.applyToZ=S,this.applyToPointArray=A,this.applyToTriplePoints=C,this.applyToPointStringified=k,this.toCSS=D,this.to2dCSS=I,this.clone=v,this.cloneFromProps=b,this.equals=g,this.inversePoints=E,this.inversePoint=T,this._t=this.transform,this.isIdentity=y,this._identity=!0,this._identityCalculated=!1,this.props=createTypedArray("float32",16),this.reset()}}(); +/*! + Transformation Matrix v2.0 + (c) Epistemex 2014-2015 + www.epistemex.com + By Ken Fyrstenberg + Contributions by leeoniya. + License: MIT, header required. + */!function(t,e){var r,i=this,s=256,a=6,n="random",o=e.pow(s,a),h=e.pow(2,52),l=2*h,p=s-1;function f(t){var e,r=t.length,i=this,a=0,n=i.i=i.j=0,o=i.S=[];for(r||(t=[r++]);a=l;)t/=2,e/=2,r>>>=1;return(t+r)/e};return P.int32=function(){return 0|b.g(4)},P.quick=function(){return b.g(4)/4294967296},P.double=P,c(d(b.S),t),(u.pass||y||function(t,r,i,s){return s&&(s.S&&m(s,b),t.state=function(){return m(b,{})}),i?(e[n]=t,r):t})(P,v,"global"in u?u.global:this==e,u.state)},c(e.random(),t)}([],BMMath);var BezierFactory=function(){var t={getBezierEasing:function(t,r,i,s,a){var n=a||("bez_"+t+"_"+r+"_"+i+"_"+s).replace(/\./g,"p");if(e[n])return e[n];var o=new c([t,r,i,s]);return e[n]=o,o}},e={};var r=4,i=1e-7,s=10,a=11,n=1/(a-1),o="function"==typeof Float32Array;function h(t,e){return 1-3*e+3*t}function l(t,e){return 3*e-6*t}function p(t){return 3*t}function f(t,e,r){return((h(e,r)*t+l(e,r))*t+p(e))*t}function m(t,e,r){return 3*h(e,r)*t*t+2*l(e,r)*t+p(e)}function c(t){this._p=t,this._mSampleValues=o?new Float32Array(a):new Array(a),this._precomputed=!1,this.get=this.get.bind(this)}return c.prototype={get:function(t){var e=this._p[0],r=this._p[1],i=this._p[2],s=this._p[3];return this._precomputed||this._precompute(),e===r&&i===s?t:0===t?0:1===t?1:f(this._getTForX(t),r,s)},_precompute:function(){var t=this._p[0],e=this._p[1],r=this._p[2],i=this._p[3];this._precomputed=!0,t===e&&r===i||this._calcSampleValues()},_calcSampleValues:function(){for(var t=this._p[0],e=this._p[2],r=0;r=.001?function(t,e,i,s){for(var a=0;a0?r=h:e=h}while(Math.abs(o)>i&&++l-.001&&n<.001}var e=function(t,e,r,i){var s,a,n,o,h,l,p=defaultCurveSegments,f=0,m=[],c=[],d=bezier_length_pool.newElement();for(n=r.length,s=0;sn?-1:1,l=!0;l;)if(i[a]<=n&&i[a+1]>n?(o=(n-i[a])/(i[a+1]-i[a]),l=!1):a+=h,a<0||a>=s-1){if(a===s-1)return r[a];l=!1}return r[a]+(r[a+1]-r[a])*o}var o=createTypedArray("float32",8);return{getSegmentsLength:function(t){var r,i=segments_length_pool.newElement(),s=t.c,a=t.v,n=t.o,o=t.i,h=t._length,l=i.lengths,p=0;for(r=0;r1?1:s,h),f=n(a=a>1?1:a,h),m=t.length,c=1-p,d=1-f,u=c*c*c,y=p*c*c*3,g=p*p*c*3,v=p*p*p,b=c*c*d,P=p*c*d+c*p*d+c*c*f,_=p*p*d+c*p*f+p*c*f,x=p*p*f,S=c*d*d,T=p*d*d+c*f*d+c*d*f,E=p*f*d+c*f*f+p*d*f,C=p*f*f,A=d*d*d,k=f*d*d+d*f*d+d*d*f,D=f*f*d+d*f*f+f*d*f,M=f*f*f;for(l=0;lm?f>c?f-m-c:c-m-f:c>m?c-m-f:m-f-c)>-1e-4&&p<1e-4}}}!function(){for(var t=0,e=["ms","moz","webkit","o"],r=0;r=0;i-=1)if("sh"==t[i].ty){if(t[i].ks.k.i)r(t[i].ks.k);else for(a=t[i].ks.k.length,s=0;sr[0]||!(r[0]>t[0])&&(t[1]>r[1]||!(r[1]>t[1])&&(t[2]>r[2]||!(r[2]>t[2])&&void 0))}var s,a=function(){var t=[4,4,14];function e(t){var e,r,i,s=t.length;for(e=0;e=0;r-=1)if("sh"==t[r].ty){if(t[r].ks.k.i)t[r].ks.k.c=t[r].closed;else for(s=t[r].ks.k.length,i=0;i0&&(p=!1),p){var f=createTag("style");f.setAttribute("f-forigin",a[r].fOrigin),f.setAttribute("f-origin",a[r].origin),f.setAttribute("f-family",a[r].fFamily),f.type="text/css",f.innerHTML="@font-face {font-family: "+a[r].fFamily+"; font-style: normal; src: url('"+a[r].fPath+"');}",e.appendChild(f)}}else if("g"===a[r].fOrigin||1===a[r].origin){for(h=document.querySelectorAll('link[f-forigin="g"], link[f-origin="1"]'),l=0;l=n.t-s){a.h&&(a=n),c=0;break}if(n.t-s>t){c=d;break}d=v||t=v?P.points.length-1:0;for(h=P.points[_].point.length,o=0;o=T&&S=v)r[0]=g[0],r[1]=g[1],r[2]=g[2];else if(t<=b)r[0]=a.s[0],r[1]=a.s[1],r[2]=a.s[2];else{!function(t,e){var r=e[0],i=e[1],s=e[2],a=e[3],n=Math.atan2(2*i*a-2*r*s,1-2*i*i-2*s*s),o=Math.asin(2*r*i+2*s*a),h=Math.atan2(2*r*a-2*i*s,1-2*r*r-2*s*s);t[0]=n/degToRads,t[1]=o/degToRads,t[2]=h/degToRads}(r,function(t,e,r){var i,s,a,n,o,h=[],l=t[0],p=t[1],f=t[2],m=t[3],c=e[0],d=e[1],u=e[2],y=e[3];(s=l*c+p*d+f*u+m*y)<0&&(s=-s,c=-c,d=-d,u=-u,y=-y);1-s>1e-6?(i=Math.acos(s),a=Math.sin(i),n=Math.sin((1-r)*i)/a,o=Math.sin(r*i)/a):(n=1-r,o=r);return h[0]=n*l+o*c,h[1]=n*p+o*d,h[2]=n*f+o*u,h[3]=n*m+o*y,h}(i(a.s),i(g),(t-b)/(v-b)))}else for(d=0;d=v?l=1:t=i&&e>=i||this._caching.lastFrame=e&&(this._caching._lastKeyframeIndex=-1,this._caching.lastIndex=0);var s=this.interpolateValue(e,this._caching);this.pv=s}return this._caching.lastFrame=e,this.pv}function a(t){var r;if("unidimensional"===this.propType)r=t*this.mult,e(this.v-r)>1e-5&&(this.v=r,this._mdf=!0);else for(var i=0,s=this.v.length;i1e-5&&(this.v[i]=r,this._mdf=!0),i+=1}function n(){if(this.elem.globalData.frameId!==this.frameId&&this.effectsSequence.length)if(this.lock)this.setVValue(this.pv);else{this.lock=!0,this._mdf=this._isFirstFrame;var t,e=this.effectsSequence.length,r=this.kf?this.pv:this.data.k;for(t=0;t=this.p.keyframes[this.p.keyframes.length-1].t?(e=this.p.getValueAtTime(this.p.keyframes[this.p.keyframes.length-1].t/i,0),r=this.p.getValueAtTime((this.p.keyframes[this.p.keyframes.length-1].t-.01)/i,0)):(e=this.p.pv,r=this.p.getValueAtTime((this.p._caching.lastFrame+this.p.offsetTime-.01)/i,this.p.offsetTime));else if(this.px&&this.px.keyframes&&this.py.keyframes&&this.px.getValueAtTime&&this.py.getValueAtTime){e=[],r=[];var s=this.px,a=this.py;s._caching.lastFrame+s.offsetTime<=s.keyframes[0].t?(e[0]=s.getValueAtTime((s.keyframes[0].t+.01)/i,0),e[1]=a.getValueAtTime((a.keyframes[0].t+.01)/i,0),r[0]=s.getValueAtTime(s.keyframes[0].t/i,0),r[1]=a.getValueAtTime(a.keyframes[0].t/i,0)):s._caching.lastFrame+s.offsetTime>=s.keyframes[s.keyframes.length-1].t?(e[0]=s.getValueAtTime(s.keyframes[s.keyframes.length-1].t/i,0),e[1]=a.getValueAtTime(a.keyframes[a.keyframes.length-1].t/i,0),r[0]=s.getValueAtTime((s.keyframes[s.keyframes.length-1].t-.01)/i,0),r[1]=a.getValueAtTime((a.keyframes[a.keyframes.length-1].t-.01)/i,0)):(e=[s.pv,a.pv],r[0]=s.getValueAtTime((s._caching.lastFrame+s.offsetTime-.01)/i,s.offsetTime),r[1]=a.getValueAtTime((a._caching.lastFrame+a.offsetTime-.01)/i,a.offsetTime))}this.v.rotate(-Math.atan2(e[1]-r[1],e[0]-r[0]))}this.data.p&&this.data.p.s?this.data.p.z?this.v.translate(this.px.v,this.py.v,-this.pz.v):this.v.translate(this.px.v,this.py.v,0):this.v.translate(this.p.v[0],this.p.v[1],-this.p.v[2])}this.frameId=this.elem.globalData.frameId}},precalculateMatrix:function(){if(!this.a.k&&(this.pre.translate(-this.a.v[0],-this.a.v[1],this.a.v[2]),this.appliedTransformations=1,!this.s.effectsSequence.length)){if(this.pre.scale(this.s.v[0],this.s.v[1],this.s.v[2]),this.appliedTransformations=2,this.sk){if(this.sk.effectsSequence.length||this.sa.effectsSequence.length)return;this.pre.skewFromAxis(-this.sk.v,this.sa.v),this.appliedTransformations=3}if(this.r){if(this.r.effectsSequence.length)return;this.pre.rotate(-this.r.v),this.appliedTransformations=4}else this.rz.effectsSequence.length||this.ry.effectsSequence.length||this.rx.effectsSequence.length||this.or.effectsSequence.length||(this.pre.rotateZ(-this.rz.v).rotateY(this.ry.v).rotateX(this.rx.v).rotateZ(-this.or.v[2]).rotateY(this.or.v[1]).rotateX(this.or.v[0]),this.appliedTransformations=4)}},autoOrient:function(){}},extendPrototype([DynamicPropertyContainer],t),t.prototype.addDynamicProperty=function(t){this._addDynamicProperty(t),this.elem.addDynamicProperty(t),this._isDirty=!0},t.prototype._addDynamicProperty=DynamicPropertyContainer.prototype.addDynamicProperty,{getTransformProperty:function(e,r,i){return new t(e,r,i)}}}();function ShapePath(){this.c=!1,this._length=0,this._maxLength=8,this.v=createSizedArray(this._maxLength),this.o=createSizedArray(this._maxLength),this.i=createSizedArray(this._maxLength)}ShapePath.prototype.setPathData=function(t,e){this.c=t,this.setLength(e);for(var r=0;r=this._maxLength&&this.doubleArrayLength(),r){case"v":a=this.v;break;case"i":a=this.i;break;case"o":a=this.o}(!a[i]||a[i]&&!s)&&(a[i]=point_pool.newElement()),a[i][0]=t,a[i][1]=e},ShapePath.prototype.setTripleAt=function(t,e,r,i,s,a,n,o){this.setXYAt(t,e,"v",n,o),this.setXYAt(r,i,"o",n,o),this.setXYAt(s,a,"i",n,o)},ShapePath.prototype.reverse=function(){var t=new ShapePath;t.setPathData(this.c,this._length);var e=this.v,r=this.o,i=this.i,s=0;this.c&&(t.setTripleAt(e[0][0],e[0][1],i[0][0],i[0][1],r[0][0],r[0][1],0,!1),s=1);var a,n=this._length-1,o=this._length;for(a=s;a=c[c.length-1].t-this.offsetTime)i=c[c.length-1].s?c[c.length-1].s[0]:c[c.length-2].e[0],a=!0;else{for(var d,u,y=m,g=c.length-1,v=!0;v&&(d=c[y],!((u=c[y+1]).t-this.offsetTime>t));)y=u.t-this.offsetTime)p=1;else if(ti&&e>i)||(this._caching.lastIndex=s=1?a.push({s:t-1,e:e-1}):(a.push({s:t,e:1}),a.push({s:0,e:e-1}));var n,o,h=[],l=a.length;for(n=0;ni+r);else p=o.s*s<=i?0:(o.s*s-i)/r,f=o.e*s>=i+r?1:(o.e*s-i)/r,h.push([p,f])}return h.length||h.push([0,0]),h},TrimModifier.prototype.releasePathsData=function(t){var e,r=t.length;for(e=0;e1?1:this.s.v<0?0:this.s.v)+s)>(r=(this.e.v>1?1:this.e.v<0?0:this.e.v)+s)){var a=e;e=r,r=a}e=1e-4*Math.round(1e4*e),r=1e-4*Math.round(1e4*r),this.sValue=e,this.eValue=r}else e=this.sValue,r=this.eValue;var n,o,h,l,p,f,m=this.shapes.length,c=0;if(r===e)for(n=0;n=0;n-=1)if((d=this.shapes[n]).shape._mdf){for((u=d.localShapeCollection).releaseShapes(),2===this.m&&m>1?(g=this.calculateShapeEdges(e,r,d.totalShapeLength,P,c),P+=d.totalShapeLength):g=[[v,b]],h=g.length,o=0;o=1?y.push({s:d.totalShapeLength*(v-1),e:d.totalShapeLength*(b-1)}):(y.push({s:d.totalShapeLength*v,e:d.totalShapeLength}),y.push({s:0,e:d.totalShapeLength*(b-1)}));var _=this.addShapes(d,y[0]);if(y[0].s!==y[0].e){if(y.length>1)if(d.shape.paths.shapes[d.shape.paths._length-1].c){var x=_.pop();this.addPaths(_,u),_=this.addShapes(d,y[1],x)}else this.addPaths(_,u),_=this.addShapes(d,y[1]);this.addPaths(_,u)}}d.shape.paths=u}}},TrimModifier.prototype.addPaths=function(t,e){var r,i=t.length;for(r=0;re.e){r.c=!1;break}e.s<=d&&e.e>=d+n.addedLength?(this.addSegment(m[i].v[s-1],m[i].o[s-1],m[i].i[s],m[i].v[s],r,o,y),y=!1):(l=bez.getNewSegment(m[i].v[s-1],m[i].v[s],m[i].o[s-1],m[i].i[s],(e.s-d)/n.addedLength,(e.e-d)/n.addedLength,h[s-1]),this.addSegmentFromArray(l,r,o,y),y=!1,r.c=!1),d+=n.addedLength,o+=1}if(m[i].c&&h.length){if(n=h[s-1],d<=e.e){var g=h[s-1].addedLength;e.s<=d&&e.e>=d+g?(this.addSegment(m[i].v[s-1],m[i].o[s-1],m[i].i[0],m[i].v[0],r,o,y),y=!1):(l=bez.getNewSegment(m[i].v[s-1],m[i].v[0],m[i].o[s-1],m[i].i[0],(e.s-d)/g,(e.e-d)/g,h[s-1]),this.addSegmentFromArray(l,r,o,y),y=!1,r.c=!1)}else r.c=!1;d+=n.addedLength,o+=1}if(r._length&&(r.setXYAt(r.v[p][0],r.v[p][1],"i",p),r.setXYAt(r.v[r._length-1][0],r.v[r._length-1][1],"o",r._length-1)),d>e.e)break;i0;)r-=1,this._elements.unshift(e[r]),1;this.dynamicProperties.length?this.k=!0:this.getValue(!0)},RepeaterModifier.prototype.resetElements=function(t){var e,r=t.length;for(e=0;e0?Math.floor(l):Math.ceil(l),m=(this.tr.v.props,this.pMatrix.props),c=this.rMatrix.props,d=this.sMatrix.props;this.pMatrix.reset(),this.rMatrix.reset(),this.sMatrix.reset(),this.tMatrix.reset(),this.matrix.reset();var u,y,g=0;if(l>0){for(;gf;)this.applyTransforms(this.pMatrix,this.rMatrix,this.sMatrix,this.tr,1,!0),g-=1;p&&(this.applyTransforms(this.pMatrix,this.rMatrix,this.sMatrix,this.tr,-p,!0),g-=p)}for(i=1===this.data.m?0:this._currentCopies-1,s=1===this.data.m?1:-1,a=this._currentCopies;a;){if(y=(r=(e=this.elemsData[i].it)[e.length-1].transform.mProps.v.props).length,e[e.length-1].transform.mProps._mdf=!0,e[e.length-1].transform.op._mdf=!0,e[e.length-1].transform.op.v=this.so.v+(this.eo.v-this.so.v)*(i/(this._currentCopies-1)),0!==g){for((0!==i&&1===s||i!==this._currentCopies-1&&-1===s)&&this.applyTransforms(this.pMatrix,this.rMatrix,this.sMatrix,this.tr,1,!1),this.matrix.transform(c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7],c[8],c[9],c[10],c[11],c[12],c[13],c[14],c[15]),this.matrix.transform(d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7],d[8],d[9],d[10],d[11],d[12],d[13],d[14],d[15]),this.matrix.transform(m[0],m[1],m[2],m[3],m[4],m[5],m[6],m[7],m[8],m[9],m[10],m[11],m[12],m[13],m[14],m[15]),u=0;u.01)return!1;r+=1}return!0},GradientProperty.prototype.checkCollapsable=function(){if(this.o.length/2!=this.c.length/4)return!1;if(this.data.k.k[0].s)for(var t=0,e=this.data.k.k.length;t=o+ot||!d?(v=(o+ot-l)/h.partialLength,z=c.point[0]+(h.point[0]-c.point[0])*v,B=c.point[1]+(h.point[1]-c.point[1])*v,T.translate(-_[0]*A[s].an/200,-_[1]*V/100),p=!1):d&&(l+=h.partialLength,(f+=1)>=d.length&&(f=0,u[m+=1]?d=u[m].points:P.v.c?(f=0,d=u[m=0].points):(l-=h.partialLength,d=null)),d&&(c=h,y=(h=d[f]).partialLength));O=A[s].an/2-A[s].add,T.translate(-O,0,0)}else O=A[s].an/2-A[s].add,T.translate(-O,0,0),T.translate(-_[0]*A[s].an/200,-_[1]*V/100,0);for(A[s].l/2,I=0;I1,this.kf&&this.addEffect(this.getKeyframeValue.bind(this)),this.kf},TextProperty.prototype.addEffect=function(t){this.effectsSequence.push(t),this.elem.addDynamicProperty(this)},TextProperty.prototype.getValue=function(t){if(this.elem.globalData.frameId!==this.frameId&&this.effectsSequence.length||t){this.currentData.t=this.data.d.k[this.keysIndex].s.t;var e=this.currentData,r=this.keysIndex;if(this.lock)this.setCurrentData(this.currentData);else{this.lock=!0,this._mdf=!1;var i,s=this.effectsSequence.length,a=t||this.data.d.k[this.keysIndex].s;for(i=0;ie));)r+=1;return this.keysIndex!==r&&(this.keysIndex=r),this.data.d.k[this.keysIndex].s},TextProperty.prototype.buildFinalText=function(t){for(var e,r=FontManager.getCombinedCharacterCodes(),i=[],s=0,a=t.length;s=55296&&e<=56319&&(e=t.charCodeAt(s+1))>=56320&&e<=57343?(i.push(t.substr(s,2)),++s):i.push(t.charAt(s)),s+=1;return i},TextProperty.prototype.completeTextData=function(t){t.__complete=!0;var e,r,i,s,a,n,o,h=this.elem.globalData.fontManager,l=this.data,p=[],f=0,m=l.m.g,c=0,d=0,u=0,y=[],g=0,v=0,b=h.getFontByName(t.f),P=0,_=b.fStyle?b.fStyle.split(" "):[],x="normal",S="normal";for(r=_.length,e=0;eD&&" "!==A[e]?(-1===I?r+=1:e=I,C+=t.finalLineHeight||1.2*t.finalSize,A.splice(e,I===e?1:0,"\r"),I=-1,g=0):(g+=P,g+=E);C+=b.ascent*t.finalSize/100,this.canResize&&t.finalSize>this.minimumFontSize&&Mv?g:v,g=-2*E,s="",i=!0,u+=1):s=t.finalText[e],h.chars?(o=h.getCharData(w,b.fStyle,h.getFontByName(t.f).fFamily),P=i?0:o.w*t.finalSize/100):P=h.measureText(s,t.f,t.finalSize)," "===w?F+=P+E:(g+=P+E+F,F=0),p.push({l:P,an:P,add:c,n:i,anIndexes:[],val:s,line:u,animatorJustifyOffset:0}),2==m){if(c+=P,""===s||" "===s||e===r-1){for(""!==s&&" "!==s||(c-=P);d<=e;)p[d].an=c,p[d].ind=f,p[d].extra=P,d+=1;f+=1,c=0}}else if(3==m){if(c+=P,""===s||e===r-1){for(""===s&&(c-=P);d<=e;)p[d].an=c,p[d].ind=f,p[d].extra=P,d+=1;c=0,f+=1}}else p[f].ind=f,p[f].extra=0,f+=1;if(t.l=p,v=g>v?g:v,y.push(g),t.sz)t.boxWidth=t.sz[0],t.justifyOffset=0;else switch(t.boxWidth=v,t.j){case 1:t.justifyOffset=-t.boxWidth;break;case 2:t.justifyOffset=-t.boxWidth/2;break;default:t.justifyOffset=0}t.lineWidths=y;var V,R,L=l.a;n=L.length;var O,z,B=[];for(a=0;a=o?1:0:t(0,e(.5/(o-n)+(i-n)/(o-n),1)));else if(3==h)a=s(a=o===n?i>=o?0:1:1-t(0,e(.5/(o-n)+(i-n)/(o-n),1)));else if(4==h)o===n?a=0:(a=t(0,e(.5/(o-n)+(i-n)/(o-n),1)))<.5?a*=2:a=1-2*(a-.5),a=s(a);else if(5==h){if(o===n)a=0;else{var l=o-n,p=-l/2+(i=e(t(0,i+.5-n),o-n)),f=l/2;a=Math.sqrt(1-p*p/(f*f))}a=s(a)}else 6==h?(o===n?a=0:(i=e(t(0,i+.5-n),o-n),a=(1+Math.cos(Math.PI+2*Math.PI*i/(o-n)))/2),a=s(a)):(i>=r(n)&&(a=i-n<0?1-(n-i):t(0,e(o-i,1))),a=s(a));return a*this.a.v},getValue:function(t){this.iterateDynamicProperties(),this._mdf=t||this._mdf,this._currentTextLength=this.elem.textProperty.currentData.l.length||0,t&&2===this.data.r&&(this.e.v=this._currentTextLength);var e=2===this.data.r?1:100/this.data.totalChars,r=this.o.v/e,i=this.s.v/e+r,s=this.e.v/e+r;if(i>s){var a=i;i=s,s=a}this.finalS=i,this.finalE=s}},extendPrototype([DynamicPropertyContainer],i),{getTextSelectorProp:function(t,e,r){return new i(t,e,r)}}}(),pool_factory=function(t,e,r,i){var s=0,a=t,n=createSizedArray(a);function o(){return s?n[s-=1]:e()}return{newElement:o,release:function(t){s===a&&(n=pooling.double(n),a*=2),r&&r(t),n[s]=t,s+=1}}},pooling={double:function(t){return t.concat(createSizedArray(t.length))}},point_pool=pool_factory(8,function(){return createTypedArray("float32",2)}),shape_pool=(factory=pool_factory(4,function(){return new ShapePath},function(t){var e,r=t._length;for(e=0;e0&&(this.maskElement.setAttribute("id",y),this.element.maskedElement.setAttribute(v,"url("+locationHref+"#"+y+")"),s.appendChild(this.maskElement)),this.viewData.length&&this.element.addRenderableComponent(this)}function HierarchyElement(){}function FrameElement(){}function TransformElement(){}function RenderableElement(){}function RenderableDOMElement(){}function ProcessedElement(t,e){this.elem=t,this.pos=e}function SVGShapeData(t,e,r){this.caches=[],this.styles=[],this.transformers=t,this.lStr="",this.sh=r,this.lvl=e,this._isAnimated=!!r.k;for(var i=0,s=t.length;i=0;e--)this.elements[e]||(r=this.layers[e]).ip-r.st<=t-this.layers[e].st&&r.op-r.st>t-this.layers[e].st&&this.buildItem(e),this.completeLayers=!!this.elements[e]&&this.completeLayers;this.checkPendingElements()},BaseRenderer.prototype.createItem=function(t){switch(t.ty){case 2:return this.createImage(t);case 0:return this.createComp(t);case 1:return this.createSolid(t);case 3:return this.createNull(t);case 4:return this.createShape(t);case 5:return this.createText(t);case 13:return this.createCamera(t)}return this.createNull(t)},BaseRenderer.prototype.createCamera=function(){throw new Error("You're using a 3d camera. Try the html renderer.")},BaseRenderer.prototype.buildAllItems=function(){var t,e=this.layers.length;for(t=0;t=0;e--)(this.completeLayers||this.elements[e])&&this.elements[e].prepareFrame(t-this.layers[e].st);if(this.globalData._mdf)for(e=0;er&&"meet"===a||ir&&"slice"===a)?(t-this.transformCanvas.w*(e/this.transformCanvas.h))/2*this.renderConfig.dpr:"xMax"===o&&(ir&&"slice"===a)?(t-this.transformCanvas.w*(e/this.transformCanvas.h))*this.renderConfig.dpr:0,this.transformCanvas.ty="YMid"===h&&(i>r&&"meet"===a||ir&&"meet"===a||i=0;t-=1)this.elements[t]&&this.elements[t].destroy();this.elements.length=0,this.globalData.canvasContext=null,this.animationItem.container=null,this.destroyed=!0},CanvasRenderer.prototype.renderFrame=function(t,e){if((this.renderedFrame!==t||!0!==this.renderConfig.clearCanvas||e)&&!this.destroyed&&-1!==t){this.renderedFrame=t,this.globalData.frameNum=t-this.animationItem._isFirstFrame,this.globalData.frameId+=1,this.globalData._mdf=!this.renderConfig.clearCanvas||e,this.globalData.projectInterface.currentFrame=t;var r,i=this.layers.length;for(this.completeLayers||this.checkLayers(t),r=0;r=0;r-=1)(this.completeLayers||this.elements[r])&&this.elements[r].renderFrame();!0!==this.renderConfig.clearCanvas&&this.restore()}}},CanvasRenderer.prototype.buildItem=function(t){var e=this.elements;if(!e[t]&&99!=this.layers[t].ty){var r=this.createItem(this.layers[t],this,this.globalData);e[t]=r,r.initExpressions()}},CanvasRenderer.prototype.checkPendingElements=function(){for(;this.pendingElements.length;){this.pendingElements.pop().checkParenting()}},CanvasRenderer.prototype.hide=function(){this.animationItem.container.style.display="none"},CanvasRenderer.prototype.show=function(){this.animationItem.container.style.display="block"},MaskElement.prototype.getMaskProperty=function(t){return this.viewData[t].prop},MaskElement.prototype.renderFrame=function(t){var e,r=this.element.finalTransform.mat,i=this.masksProperties.length;for(e=0;e1&&(a+=" C"+e.o[i-1][0]+","+e.o[i-1][1]+" "+e.i[0][0]+","+e.i[0][1]+" "+e.v[0][0]+","+e.v[0][1]),r.lastPath!==a){var n="";r.elem&&(e.c&&(n=t.inv?this.solidPath+a:a),r.elem.setAttribute("d",n)),r.lastPath=a}},MaskElement.prototype.destroy=function(){this.element=null,this.globalData=null,this.maskElement=null,this.data=null,this.masksProperties=null},HierarchyElement.prototype={initHierarchy:function(){this.hierarchy=[],this._isParent=!1,this.checkParenting()},setHierarchy:function(t){this.hierarchy=t},setAsParent:function(){this._isParent=!0},checkParenting:function(){void 0!==this.data.parent&&this.comp.buildElementParenting(this,this.data.parent,[])}},FrameElement.prototype={initFrame:function(){this._isFirstFrame=!1,this.dynamicProperties=[],this._mdf=!1},prepareProperties:function(t,e){var r,i=this.dynamicProperties.length;for(r=0;rt?!0!==this.isInRange&&(this.globalData._mdf=!0,this._mdf=!0,this.isInRange=!0,this.show()):!1!==this.isInRange&&(this.globalData._mdf=!0,this.isInRange=!1,this.hide())},renderRenderable:function(){var t,e=this.renderableComponents.length;for(t=0;t=0;i-=1)r=t.transforms[i].transform.mProps.v.props,t.finalTransform.transform(r[0],r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8],r[9],r[10],r[11],r[12],r[13],r[14],r[15]);t._mdf=a},processSequences:function(t){var e,r=this.sequenceList.length;for(e=0;e=0;t-=1)this.shapeModifiers[t].processShapes(this._isFirstFrame)}},lcEnum:{1:"butt",2:"round",3:"square"},ljEnum:{1:"miter",2:"round",3:"bevel"},searchProcessedElement:function(t){for(var e=this.processedElements,r=0,i=e.length;r=0;r-=1)(this.completeLayers||this.elements[r])&&(this.elements[r].prepareFrame(this.renderedFrame-this.layers[r].st),this.elements[r]._mdf&&(this._mdf=!0))}},ICompElement.prototype.renderInnerContent=function(){var t,e=this.layers.length;for(t=0;t1&&o&&this.setShapesAsAnimated(n)}},SVGShapeElement.prototype.setShapesAsAnimated=function(t){var e,r=t.length;for(e=0;e=0;o-=1){if((m=this.searchProcessedElement(t[o]))?e[o]=r[m-1]:t[o]._render=n,"fl"==t[o].ty||"st"==t[o].ty||"gf"==t[o].ty||"gs"==t[o].ty)m?e[o].style.closed=!1:e[o]=this.createStyleElement(t[o],s),t[o]._render&&i.appendChild(e[o].style.pElem),u.push(e[o].style);else if("gr"==t[o].ty){if(m)for(l=e[o].it.length,h=0;ho&&"xMidYMid slice"===h||n=0;t-=1)(this.completeLayers||this.elements[t])&&this.elements[t].renderFrame()},CVCompElement.prototype.destroy=function(){var t;for(t=this.layers.length-1;t>=0;t-=1)this.elements[t]&&this.elements[t].destroy();this.layers=null,this.elements=null},CVMaskElement.prototype.renderFrame=function(){if(this.hasMasks){var t,e,r,i,s=this.element.finalTransform.mat,a=this.element.canvasContext,n=this.masksProperties.length;for(a.beginPath(),t=0;t=0;a-=1){if((h=this.searchProcessedElement(t[a]))?e[a]=r[h-1]:t[a]._shouldRender=i,"fl"==t[a].ty||"st"==t[a].ty||"gf"==t[a].ty||"gs"==t[a].ty)h?e[a].style.closed=!1:e[a]=this.createStyleElement(t[a],d),m.push(e[a].style);else if("gr"==t[a].ty){if(h)for(o=e[a].it.length,n=0;n=0;s-=1)"tr"==e[s].ty?(a=r[s].transform,this.renderShapeTransform(t,a)):"sh"==e[s].ty||"el"==e[s].ty||"rc"==e[s].ty||"sr"==e[s].ty?this.renderPath(e[s],r[s]):"fl"==e[s].ty?this.renderFill(e[s],r[s],a):"st"==e[s].ty?this.renderStroke(e[s],r[s],a):"gf"==e[s].ty||"gs"==e[s].ty?this.renderGradientFill(e[s],r[s],a):"gr"==e[s].ty?this.renderShape(a,e[s].it,r[s].it):e[s].ty;i&&this.drawLayer()},CVShapeElement.prototype.renderStyledShape=function(t,e){if(this._isFirstFrame||e._mdf||t.transforms._mdf){var r,i,s,a=t.trNodes,n=e.paths,o=n._length;a.length=0;var h=t.transforms.finalTransform;for(s=0;s=1?.99:e.h.v<=-1?-.99:e.h.v),p=Math.cos(h+e.a.v)*l+a[0],f=Math.sin(h+e.a.v)*l+a[1],m=s.createRadialGradient(p,f,0,a[0],a[1],o);var c,d=t.g.p,u=e.g.c,y=1;for(c=0;c=0;r-=1)e[r].animation.destroy(t)},t.freeze=function(){n=!0},t.unfreeze=function(){n=!1,d()},t.getRegisteredAnimations=function(){var t,r=e.length,i=[];for(t=0;tthis.animationData.op&&(this.animationData.op=t.op,this.totalFrames=Math.floor(t.op-this.animationData.ip));var e,r,i=this.animationData.layers,s=i.length,a=t.layers,n=a.length;for(r=0;rthis.timeCompleted&&(this.currentFrame=this.timeCompleted),this.trigger("enterFrame"),this.renderFrame()},AnimationItem.prototype.renderFrame=function(){!1!==this.isLoaded&&this.renderer.renderFrame(this.currentFrame+this.firstFrame)},AnimationItem.prototype.play=function(t){t&&this.name!=t||!0===this.isPaused&&(this.isPaused=!1,this._idle&&(this._idle=!1,this.trigger("_active")))},AnimationItem.prototype.pause=function(t){t&&this.name!=t||!1===this.isPaused&&(this.isPaused=!0,this._idle=!0,this.trigger("_idle"))},AnimationItem.prototype.togglePause=function(t){t&&this.name!=t||(!0===this.isPaused?this.play():this.pause())},AnimationItem.prototype.stop=function(t){t&&this.name!=t||(this.pause(),this.playCount=0,this._completedLoop=!1,this.setCurrentRawFrameValue(0))},AnimationItem.prototype.goToAndStop=function(t,e,r){r&&this.name!=r||(e?this.setCurrentRawFrameValue(t):this.setCurrentRawFrameValue(t*this.frameModifier),this.pause())},AnimationItem.prototype.goToAndPlay=function(t,e,r){this.goToAndStop(t,e,r),this.play()},AnimationItem.prototype.advanceTime=function(t){if(!0!==this.isPaused&&!1!==this.isLoaded){var e=this.currentRawFrame+t*this.frameModifier,r=!1;e>=this.totalFrames-1&&this.frameModifier>0?this.loop&&this.playCount!==this.loop?e>=this.totalFrames?(this.playCount+=1,this.checkSegments(e%this.totalFrames)||(this.setCurrentRawFrameValue(e%this.totalFrames),this._completedLoop=!0,this.trigger("loopComplete"))):this.setCurrentRawFrameValue(e):this.checkSegments(e>this.totalFrames?e%this.totalFrames:0)||(r=!0,e=this.totalFrames-1):e<0?this.checkSegments(e%this.totalFrames)||(!this.loop||this.playCount--<=0&&!0!==this.loop?(r=!0,e=0):(this.setCurrentRawFrameValue(this.totalFrames+e%this.totalFrames),this._completedLoop?this.trigger("loopComplete"):this._completedLoop=!0)):this.setCurrentRawFrameValue(e),r&&(this.setCurrentRawFrameValue(e),this.pause(),this.trigger("complete"))}},AnimationItem.prototype.adjustSegment=function(t,e){this.playCount=0,t[1]0&&(this.playSpeed<0?this.setSpeed(-this.playSpeed):this.setDirection(-1)),this.timeCompleted=this.totalFrames=t[0]-t[1],this.firstFrame=t[1],this.setCurrentRawFrameValue(this.totalFrames-.001-e)):t[1]>t[0]&&(this.frameModifier<0&&(this.playSpeed<0?this.setSpeed(-this.playSpeed):this.setDirection(1)),this.timeCompleted=this.totalFrames=t[1]-t[0],this.firstFrame=t[0],this.setCurrentRawFrameValue(.001+e)),this.trigger("segmentStart")},AnimationItem.prototype.setSegment=function(t,e){var r=-1;this.isPaused&&(this.currentRawFrame+this.firstFramee&&(r=e-t)),this.firstFrame=t,this.timeCompleted=this.totalFrames=e-t,-1!==r&&this.goToAndStop(r,!0)},AnimationItem.prototype.playSegments=function(t,e){if(e&&(this.segments.length=0),"object"===_typeof(t[0])){var r,i=t.length;for(r=0;rr){var i=r;r=e,e=i}return Math.min(Math.max(t,e),r)}function radiansToDegrees(t){return t/degToRads}var radians_to_degrees=radiansToDegrees;function degreesToRadians(t){return t*degToRads}var degrees_to_radians=radiansToDegrees,helperLengthArray=[0,0,0,0,0,0];function length(t,e){if("number"==typeof t||t instanceof Number)return e=e||0,Math.abs(t-e);e||(e=helperLengthArray);var r,i=Math.min(t.length,e.length),s=0;for(r=0;r.5?l/(2-n-o):l/(n+o),n){case i:e=(s-a)/l+(s1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}function hslToRgb(t){var e,r,i,s=t[0],a=t[1],n=t[2];if(0===a)e=r=i=n;else{var o=n<.5?n*(1+a):n+a-n*a,h=2*n-o;e=hue2rgb(h,o,s+1/3),r=hue2rgb(h,o,s),i=hue2rgb(h,o,s-1/3)}return[e,r,i,t[3]]}function linear(t,e,r,i,s){if(void 0!==i&&void 0!==s||(i=e,s=r,e=0,r=1),r=r)return s;var n=r===e?0:(t-e)/(r-e);if(!i.length)return i+(s-i)*n;var o,h=i.length,l=createTypedArray("float32",h);for(o=0;o1){for(i=0;i1?1:e<0?0:e);if($bm_isInstanceOfArray(s)){var o,h=s.length,l=createTypedArray("float32",h);for(o=0;odata.k[e].t&&tdata.k[e+1].t-t?(r=e+2,i=data.k[e+1].t):(r=e+1,i=data.k[e].t);break}}-1===r&&(r=e+1,i=data.k[e].t)}else r=0,i=0;var a={};return a.index=r,a.time=i/elem.comp.globalData.frameRate,a}function key(t){var e,r,i;if(!data.k.length||"number"==typeof data.k[0])throw new Error("The property has no keyframe at index "+t);t-=1,e={time:data.k[t].t/elem.comp.globalData.frameRate,value:[]};var s=data.k[t].hasOwnProperty("s")?data.k[t].s:data.k[t-1].e;for(i=s.length,r=0;rl.length-1)&&(e=l.length-1),i=p-(s=l[l.length-1-e].t)),"pingpong"===t){if(Math.floor((h-s)/i)%2!=0)return this.getValueAtTime((i-(h-s)%i+s)/this.comp.globalData.frameRate,0)}else{if("offset"===t){var f=this.getValueAtTime(s/this.comp.globalData.frameRate,0),m=this.getValueAtTime(p/this.comp.globalData.frameRate,0),c=this.getValueAtTime(((h-s)%i+s)/this.comp.globalData.frameRate,0),d=Math.floor((h-s)/i);if(this.pv.length){for(n=(o=new Array(f.length)).length,a=0;a=p)return this.pv;if(r?s=p+(i=e?Math.abs(elem.comp.globalData.frameRate*e):Math.max(0,this.elem.data.op-p)):((!e||e>l.length-1)&&(e=l.length-1),i=(s=l[e].t)-p),"pingpong"===t){if(Math.floor((p-h)/i)%2==0)return this.getValueAtTime(((p-h)%i+p)/this.comp.globalData.frameRate,0)}else{if("offset"===t){var f=this.getValueAtTime(p/this.comp.globalData.frameRate,0),m=this.getValueAtTime(s/this.comp.globalData.frameRate,0),c=this.getValueAtTime((i-(p-h)%i+p)/this.comp.globalData.frameRate,0),d=Math.floor((p-h)/i)+1;if(this.pv.length){for(n=(o=new Array(f.length)).length,a=0;a1?(s+t-a)/(e-1):1,o=0,h=0;for(r=this.pv.length?createTypedArray("float32",this.pv.length):0;on){var p=o,f=r.c&&o===h-1?0:o+1,m=(n-l)/a[o].addedLength;i=bez.getPointInSegment(r.v[p],r.v[f],r.o[p],r.i[f],m,a[o]);break}l+=a[o].addedLength,o+=1}return i||(i=r.c?[r.v[0][0],r.v[0][1]]:[r.v[r._length-1][0],r.v[r._length-1][1]]),i},vectorOnPath:function(t,e,r){t=1==t?this.v.c?0:.999:t;var i=this.pointOnPath(t,e),s=this.pointOnPath(t+.001,e),a=s[0]-i[0],n=s[1]-i[1],o=Math.sqrt(Math.pow(a,2)+Math.pow(n,2));return 0===o?[0,0]:"tangent"===r?[a/o,n/o]:[-n/o,a/o]},tangentOnPath:function(t,e){return this.vectorOnPath(t,e,"tangent")},normalOnPath:function(t,e){return this.vectorOnPath(t,e,"normal")},setGroupProperty:expressionHelpers.setGroupProperty,getValueAtTime:expressionHelpers.getStaticValueAtTime},extendPrototype([o],a),extendPrototype([o],n),n.prototype.getValueAtTime=function(t){return this._cachingAtTime||(this._cachingAtTime={shapeValue:shape_pool.clone(this.pv),lastIndex:0,lastTime:initialDefaultFrame}),t*=this.elem.globalData.frameRate,(t-=this.offsetTime)!==this._cachingAtTime.lastTime&&(this._cachingAtTime.lastIndex=this._cachingAtTime.lastTime1&&(defaultCurveSegments=t);roundValues(!(defaultCurveSegments>=50))}function inBrowser(){return void 0!==navigator}function installPlugin(t,e){"expressions"===t&&(expressionsPlugin=e)}function getFactory(t){switch(t){case"propertyFactory":return PropertyFactory;case"shapePropertyFactory":return ShapePropertyFactory;case"matrix":return Matrix}}function checkReady(){"complete"===document.readyState&&(clearInterval(readyStateCheckInterval),searchAnimations())}function getQueryVariable(t){for(var e=queryString.split("&"),r=0;r>>=1;return(t+r)/e};return n.int32=function(){return 0|a.g(4)},n.quick=function(){return a.g(4)/4294967296},n.double=n,P(E(a.S),o),(e.pass||r||function(t,e,r,i){return i&&(i.S&&b(i,a),t.state=function(){return b(a,{})}),r?(h[c]=t,e):t})(n,s,"global"in e?e.global:this==h,e.state)},P(h.random(),o)}([],BMMath);var BezierFactory=function(){var t={getBezierEasing:function(t,e,r,i,s){var a=s||("bez_"+t+"_"+e+"_"+r+"_"+i).replace(/\./g,"p");if(o[a])return o[a];var n=new h([t,e,r,i]);return o[a]=n}},o={};var l=11,p=1/(l-1),e="function"==typeof Float32Array;function i(t,e){return 1-3*e+3*t}function s(t,e){return 3*e-6*t}function a(t){return 3*t}function m(t,e,r){return((i(e,r)*t+s(e,r))*t+a(e))*t}function f(t,e,r){return 3*i(e,r)*t*t+2*s(e,r)*t+a(e)}function h(t){this._p=t,this._mSampleValues=e?new Float32Array(l):new Array(l),this._precomputed=!1,this.get=this.get.bind(this)}return h.prototype={get:function(t){var e=this._p[0],r=this._p[1],i=this._p[2],s=this._p[3];return this._precomputed||this._precompute(),e===r&&i===s?t:0===t?0:1===t?1:m(this._getTForX(t),r,s)},_precompute:function(){var t=this._p[0],e=this._p[1],r=this._p[2],i=this._p[3];this._precomputed=!0,t===e&&r===i||this._calcSampleValues()},_calcSampleValues:function(){for(var t=this._p[0],e=this._p[2],r=0;rn?-1:1,l=!0;l;)if(i[a]<=n&&i[a+1]>n?(o=(n-i[a])/(i[a+1]-i[a]),l=!1):a+=h,a<0||s-1<=a){if(a===s-1)return r[a];l=!1}return r[a]+(r[a+1]-r[a])*o}var F=createTypedArray("float32",8);return{getSegmentsLength:function(t){var e,r=segmentsLengthPool.newElement(),i=t.c,s=t.v,a=t.o,n=t.i,o=t._length,h=r.lengths,l=0;for(e=0;er[0]||!(r[0]>t[0])&&(t[1]>r[1]||!(r[1]>t[1])&&(t[2]>r[2]||!(r[2]>t[2])&&null))}var h,r=function(){var i=[4,4,14];function s(t){var e,r,i,s=t.length;for(e=0;e=a.t-i){s.h&&(s=a),f=0;break}if(a.t-i>t){f=c;break}c=r&&r<=t||this._caching.lastFrame=t&&(this._caching._lastKeyframeIndex=-1,this._caching.lastIndex=0);var i=this.interpolateValue(t,this._caching);this.pv=i}return this._caching.lastFrame=t,this.pv}function d(t){var e;if("unidimensional"===this.propType)e=t*this.mult,1e-5=this.p.keyframes[this.p.keyframes.length-1].t?(r=this.p.getValueAtTime(this.p.keyframes[this.p.keyframes.length-1].t/e,0),this.p.getValueAtTime((this.p.keyframes[this.p.keyframes.length-1].t-.05)/e,0)):(r=this.p.pv,this.p.getValueAtTime((this.p._caching.lastFrame+this.p.offsetTime-.01)/e,this.p.offsetTime));else if(this.px&&this.px.keyframes&&this.py.keyframes&&this.px.getValueAtTime&&this.py.getValueAtTime){r=[],i=[];var s=this.px,a=this.py;s._caching.lastFrame+s.offsetTime<=s.keyframes[0].t?(r[0]=s.getValueAtTime((s.keyframes[0].t+.01)/e,0),r[1]=a.getValueAtTime((a.keyframes[0].t+.01)/e,0),i[0]=s.getValueAtTime(s.keyframes[0].t/e,0),i[1]=a.getValueAtTime(a.keyframes[0].t/e,0)):s._caching.lastFrame+s.offsetTime>=s.keyframes[s.keyframes.length-1].t?(r[0]=s.getValueAtTime(s.keyframes[s.keyframes.length-1].t/e,0),r[1]=a.getValueAtTime(a.keyframes[a.keyframes.length-1].t/e,0),i[0]=s.getValueAtTime((s.keyframes[s.keyframes.length-1].t-.01)/e,0),i[1]=a.getValueAtTime((a.keyframes[a.keyframes.length-1].t-.01)/e,0)):(r=[s.pv,a.pv],i[0]=s.getValueAtTime((s._caching.lastFrame+s.offsetTime-.01)/e,s.offsetTime),i[1]=a.getValueAtTime((a._caching.lastFrame+a.offsetTime-.01)/e,a.offsetTime))}else r=i=n;this.v.rotate(-Math.atan2(r[1]-i[1],r[0]-i[0]))}this.data.p&&this.data.p.s?this.data.p.z?this.v.translate(this.px.v,this.py.v,-this.pz.v):this.v.translate(this.px.v,this.py.v,0):this.v.translate(this.p.v[0],this.p.v[1],-this.p.v[2])}this.frameId=this.elem.globalData.frameId}},precalculateMatrix:function(){if(!this.a.k&&(this.pre.translate(-this.a.v[0],-this.a.v[1],this.a.v[2]),this.appliedTransformations=1,!this.s.effectsSequence.length)){if(this.pre.scale(this.s.v[0],this.s.v[1],this.s.v[2]),this.appliedTransformations=2,this.sk){if(this.sk.effectsSequence.length||this.sa.effectsSequence.length)return;this.pre.skewFromAxis(-this.sk.v,this.sa.v),this.appliedTransformations=3}this.r?this.r.effectsSequence.length||(this.pre.rotate(-this.r.v),this.appliedTransformations=4):this.rz.effectsSequence.length||this.ry.effectsSequence.length||this.rx.effectsSequence.length||this.or.effectsSequence.length||(this.pre.rotateZ(-this.rz.v).rotateY(this.ry.v).rotateX(this.rx.v).rotateZ(-this.or.v[2]).rotateY(this.or.v[1]).rotateX(this.or.v[0]),this.appliedTransformations=4)}},autoOrient:function(){}},extendPrototype([DynamicPropertyContainer],i),i.prototype.addDynamicProperty=function(t){this._addDynamicProperty(t),this.elem.addDynamicProperty(t),this._isDirty=!0},i.prototype._addDynamicProperty=DynamicPropertyContainer.prototype.addDynamicProperty,{getTransformProperty:function(t,e,r){return new i(t,e,r)}}}();function ShapePath(){this.c=!1,this._length=0,this._maxLength=8,this.v=createSizedArray(this._maxLength),this.o=createSizedArray(this._maxLength),this.i=createSizedArray(this._maxLength)}ShapePath.prototype.setPathData=function(t,e){this.c=t,this.setLength(e);for(var r=0;r=this._maxLength&&this.doubleArrayLength(),r){case"v":a=this.v;break;case"i":a=this.i;break;case"o":a=this.o;break;default:a=[]}(!a[i]||a[i]&&!s)&&(a[i]=pointPool.newElement()),a[i][0]=t,a[i][1]=e},ShapePath.prototype.setTripleAt=function(t,e,r,i,s,a,n,o){this.setXYAt(t,e,"v",n,o),this.setXYAt(r,i,"o",n,o),this.setXYAt(s,a,"i",n,o)},ShapePath.prototype.reverse=function(){var t=new ShapePath;t.setPathData(this.c,this._length);var e=this.v,r=this.o,i=this.i,s=0;this.c&&(t.setTripleAt(e[0][0],e[0][1],i[0][0],i[0][1],r[0][0],r[0][1],0,!1),s=1);var a,n=this._length-1,o=this._length;for(a=s;a=c[c.length-1].t-this.offsetTime)i=c[c.length-1].s?c[c.length-1].s[0]:c[c.length-2].e[0],a=!0;else{for(var d,u,y=f,g=c.length-1,v=!0;v&&(d=c[y],!((u=c[y+1]).t-this.offsetTime>t));)y=u.t-this.offsetTime)p=1;else if(ti+r))p=o.s*s<=i?0:(o.s*s-i)/r,m=o.e*s>=i+r?1:(o.e*s-i)/r,h.push([p,m])}return h.length||h.push([0,0]),h},TrimModifier.prototype.releasePathsData=function(t){var e,r=t.length;for(e=0;ee.e){r.c=!1;break}e.s<=d&&e.e>=d+n.addedLength?(this.addSegment(f[i].v[s-1],f[i].o[s-1],f[i].i[s],f[i].v[s],r,o,y),y=!1):(l=bez.getNewSegment(f[i].v[s-1],f[i].v[s],f[i].o[s-1],f[i].i[s],(e.s-d)/n.addedLength,(e.e-d)/n.addedLength,h[s-1]),this.addSegmentFromArray(l,r,o,y),y=!1,r.c=!1),d+=n.addedLength,o+=1}if(f[i].c&&h.length){if(n=h[s-1],d<=e.e){var g=h[s-1].addedLength;e.s<=d&&e.e>=d+g?(this.addSegment(f[i].v[s-1],f[i].o[s-1],f[i].i[0],f[i].v[0],r,o,y),y=!1):(l=bez.getNewSegment(f[i].v[s-1],f[i].v[0],f[i].o[s-1],f[i].i[0],(e.s-d)/g,(e.e-d)/g,h[s-1]),this.addSegmentFromArray(l,r,o,y),y=!1,r.c=!1)}else r.c=!1;d+=n.addedLength,o+=1}if(r._length&&(r.setXYAt(r.v[p][0],r.v[p][1],"i",p),r.setXYAt(r.v[r._length-1][0],r.v[r._length-1][1],"o",r._length-1)),d>e.e)break;i=d.length&&(m=0,d=u[f+=1]?u[f].points:P.v.c?u[f=m=0].points:(l-=h.partialLength,null)),d&&(c=h,y=(h=d[m]).partialLength));L=T[s].an/2-T[s].add,A.translate(-L,0,0)}else L=T[s].an/2-T[s].add,A.translate(-L,0,0),A.translate(-E[0]*T[s].an*.005,-E[1]*B*.01,0);for(F=0;Fe);)r+=1;return this.keysIndex!==r&&(this.keysIndex=r),this.data.d.k[this.keysIndex].s},TextProperty.prototype.buildFinalText=function(t){for(var e,r=FontManager.getCombinedCharacterCodes(),i=[],s=0,a=t.length;sthis.minimumFontSize&&k=u(o)&&(n=c(0,d(t-o<0?d(h,1)-(o-t):h-t,1))),a(n));return n*this.a.v},getValue:function(t){this.iterateDynamicProperties(),this._mdf=t||this._mdf,this._currentTextLength=this.elem.textProperty.currentData.l.length||0,t&&2===this.data.r&&(this.e.v=this._currentTextLength);var e=2===this.data.r?1:100/this.data.totalChars,r=this.o.v/e,i=this.s.v/e+r,s=this.e.v/e+r;if(st-this.layers[e].st&&this.buildItem(e),this.completeLayers=!!this.elements[e]&&this.completeLayers;this.checkPendingElements()},BaseRenderer.prototype.createItem=function(t){switch(t.ty){case 2:return this.createImage(t);case 0:return this.createComp(t);case 1:return this.createSolid(t);case 3:return this.createNull(t);case 4:return this.createShape(t);case 5:return this.createText(t);case 6:return this.createAudio(t);case 13:return this.createCamera(t);case 15:return this.createFootage(t);default:return this.createNull(t)}},BaseRenderer.prototype.createCamera=function(){throw new Error("You're using a 3d camera. Try the html renderer.")},BaseRenderer.prototype.createAudio=function(t){return new AudioElement(t,this.globalData,this)},BaseRenderer.prototype.createFootage=function(t){return new FootageElement(t,this.globalData,this)},BaseRenderer.prototype.buildAllItems=function(){var t,e=this.layers.length;for(t=0;t=t)return this.threeDElements[e].perspectiveElem;e+=1}return null},HybridRenderer.prototype.createThreeDContainer=function(t,e){var r,i,s=createTag("div");styleDiv(s);var a=createTag("div");if(styleDiv(a),"3d"===e){(r=s.style).width=this.globalData.compSize.w+"px",r.height=this.globalData.compSize.h+"px";var n="50% 50%";r.webkitTransformOrigin=n,r.mozTransformOrigin=n,r.transformOrigin=n;var o="matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)";(i=a.style).transform=o,i.webkitTransform=o}s.appendChild(a);var h={container:a,perspectiveElem:s,startPos:t,endPos:t,type:e};return this.threeDElements.push(h),h},HybridRenderer.prototype.build3dContainers=function(){var t,e,r=this.layers.length,i="";for(t=0;tt?!0!==this.isInRange&&(this.globalData._mdf=!0,this._mdf=!0,this.isInRange=!0,this.show()):!1!==this.isInRange&&(this.globalData._mdf=!0,this.isInRange=!1,this.hide())},renderRenderable:function(){var t,e=this.renderableComponents.length;for(t=0;t=t.x+t.width&&this.currentBBox.height+this.currentBBox.y>=t.y+t.height},HShapeElement.prototype.renderInnerContent=function(){if(this._renderShapeFrame(),!this.hidden&&(this._isFirstFrame||this._mdf)){var t=this.tempBoundingBox,e=999999;if(t.x=e,t.xMax=-e,t.y=e,t.yMax=-e,this.calculateBoundingBox(this.itemsData,t),t.width=t.xMaxthis.animationData.op&&(this.animationData.op=t.op,this.totalFrames=Math.floor(t.op-this.animationData.ip));var e,r,i=this.animationData.layers,s=i.length,a=t.layers,n=a.length;for(r=0;rthis.timeCompleted&&(this.currentFrame=this.timeCompleted),this.trigger("enterFrame"),this.renderFrame()},AnimationItem.prototype.renderFrame=function(){if(!1!==this.isLoaded&&this.renderer)try{this.renderer.renderFrame(this.currentFrame+this.firstFrame)}catch(t){this.triggerRenderFrameError(t)}},AnimationItem.prototype.play=function(t){t&&this.name!==t||!0===this.isPaused&&(this.isPaused=!1,this.audioController.resume(),this._idle&&(this._idle=!1,this.trigger("_active")))},AnimationItem.prototype.pause=function(t){t&&this.name!==t||!1===this.isPaused&&(this.isPaused=!0,this._idle=!0,this.trigger("_idle"),this.audioController.pause())},AnimationItem.prototype.togglePause=function(t){t&&this.name!==t||(!0===this.isPaused?this.play():this.pause())},AnimationItem.prototype.stop=function(t){t&&this.name!==t||(this.pause(),this.playCount=0,this._completedLoop=!1,this.setCurrentRawFrameValue(0))},AnimationItem.prototype.getMarkerData=function(t){for(var e,r=0;r=this.totalFrames-1&&0=this.totalFrames?(this.playCount+=1,this.checkSegments(e%this.totalFrames)||(this.setCurrentRawFrameValue(e%this.totalFrames),this._completedLoop=!0,this.trigger("loopComplete"))):this.setCurrentRawFrameValue(e):this.checkSegments(e>this.totalFrames?e%this.totalFrames:0)||(r=!0,e=this.totalFrames-1):e<0?this.checkSegments(e%this.totalFrames)||(!this.loop||this.playCount--<=0&&!0!==this.loop?(r=!0,e=0):(this.setCurrentRawFrameValue(this.totalFrames+e%this.totalFrames),this._completedLoop?this.trigger("loopComplete"):this._completedLoop=!0)):this.setCurrentRawFrameValue(e),r&&(this.setCurrentRawFrameValue(e),this.pause(),this.trigger("complete"))}},AnimationItem.prototype.adjustSegment=function(t,e){this.playCount=0,t[1]t[0]&&(this.frameModifier<0&&(this.playSpeed<0?this.setSpeed(-this.playSpeed):this.setDirection(1)),this.totalFrames=t[1]-t[0],this.timeCompleted=this.totalFrames,this.firstFrame=t[0],this.setCurrentRawFrameValue(.001+e)),this.trigger("segmentStart")},AnimationItem.prototype.setSegment=function(t,e){var r=-1;this.isPaused&&(this.currentRawFrame+this.firstFramee&&(r=e-t)),this.firstFrame=t,this.totalFrames=e-t,this.timeCompleted=this.totalFrames,-1!==r&&this.goToAndStop(r,!0)},AnimationItem.prototype.playSegments=function(t,e){if(e&&(this.segments.length=0),"object"==typeof t[0]){var r,i=t.length;for(r=0;rdata.k[e].t&&tdata.k[e+1].t-t?(r=e+2,data.k[e+1].t):(r=e+1,data.k[e].t);break}}-1===r&&(r=e+1,i=data.k[e].t)}else i=r=0;var a={};return a.index=r,a.time=i/elem.comp.globalData.frameRate,a}function key(t){var e,r,i;if(!data.k.length||"number"==typeof data.k[0])throw new Error("The property has no keyframe at index "+t);t-=1,e={time:data.k[t].t/elem.comp.globalData.frameRate,value:[]};var s=Object.prototype.hasOwnProperty.call(data.k[t],"s")?data.k[t].s:data.k[t-1].e;for(i=s.length,r=0;rl.length-1)&&(e=l.length-1),i=p-(s=l[l.length-1-e].t)),"pingpong"===t){if(Math.floor((h-s)/i)%2!=0)return this.getValueAtTime((i-(h-s)%i+s)/this.comp.globalData.frameRate,0)}else{if("offset"===t){var m=this.getValueAtTime(s/this.comp.globalData.frameRate,0),f=this.getValueAtTime(p/this.comp.globalData.frameRate,0),c=this.getValueAtTime(((h-s)%i+s)/this.comp.globalData.frameRate,0),d=Math.floor((h-s)/i);if(this.pv.length){for(n=(o=new Array(m.length)).length,a=0;al.length-1)&&(e=l.length-1),i=(s=l[e].t)-p),"pingpong"===t){if(Math.floor((p-h)/i)%2==0)return this.getValueAtTime(((p-h)%i+p)/this.comp.globalData.frameRate,0)}else{if("offset"===t){var m=this.getValueAtTime(p/this.comp.globalData.frameRate,0),f=this.getValueAtTime(s/this.comp.globalData.frameRate,0),c=this.getValueAtTime((i-(p-h)%i+p)/this.comp.globalData.frameRate,0),d=Math.floor((p-h)/i)+1;if(this.pv.length){for(n=(o=new Array(m.length)).length,a=0;an){var p=o,m=r.c&&o===h-1?0:o+1,f=(n-l)/a[o].addedLength;i=bez.getPointInSegment(r.v[p],r.v[m],r.o[p],r.i[m],f,a[o]);break}l+=a[o].addedLength,o+=1}return i||(i=r.c?[r.v[0][0],r.v[0][1]]:[r.v[r._length-1][0],r.v[r._length-1][1]]),i},vectorOnPath:function(t,e,r){1==t?t=this.v.c:0==t&&(t=.999);var i=this.pointOnPath(t,e),s=this.pointOnPath(t+.001,e),a=s[0]-i[0],n=s[1]-i[1],o=Math.sqrt(Math.pow(a,2)+Math.pow(n,2));return 0===o?[0,0]:"tangent"===r?[a/o,n/o]:[-n/o,a/o]},tangentOnPath:function(t,e){return this.vectorOnPath(t,e,"tangent")},normalOnPath:function(t,e){return this.vectorOnPath(t,e,"normal")},setGroupProperty:expressionHelpers.setGroupProperty,getValueAtTime:expressionHelpers.getStaticValueAtTime},extendPrototype([r],t),extendPrototype([r],e),e.prototype.getValueAtTime=function(t){return this._cachingAtTime||(this._cachingAtTime={shapeValue:shapePool.clone(this.pv),lastIndex:0,lastTime:initialDefaultFrame}),t*=this.elem.globalData.frameRate,(t-=this.offsetTime)!==this._cachingAtTime.lastTime&&(this._cachingAtTime.lastIndex=this._cachingAtTime.lastTime + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-modal/tui-modal.vue b/src/components/thorui/tui-modal/tui-modal.vue new file mode 100644 index 0000000..b6e2898 --- /dev/null +++ b/src/components/thorui/tui-modal/tui-modal.vue @@ -0,0 +1,338 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-msg/tui-msg.vue b/src/components/thorui/tui-msg/tui-msg.vue new file mode 100644 index 0000000..ab1f66e --- /dev/null +++ b/src/components/thorui/tui-msg/tui-msg.vue @@ -0,0 +1,92 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-navigation-bar/tui-navigation-bar.vue b/src/components/thorui/tui-navigation-bar/tui-navigation-bar.vue new file mode 100644 index 0000000..7db07ea --- /dev/null +++ b/src/components/thorui/tui-navigation-bar/tui-navigation-bar.vue @@ -0,0 +1,258 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-network-alert/tui-network-alert.vue b/src/components/thorui/tui-network-alert/tui-network-alert.vue new file mode 100644 index 0000000..cb09c52 --- /dev/null +++ b/src/components/thorui/tui-network-alert/tui-network-alert.vue @@ -0,0 +1,127 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-no-data/tui-no-data.vue b/src/components/thorui/tui-no-data/tui-no-data.vue new file mode 100644 index 0000000..cfd80c8 --- /dev/null +++ b/src/components/thorui/tui-no-data/tui-no-data.vue @@ -0,0 +1,137 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-nomore/tui-nomore.vue b/src/components/thorui/tui-nomore/tui-nomore.vue new file mode 100644 index 0000000..cbc9d61 --- /dev/null +++ b/src/components/thorui/tui-nomore/tui-nomore.vue @@ -0,0 +1,115 @@ + + + + + diff --git a/src/components/thorui/tui-notice-bar/tui-notice-bar.vue b/src/components/thorui/tui-notice-bar/tui-notice-bar.vue new file mode 100644 index 0000000..48565bc --- /dev/null +++ b/src/components/thorui/tui-notice-bar/tui-notice-bar.vue @@ -0,0 +1,431 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-notice-vertical/tui-notice-vertical.vue b/src/components/thorui/tui-notice-vertical/tui-notice-vertical.vue new file mode 100644 index 0000000..e1350ea --- /dev/null +++ b/src/components/thorui/tui-notice-vertical/tui-notice-vertical.vue @@ -0,0 +1,174 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-numberbox/tui-numberbox.vue b/src/components/thorui/tui-numberbox/tui-numberbox.vue new file mode 100644 index 0000000..2fb6e7e --- /dev/null +++ b/src/components/thorui/tui-numberbox/tui-numberbox.vue @@ -0,0 +1,248 @@ + + + + + diff --git a/src/components/thorui/tui-org-horizontal/tui-org-horizontal.vue b/src/components/thorui/tui-org-horizontal/tui-org-horizontal.vue new file mode 100644 index 0000000..e5619e2 --- /dev/null +++ b/src/components/thorui/tui-org-horizontal/tui-org-horizontal.vue @@ -0,0 +1,241 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-org-node/tui-org-node.vue b/src/components/thorui/tui-org-node/tui-org-node.vue new file mode 100644 index 0000000..a51577f --- /dev/null +++ b/src/components/thorui/tui-org-node/tui-org-node.vue @@ -0,0 +1,244 @@ + + + + + diff --git a/src/components/thorui/tui-org-tree/tui-org-tree.vue b/src/components/thorui/tui-org-tree/tui-org-tree.vue new file mode 100644 index 0000000..2026244 --- /dev/null +++ b/src/components/thorui/tui-org-tree/tui-org-tree.vue @@ -0,0 +1,45 @@ + + + + + diff --git a/src/components/thorui/tui-overflow-hidden/tui-overflow-hidden.vue b/src/components/thorui/tui-overflow-hidden/tui-overflow-hidden.vue new file mode 100644 index 0000000..55a22df --- /dev/null +++ b/src/components/thorui/tui-overflow-hidden/tui-overflow-hidden.vue @@ -0,0 +1,134 @@ + + + + + diff --git a/src/components/thorui/tui-pagination/tui-pagination.vue b/src/components/thorui/tui-pagination/tui-pagination.vue new file mode 100644 index 0000000..f2e3626 --- /dev/null +++ b/src/components/thorui/tui-pagination/tui-pagination.vue @@ -0,0 +1,213 @@ + + + + + diff --git a/src/components/thorui/tui-picker/tui-picker.vue b/src/components/thorui/tui-picker/tui-picker.vue new file mode 100644 index 0000000..085f8c3 --- /dev/null +++ b/src/components/thorui/tui-picker/tui-picker.vue @@ -0,0 +1,551 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-picture-cropper/tui-picture-cropper.vue b/src/components/thorui/tui-picture-cropper/tui-picture-cropper.vue new file mode 100644 index 0000000..1a8cbad --- /dev/null +++ b/src/components/thorui/tui-picture-cropper/tui-picture-cropper.vue @@ -0,0 +1,701 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-picture-cropper/tui-picture-cropper.wxs b/src/components/thorui/tui-picture-cropper/tui-picture-cropper.wxs new file mode 100644 index 0000000..09a3402 --- /dev/null +++ b/src/components/thorui/tui-picture-cropper/tui-picture-cropper.wxs @@ -0,0 +1,571 @@ +var cropper = { + CUT_START: null, + cutX: 0, //画布x轴起点 + cutY: 0, //画布y轴起点0 + touchRelative: [{ + x: 0, + y: 0 + }], //手指或鼠标和图片中心的相对位置 + flagCutTouch: false, //是否是拖动裁剪框 + hypotenuseLength: 0, //双指触摸时斜边长度 + flagEndTouch: false, //是否结束触摸 + canvasWidth: 0, + canvasHeight: 0, + imgWidth: 0, //图片宽度 + imgHeight: 0, //图片高度 + scale: 1, //图片缩放比 + angle: 0, //图片旋转角度 + imgTop: 0, //图片上边距 + imgLeft: 0, //图片左边距 + //是否限制移动范围(剪裁框只能在图片内,为true不可触摸转动图片) + limitMove: true, + minHeight: 0, + maxHeight: 0, + minWidth: 0, + maxWidth: 0, + windowHeight: 0, + windowWidth: 0, + init: true +} + +function bool(str) { + return str === 'true' || str == true ? true : false +} + +function touchstart(e, ins) { + //var instance = e.instance; + // var state = instance.getState(); + var touch = e.touches || e.changedTouches; + cropper.flagEndTouch = false; + if (touch.length == 1) { + cropper.touchRelative[0] = { + x: touch[0].pageX - cropper.imgLeft, + y: touch[0].pageY - cropper.imgTop + }; + } else { + var width = Math.abs(touch[0].pageX - touch[1].pageX); + var height = Math.abs(touch[0].pageY - touch[1].pageY); + cropper.touchRelative = [{ + x: touch[0].pageX - cropper.imgLeft, + y: touch[0].pageY - cropper.imgTop + }, + { + x: touch[1].pageX - cropper.imgLeft, + y: touch[1].pageY - cropper.imgTop + } + ]; + cropper.hypotenuseLength = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)); + } + +} + +function moveDuring(ins) { + if (!ins) return; + ins.callMethod('moveDuring') +} + +function moveStop(ins) { + if (!ins) return; + ins.callMethod('moveStop') +}; + +function setCutCenter(ins) { + var cutY = (cropper.windowHeight - cropper.canvasHeight) * 0.5; + var cutX = (cropper.windowWidth - cropper.canvasWidth) * 0.5; + //顺序不能变 + cropper.imgTop = cropper.imgTop - cropper.cutY + cutY; + cropper.cutY = cutY; //截取的框上边距 + cropper.imgLeft = cropper.imgLeft - cropper.cutX + cutX; + cropper.cutX = cutX; //截取的框左边距 + styleUpdate(ins) + cutDetectionPosition(ins) + imgTransform(ins) + updateData(ins) +} + +function touchmove(e, ins) { + var touch = e.touches || e.changedTouches; + if (cropper.flagEndTouch) return; + moveDuring(ins); + if (e.touches.length == 1) { + var left = touch[0].pageX - cropper.touchRelative[0].x, + top = touch[0].pageY - cropper.touchRelative[0].y; + cropper.imgLeft = left; + cropper.imgTop = top; + imgTransform(ins); + imgMarginDetectionPosition(ins); + } else { + var res = e.instance.getDataset(); + var minScale = +res.minscale; + var maxScale = +res.maxscale; + var disableRotate = bool(res.disablerotate) + var width = Math.abs(touch[0].pageX - touch[1].pageX), + height = Math.abs(touch[0].pageY - touch[1].pageY), + hypotenuse = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)), + scale = cropper.scale * (hypotenuse / cropper.hypotenuseLength), + current_deg = 0; + scale = scale <= minScale ? minScale : scale; + scale = scale >= maxScale ? maxScale : scale; + cropper.scale = scale; + imgMarginDetectionScale(ins, true); + var touchRelative = [{ + x: touch[0].pageX - cropper.imgLeft, + y: touch[0].pageY - cropper.imgTop + }, + { + x: touch[1].pageX - cropper.imgLeft, + y: touch[1].pageY - cropper.imgTop + } + ]; + if (!disableRotate) { + var first_atan = (180 / Math.PI) * Math.atan2(touchRelative[0].y, touchRelative[0].x); + var first_atan_old = (180 / Math.PI) * Math.atan2(cropper.touchRelative[0].y, cropper.touchRelative[0].x); + var second_atan = (180 / Math.PI) * Math.atan2(touchRelative[1].y, touchRelative[1].x); + var second_atan_old = (180 / Math.PI) * Math.atan2(cropper.touchRelative[1].y, cropper.touchRelative[1].x); + var first_deg = first_atan - first_atan_old, + second_deg = second_atan - second_atan_old; + if (first_deg != 0) { + current_deg = first_deg; + } else if (second_deg != 0) { + current_deg = second_deg; + } + } + cropper.touchRelative = touchRelative; + cropper.hypotenuseLength = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)); + //更新视图 + cropper.angle = cropper.angle + current_deg; + imgTransform(ins); + } +} + +function touchend(e, ins) { + cropper.flagEndTouch = true; + moveStop(ins); + updateData(ins) +} + + +function cutTouchStart(e, ins) { + var touch = e.touches || e.changedTouches; + var currentX = touch[0].pageX; + var currentY = touch[0].pageY; + + /* + * (右下-1 右上-2 左上-3 左下-4) + * left_x [3,4] + * top_y [2,3] + * right_x [1,2] + * bottom_y [1,4] + */ + var left_x1 = cropper.cutX - 30; + var left_x2 = cropper.cutX + 30; + + var top_y1 = cropper.cutY - 30; + var top_y2 = cropper.cutY + 30; + + var right_x1 = cropper.cutX + cropper.canvasWidth - 30; + var right_x2 = cropper.cutX + cropper.canvasWidth + 30; + + var bottom_y1 = cropper.cutY + cropper.canvasHeight - 30; + var bottom_y2 = cropper.cutY + cropper.canvasHeight + 30; + + if (currentX > right_x1 && currentX < right_x2 && currentY > bottom_y1 && currentY < bottom_y2) { + moveDuring(); + cropper.flagCutTouch = true; + cropper.flagEndTouch = true; + cropper.CUT_START = { + width: cropper.canvasWidth, + height: cropper.canvasHeight, + x: currentX, + y: currentY, + corner: 1 + }; + } else if (currentX > right_x1 && currentX < right_x2 && currentY > top_y1 && currentY < top_y2) { + moveDuring(); + cropper.flagCutTouch = true; + cropper.flagEndTouch = true; + cropper.CUT_START = { + width: cropper.canvasWidth, + height: cropper.canvasHeight, + x: currentX, + y: currentY, + cutY: cropper.cutY, + cutX: cropper.cutX, + corner: 2 + }; + } else if (currentX > left_x1 && currentX < left_x2 && currentY > top_y1 && currentY < top_y2) { + moveDuring(); + cropper.flagCutTouch = true; + cropper.flagEndTouch = true; + cropper.CUT_START = { + width: cropper.canvasWidth, + height: cropper.canvasHeight, + cutY: cropper.cutY, + cutX: cropper.cutX, + x: currentX, + y: currentY, + corner: 3 + }; + } else if (currentX > left_x1 && currentX < left_x2 && currentY > bottom_y1 && currentY < bottom_y2) { + moveDuring(); + cropper.flagCutTouch = true; + cropper.flagEndTouch = true; + cropper.CUT_START = { + width: cropper.canvasWidth, + height: cropper.canvasHeight, + cutY: cropper.cutY, + cutX: cropper.cutX, + x: currentX, + y: currentY, + corner: 4 + }; + } +} + +function cutTouchMove(e, ins) { + if (!cropper.CUT_START || cropper.CUT_START === 'null') return; + if (cropper.flagCutTouch) { + var touch = e.touches || e.changedTouches; + var res = e.instance.getDataset(); + var lockRatio = bool(res.lockratio); + var lockWidth = bool(res.lockwidth); + var lockHeight = bool(res.lockheight); + if (lockRatio && (lockWidth || lockHeight)) return; + var width = cropper.canvasWidth, + height = cropper.canvasHeight, + cutY = cropper.cutY, + cutX = cropper.cutX; + + var size_correct = function() { + width = width <= cropper.maxWidth ? (width >= cropper.minWidth ? width : cropper.minWidth) : cropper + .maxWidth; + height = height <= cropper.maxHeight ? (height >= cropper.minHeight ? height : cropper.minHeight) : + cropper.maxHeight; + } + + var size_inspect = function() { + if ((width > cropper.maxWidth || width < cropper.minWidth || height > cropper.maxHeight || height < + cropper.minHeight) && + lockRatio) { + size_correct(); + return false; + } else { + size_correct(); + return true; + } + }; + height = cropper.CUT_START.height + (cropper.CUT_START.corner > 1 && cropper.CUT_START.corner < 4 ? 1 : -1) * ( + cropper.CUT_START.y - touch[0].pageY); + switch (cropper.CUT_START.corner) { + case 1: + width = cropper.CUT_START.width - cropper.CUT_START.x + touch[0].pageX; + if (lockRatio) { + height = width / (cropper.canvasWidth / cropper.canvasHeight); + } + if (!size_inspect()) return; + break; + case 2: + width = cropper.CUT_START.width - cropper.CUT_START.x + touch[0].pageX; + if (lockRatio) { + height = width / (cropper.canvasWidth / cropper.canvasHeight); + } + if (!size_inspect()) return; + cutY = cropper.CUT_START.cutY - (height - cropper.CUT_START.height); + break; + case 3: + width = cropper.CUT_START.width + cropper.CUT_START.x - touch[0].pageX; + if (lockRatio) { + height = width / (cropper.canvasWidth / cropper.canvasHeight); + } + if (!size_inspect()) return; + cutY = cropper.CUT_START.cutY - (height - cropper.CUT_START.height); + cutX = cropper.CUT_START.cutX - (width - cropper.CUT_START.width); + break; + case 4: + width = cropper.CUT_START.width + cropper.CUT_START.x - touch[0].pageX; + if (lockRatio) { + height = width / (cropper.canvasWidth / cropper.canvasHeight); + } + if (!size_inspect()) return; + cutX = cropper.CUT_START.cutX - (width - cropper.CUT_START.width); + break; + default: + break; + } + if (!lockWidth && !lockHeight) { + cropper.canvasWidth = width; + cropper.cutX = cutX; + cropper.canvasHeight = height; + cropper.cutY = cutY; + canvasHeight(ins); + canvasWidth(ins); + } else if (!lockWidth) { + cropper.canvasWidth = width; + cropper.cutX = cutX; + canvasWidth(ins); + } else if (!lockHeight) { + cropper.canvasHeight = height; + cropper.cutY = cutY; + canvasHeight(ins); + } + styleUpdate(ins) + imgMarginDetectionScale(ins); + } +} + +//检测剪裁框位置是否在允许的范围内(屏幕内) +function cutDetectionPosition(ins) { + var windowHeight = cropper.windowHeight, + windowWidth = cropper.windowWidth; + + var cutDetectionPositionTop = function() { + //检测上边距是否在范围内 + if (cropper.cutY < 0) { + cropper.cutY = 0; + } + if (cropper.cutY > windowHeight - cropper.canvasHeight) { + cropper.cutY = windowHeight - cropper.canvasHeight; + } + } + + var cutDetectionPositionLeft = function() { + //检测左边距是否在范围内 + if (cropper.cutX < 0) { + cropper.cutX = 0; + } + if (cropper.cutX > windowWidth - cropper.canvasWidth) { + cropper.cutX = windowWidth - cropper.canvasWidth; + } + } + //裁剪框坐标处理(如果只写一个参数则另一个默认为0,都不写默认居中) + if (cropper.cutY == null && cropper.cutX == null) { + var cutY = (windowHeight - cropper.canvasHeight) * 0.5; + var cutX = (windowWidth - cropper.canvasWidth) * 0.5; + cropper.cutY = cutY; //截取的框上边距 + cropper.cutX = cutX; //截取的框左边距 + } else if (cropper.cutY != null && cropper.cutX != null) { + cutDetectionPositionTop(); + cutDetectionPositionLeft(); + } else if (cropper.cutY != null && cropper.cutX == null) { + cutDetectionPositionTop(); + cropper.cutX = (windowWidth - cropper.canvasWidth) / 2; + } else if (cropper.cutY == null && cropper.cutX != null) { + cutDetectionPositionLeft(); + cropper.cutY = (windowHeight - cropper.canvasHeight) / 2; + } + + styleUpdate(ins) +} + +/** + * 图片边缘检测-缩放 + */ +function imgMarginDetectionScale(ins, delay) { + if (!cropper.limitMove) return; + var scale = cropper.scale; + var imgWidth = cropper.imgWidth; + var imgHeight = cropper.imgHeight; + if ((cropper.angle / 90) % 2) { + imgWidth = cropper.imgHeight; + imgHeight = cropper.imgWidth; + } + if (imgWidth * scale < cropper.canvasWidth) { + scale = cropper.canvasWidth / imgWidth; + } + if (imgHeight * scale < cropper.canvasHeight) { + scale = Math.max(scale, cropper.canvasHeight / imgHeight); + } + imgMarginDetectionPosition(ins, scale, delay); +} +/** + * 图片边缘检测-位置 + */ +function imgMarginDetectionPosition(ins, scale, delay) { + if (!cropper.limitMove) return; + var left = cropper.imgLeft; + var top = cropper.imgTop; + scale = scale || cropper.scale; + var imgWidth = cropper.imgWidth; + var imgHeight = cropper.imgHeight; + if ((cropper.angle / 90) % 2) { + imgWidth = cropper.imgHeight; + imgHeight = cropper.imgWidth; + } + left = cropper.cutX + (imgWidth * scale) / 2 >= left ? left : cropper.cutX + (imgWidth * scale) / 2; + left = cropper.cutX + cropper.canvasWidth - (imgWidth * scale) / 2 <= left ? left : cropper.cutX + cropper + .canvasWidth - + (imgWidth * scale) / 2; + top = cropper.cutY + (imgHeight * scale) / 2 >= top ? top : cropper.cutY + (imgHeight * scale) / 2; + top = cropper.cutY + cropper.canvasHeight - (imgHeight * scale) / 2 <= top ? top : cropper.cutY + cropper + .canvasHeight - + (imgHeight * scale) / 2; + + cropper.imgLeft = left; + cropper.imgTop = top; + cropper.scale = scale; + styleUpdate(ins) + if (!delay || delay === 'null') { + imgTransform(ins); + } +} + + +function cutTouchEnd(e, ins) { + moveStop(ins); + cropper.flagCutTouch = false; + updateData(ins) +} + + +//改变截取框大小 +function computeCutSize(ins) { + if (cropper.canvasWidth > cropper.windowWidth) { + cropper.canvasWidth = cropper.windowWidth; + // canvasWidth(ins) + } else if (cropper.canvasWidth + cropper.cutX > cropper.windowWidth) { + cropper.cutX = cropper.windowWidth - cropper.cutX; + } + if (cropper.canvasHeight > cropper.windowHeight) { + cropper.canvasHeight = cropper.windowHeight; + // canvasHeight(ins) + } else if (cropper.canvasHeight + cropper.cutY > cropper.windowHeight) { + cropper.cutY = cropper.windowHeight - cropper.cutY; + } + // styleUpdate(ins) +} + +function styleUpdate(ins) { + if (!ins) return; + var tcb = ins.selectComponent('.tui-cropper-box'); + var tcm = ins.selectComponent('.tui-content-middle') + var tct = ins.selectComponent('.tui-content-top') + var twb = ins.selectComponent('.tui-wxs-bg') + if (!tcb || !tcm || !tct || !twb) return; + tcb.setStyle({ + 'width': cropper.canvasWidth + 'px', + 'height': cropper.canvasHeight + 'px' + }) + tcm.setStyle({ + 'height': cropper.canvasHeight + 'px' + }) + tct.setStyle({ + 'height': cropper.cutY + 'px' + }) + twb.setStyle({ + 'width': cropper.cutX + 'px' + }) + +} + +function imgTransform(ins) { + var owner = ins.selectComponent('.tui-cropper-image') + if (!owner) return + var x = cropper.imgLeft - cropper.imgWidth / 2; + var y = cropper.imgTop - cropper.imgHeight / 2; + owner.setStyle({ + 'transform': 'translate3d(' + x + 'px,' + y + 'px,0) scale(' + cropper.scale + ') rotate(' + cropper + .angle + 'deg)' + }) +} + +function imageReset(ins) { + cropper.scale = 1; + cropper.angle = 0; + imgTransform(ins); +} +//监听截取框宽高变化 +function canvasWidth(ins) { + if (cropper.canvasWidth < cropper.minWidth) { + cropper.canvasWidth = cropper.minWidth; + } + if (!ins) return; + computeCutSize(ins); +} + +function canvasHeight(ins) { + if (cropper.canvasHeight < cropper.minHeight) { + cropper.canvasHeight = cropper.minHeight; + } + if (!ins) return; + computeCutSize(ins); +} + +function updateData(ins) { + if (!ins) return; + ins.callMethod('change', { + cutX: cropper.cutX, + cutY: cropper.cutY, + canvasWidth: cropper.canvasWidth, + canvasHeight: cropper.canvasHeight, + imgWidth: cropper.imgWidth, + imgHeight: cropper.imgHeight, + scale: cropper.scale, + angle: cropper.angle, + imgTop: cropper.imgTop, + imgLeft: cropper.imgLeft + }) +} + +function propsChange(prop, oldProp, ownerInstance, ins) { + if (prop && prop !== 'null') { + var params = prop.split(',') + var type = +params[0] + var dataset = ins.getDataset(); + if (cropper.init || type == 4) { + cropper.maxHeight = +dataset.maxheight; + cropper.minHeight = +dataset.minheight; + cropper.maxWidth = +dataset.maxwidth; + cropper.minWidth = +dataset.minwidth; + cropper.canvasWidth = +dataset.width; + cropper.canvasHeight = +dataset.height; + cropper.imgTop = dataset.windowheight / 2; + cropper.imgLeft = dataset.windowwidth / 2; + cropper.imgWidth = +dataset.imgwidth; + cropper.imgHeight = +dataset.imgheight; + cropper.windowHeight = +dataset.windowheight; + cropper.windowWidth = +dataset.windowwidth; + cropper.init = false + } else if (type == 2 || type == 3) { + cropper.imgWidth = +dataset.imgwidth; + cropper.imgHeight = +dataset.imgheight; + } + cropper.limitMove = bool(dataset.limitmove); + cropper.angle = +dataset.angle; + if (type == 3) { + imgTransform(ownerInstance); + } + switch (type) { + case 1: + setCutCenter(ownerInstance); + //设置裁剪框大小>设置图片尺寸>绘制canvas + computeCutSize(ownerInstance); + //检查裁剪框是否在范围内 + cutDetectionPosition(ownerInstance); + break; + case 2: + setCutCenter(ownerInstance); + break; + case 3: + imgMarginDetectionScale(ownerInstance) + break; + case 4: + imageReset(ownerInstance); + break; + case 5: + setCutCenter(ownerInstance); + break; + default: + break; + } + } +} + +module.exports = { + touchstart: touchstart, + touchmove: touchmove, + touchend: touchend, + cutTouchStart: cutTouchStart, + cutTouchMove: cutTouchMove, + cutTouchEnd: cutTouchEnd, + propsChange: propsChange +} diff --git a/src/components/thorui/tui-popup/tui-popup.vue b/src/components/thorui/tui-popup/tui-popup.vue new file mode 100644 index 0000000..28b7001 --- /dev/null +++ b/src/components/thorui/tui-popup/tui-popup.vue @@ -0,0 +1,276 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-poster/tui-poster.vue b/src/components/thorui/tui-poster/tui-poster.vue new file mode 100644 index 0000000..cc592f6 --- /dev/null +++ b/src/components/thorui/tui-poster/tui-poster.vue @@ -0,0 +1,654 @@ + + + + + diff --git a/src/components/thorui/tui-progress/tui-progress.vue b/src/components/thorui/tui-progress/tui-progress.vue new file mode 100644 index 0000000..3e9b53d --- /dev/null +++ b/src/components/thorui/tui-progress/tui-progress.vue @@ -0,0 +1,140 @@ + + + + + diff --git a/src/components/thorui/tui-radio-group/tui-radio-group.vue b/src/components/thorui/tui-radio-group/tui-radio-group.vue new file mode 100644 index 0000000..e7b22bf --- /dev/null +++ b/src/components/thorui/tui-radio-group/tui-radio-group.vue @@ -0,0 +1,105 @@ + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-radio/tui-radio.vue b/src/components/thorui/tui-radio/tui-radio.vue new file mode 100644 index 0000000..4d0600a --- /dev/null +++ b/src/components/thorui/tui-radio/tui-radio.vue @@ -0,0 +1,222 @@ + + + + + diff --git a/src/components/thorui/tui-rate/tui-rate.vue b/src/components/thorui/tui-rate/tui-rate.vue new file mode 100644 index 0000000..06086ea --- /dev/null +++ b/src/components/thorui/tui-rate/tui-rate.vue @@ -0,0 +1,187 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-roll-news/tui-roll-news.vue b/src/components/thorui/tui-roll-news/tui-roll-news.vue new file mode 100644 index 0000000..3e85a55 --- /dev/null +++ b/src/components/thorui/tui-roll-news/tui-roll-news.vue @@ -0,0 +1,156 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-rotate-verify/index.js b/src/components/thorui/tui-rotate-verify/index.js new file mode 100644 index 0000000..660a0a8 --- /dev/null +++ b/src/components/thorui/tui-rotate-verify/index.js @@ -0,0 +1,80 @@ +// #ifndef APP-PLUS || MP-WEIXIN || H5 +export default { + data() { + return { + useAngle: 0, + transform: '', + startX: 0, + lastLeft: 0, + resetAni: false + } + }, + created() { + this.useAngle = this.angle + }, + watch: { + angle(val) { + this.useAngle = this.angle + }, + reset(val) { + this.startX = 0; + this.lastLeft = 0; + this.styleChange(0, 0) + } + }, + methods: { + styleChange(left, deg) { + if (left == 0 && deg == this.angle) { + this.resetAni = true + } else { + this.resetAni = false + } + this.transform = 'translate3d(' + left + 'px,0,0)' + this.useAngle = deg + }, + touchstart(e) { + let touch = e.touches[0] || e.changedTouches[0]; + this.startX = touch.clientX + }, + touchmove(e) { + if (this.isPass || !this.show) return; + let touch = e.touches[0] || e.changedTouches[0] + let pageX = touch.clientX; + let left = pageX - this.startX + this.lastLeft; + left = left < 0 ? 0 : left; + let width = this.sliderWidth - this.sliderHeight; + left = left >= width ? width : left; + this.startX = pageX + this.lastLeft = left + let deg = 360 / width * left + Number(this.angle) + this.styleChange(left, deg) + }, + touchend(e) { + if (this.isPass || !this.show) return; + let left = this.sliderWidth - this.sliderHeight; + let deg = 360 / left * this.lastLeft + Number(this.angle) + if (this.type == 1) { + if (Math.abs(deg - 360) <= this.errorRange || Math.abs(deg) <= this.errorRange) { + this.styleChange(this.lastLeft, deg) + this.success() + } else { + this.startX = 0; + this.lastLeft = 0; + this.styleChange(0, Number(this.angle)) + this.error() + } + } else { + this.result({ + angle: deg - Number(this.angle) + }) + } + + } + } +} + +// #endif + +// #ifdef APP-PLUS|| MP-WEIXIN || H5 +export default {} +// #endif diff --git a/src/components/thorui/tui-rotate-verify/tui-rotate-verify.vue b/src/components/thorui/tui-rotate-verify/tui-rotate-verify.vue new file mode 100644 index 0000000..190e18b --- /dev/null +++ b/src/components/thorui/tui-rotate-verify/tui-rotate-verify.vue @@ -0,0 +1,441 @@ + + + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-rotate-verify/tui-rotate-verify.wxs b/src/components/thorui/tui-rotate-verify/tui-rotate-verify.wxs new file mode 100644 index 0000000..e7d2b6b --- /dev/null +++ b/src/components/thorui/tui-rotate-verify/tui-rotate-verify.wxs @@ -0,0 +1,150 @@ +var sliderWidth = 200; +var blockWidth = 32; +var errorRange = 5; +var angle = 0; +var disabled = false; +var type = 1; + +function bool(str) { + return str === 'true' || str == true ? true : false +} +function isPC() { + if (typeof navigator !== 'object') return false; + var userAgentInfo = navigator.userAgent; + var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; + var flag = true; + for (var v = 0; v < Agents.length - 1; v++) { + if (userAgentInfo.indexOf(Agents[v]) > 0) { + flag = false; + break; + } + } + return flag; +} +var isH5 = false +if (typeof window === 'object') isH5 = true + + +function touchstart(e, ins) { + var state = e.instance.getState() + var touch = {} + if (isH5 && isPC()) { + touch = e; + } else { + touch = e.touches[0] || e.changedTouches[0] + } + var dataset = e.instance.getDataset() + state.startX = touch.pageX + sliderWidth = +dataset.width + blockWidth = +dataset.height + errorRange = +dataset.errorrange + angle = +dataset.angle + type = +dataset.type + disabled = bool(dataset.disabled) +} + +function styleChange(left, deg, ins) { + if (!ins) return; + var block = ins.selectComponent('.tui-slider_block'); + var image = ins.selectComponent('.tui-verify__image') + if(!block || !image) return; + if (left === 0) { + block.addClass('tui-block__trans') + image.addClass('tui-block__trans') + } else { + block.removeClass('tui-block__trans') + image.removeClass('tui-block__trans') + } + block.setStyle({ + transform: 'translate3d(' + left + 'px,0,0)' + }) + image.setStyle({ + transform: 'rotate(' + deg + 'deg)' + }) +} + +function touchmove(e, ins, event) { + if (disabled) return; + var state = {} + var touch = {} + if (isH5 && isPC()) { + touch = e; + state = event.instance.getState() + } else { + state = e.instance.getState() + touch = e.touches[0] || e.changedTouches[0] + } + var pageX = touch.pageX; + var left = pageX - state.startX + (state.lastLeft || 0); + left = left < 0 ? 0 : left; + var width = sliderWidth - blockWidth; + left = left >= width ? width : left; + state.startX = pageX + state.lastLeft = left + var deg = 360 / width * left + angle + styleChange(left, deg, ins) +} + +function touchend(e, ins, event) { + if (disabled) return; + var state = {} + if (isH5 && isPC()) { + state = event.instance.getState() + } else { + state = e.instance.getState() + } + var left = sliderWidth - blockWidth + var deg = 360 / left * state.lastLeft + angle + if (type == 1) { + if (Math.abs(deg - 360) <= errorRange || Math.abs(deg) <= errorRange) { + styleChange(state.lastLeft, deg, ins) + ins.callMethod('success') + } else { + state.startX = 0; + state.lastLeft = 0; + styleChange(0, angle, ins) + ins.callMethod('error') + } + } else { + ins.callMethod('result', { + angle: deg - angle + }) + } +} + +function slidereset(reset, oldreset, owner, ins) { + var state = ins.getState() + var dataset = ins.getDataset() + if (reset > 0) { + state.startX = 0; + state.lastLeft = 0; + var angle = +dataset.angle + styleChange(0, angle, owner) + } +} + +var movable = false; + +function mousedown(e, ins) { + if (!isH5 || !isPC()) return + touchstart(e, ins) + movable = true + window.onmousemove = function(event) { + if (!isH5 || !isPC() || !movable) return + touchmove(event, ins, e) + } + window.onmouseup = function(event) { + if (!isH5 || !isPC() || !movable) return + touchend(event, ins, e) + movable = false + } +} + + +module.exports = { + touchstart: touchstart, + touchmove: touchmove, + touchend: touchend, + mousedown: mousedown, + slidereset: slidereset +} diff --git a/src/components/thorui/tui-round-progress/tui-round-progress.vue b/src/components/thorui/tui-round-progress/tui-round-progress.vue new file mode 100644 index 0000000..eb18cc5 --- /dev/null +++ b/src/components/thorui/tui-round-progress/tui-round-progress.vue @@ -0,0 +1,309 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-row/tui-row.vue b/src/components/thorui/tui-row/tui-row.vue new file mode 100644 index 0000000..32a7264 --- /dev/null +++ b/src/components/thorui/tui-row/tui-row.vue @@ -0,0 +1,154 @@ + + + + + diff --git a/src/components/thorui/tui-scale-horizontal/tui-scale-horizontal.vue b/src/components/thorui/tui-scale-horizontal/tui-scale-horizontal.vue new file mode 100644 index 0000000..fce1253 --- /dev/null +++ b/src/components/thorui/tui-scale-horizontal/tui-scale-horizontal.vue @@ -0,0 +1,273 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-scale-vertical/tui-scale-vertical.vue b/src/components/thorui/tui-scale-vertical/tui-scale-vertical.vue new file mode 100644 index 0000000..c038e4e --- /dev/null +++ b/src/components/thorui/tui-scale-vertical/tui-scale-vertical.vue @@ -0,0 +1,278 @@ + + + + + diff --git a/src/components/thorui/tui-scroll-top/tui-scroll-top.vue b/src/components/thorui/tui-scroll-top/tui-scroll-top.vue new file mode 100644 index 0000000..b64bd0f --- /dev/null +++ b/src/components/thorui/tui-scroll-top/tui-scroll-top.vue @@ -0,0 +1,179 @@ + + + + + diff --git a/src/components/thorui/tui-searchbar/tui-searchbar.vue b/src/components/thorui/tui-searchbar/tui-searchbar.vue new file mode 100644 index 0000000..5b25983 --- /dev/null +++ b/src/components/thorui/tui-searchbar/tui-searchbar.vue @@ -0,0 +1,287 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-section/tui-section.vue b/src/components/thorui/tui-section/tui-section.vue new file mode 100644 index 0000000..ad928b8 --- /dev/null +++ b/src/components/thorui/tui-section/tui-section.vue @@ -0,0 +1,141 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-segmented-control/tui-segmented-control.vue b/src/components/thorui/tui-segmented-control/tui-segmented-control.vue new file mode 100644 index 0000000..9ad7bb9 --- /dev/null +++ b/src/components/thorui/tui-segmented-control/tui-segmented-control.vue @@ -0,0 +1,140 @@ + + + + + diff --git a/src/components/thorui/tui-select/tui-select.vue b/src/components/thorui/tui-select/tui-select.vue new file mode 100644 index 0000000..f948ab9 --- /dev/null +++ b/src/components/thorui/tui-select/tui-select.vue @@ -0,0 +1,537 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-skeleton/tui-skeleton.vue b/src/components/thorui/tui-skeleton/tui-skeleton.vue new file mode 100644 index 0000000..7040fd6 --- /dev/null +++ b/src/components/thorui/tui-skeleton/tui-skeleton.vue @@ -0,0 +1,263 @@ + + + + + diff --git a/src/components/thorui/tui-slide-verify/index.js b/src/components/thorui/tui-slide-verify/index.js new file mode 100644 index 0000000..3f43b04 --- /dev/null +++ b/src/components/thorui/tui-slide-verify/index.js @@ -0,0 +1,64 @@ +// #ifndef APP-PLUS || MP-WEIXIN || H5 +export default { + data() { + return { + transform: '', + slipOverWidth: 0, + startX: 0, + lastLeft: 0, + resetAni: false + } + }, + watch: { + reset(val) { + this.startX = 0; + this.lastLeft = 0; + this.styleChange(0) + } + }, + methods: { + styleChange(left) { + if (left == 0) { + this.resetAni = true + } else { + this.resetAni = false + } + this.slipOverWidth = left + this.transform = 'translate3d(' + left + 'px,0,0)' + }, + touchstart(e) { + let touch = e.touches[0] || e.changedTouches[0]; + this.startX = touch.clientX + }, + touchmove(e) { + if (this.isPass) return; + let touch = e.touches[0] || e.changedTouches[0] + let pageX = touch.clientX; + let left = pageX - this.startX + this.lastLeft; + left = left < 0 ? 0 : left; + let width = this.slideBarWidth - this.slideBlockWidth; + left = left >= width ? width : left; + this.startX = pageX + this.lastLeft = left + this.styleChange(left) + }, + touchend(e) { + if (this.isPass) return; + let left = this.slideBarWidth - this.slideBlockWidth + if (Math.abs(left - this.lastLeft) <= Number(this.errorRange)) { + // this.styleChange(left) + this.success() + } else { + this.startX = 0; + this.lastLeft = 0; + this.styleChange(0) + } + } + } +} + +// #endif + +// #ifdef APP-PLUS|| MP-WEIXIN || H5 +export default {} +// #endif diff --git a/src/components/thorui/tui-slide-verify/tui-slide-verify.vue b/src/components/thorui/tui-slide-verify/tui-slide-verify.vue new file mode 100644 index 0000000..ddf441c --- /dev/null +++ b/src/components/thorui/tui-slide-verify/tui-slide-verify.vue @@ -0,0 +1,272 @@ + + + + + + + diff --git a/src/components/thorui/tui-slide-verify/tui-slide-verify.wxs b/src/components/thorui/tui-slide-verify/tui-slide-verify.wxs new file mode 100644 index 0000000..6bfe7c7 --- /dev/null +++ b/src/components/thorui/tui-slide-verify/tui-slide-verify.wxs @@ -0,0 +1,134 @@ +var slideBarWidth = 200; +var slideBlockWidth = 32; +var errorRange = 2 +var disabled = false + +function bool(str) { + return str === 'true' || str == true ? true : false +} + +function isPC() { + if (typeof navigator !== 'object') return false; + var userAgentInfo = navigator.userAgent; + var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; + var flag = true; + for (var v = 0; v < Agents.length - 1; v++) { + if (userAgentInfo.indexOf(Agents[v]) > 0) { + flag = false; + break; + } + } + return flag; +} +var isH5 = false +if (typeof window === 'object') isH5 = true + + +function touchstart(e, ins) { + var state = e.instance.getState() + var touch = {} + if (isH5 && isPC()) { + touch = e; + } else { + touch = e.touches[0] || e.changedTouches[0] + } + var dataset = e.instance.getDataset() + state.startX = touch.pageX + slideBarWidth = +dataset.slidebarwidth + slideBlockWidth = +dataset.slideblockwidth + errorRange = +dataset.errorrange + disabled = bool(dataset.disabled) +} + +function styleChange(left, ins) { + if (!ins) return; + var tsb = ins.selectComponent('.tui-slider-block') + var tsg = ins.selectComponent('.tui-slide-glided') + if (!tsb || !tsg) return; + if (left == 0) { + tsb.addClass('tui-slider__reset') + tsg.addClass('tui-slider__reset') + } else { + tsb.removeClass('tui-slider__reset') + tsg.removeClass('tui-slider__reset') + } + tsb.setStyle({ + transform: 'translate3d(' + left + 'px,0,0)' + }) + tsg.setStyle({ + width: left + 'px' + }) +} + +function touchmove(e, ins, event) { + if (disabled) return; + var state = {} + var touch = {} + if (isH5 && isPC()) { + touch = e; + state = event.instance.getState() + } else { + state = e.instance.getState() + touch = e.touches[0] || e.changedTouches[0] + } + var pageX = touch.pageX; + var left = pageX - state.startX + (state.lastLeft || 0); + left = left < 0 ? 0 : left; + var width = slideBarWidth - slideBlockWidth; + left = left >= width ? width : left; + state.startX = pageX + state.lastLeft = left + styleChange(left, ins) +} + +function touchend(e, ins, event) { + if (disabled) return; + var state = {} + if (isH5 && isPC()) { + state = event.instance.getState() + } else { + state = e.instance.getState() + } + var left = slideBarWidth - slideBlockWidth + if (left - state.lastLeft <= errorRange) { + styleChange(left, ins) + ins.callMethod('success') + } else { + state.startX = 0; + state.lastLeft = 0; + styleChange(0, ins) + } +} + +function slidereset(reset, oldreset, owner, ins) { + var state = ins.getState() + if (reset > 0) { + state.startX = 0; + state.lastLeft = 0; + styleChange(0, owner) + } +} +var movable = false; + +function mousedown(e, ins) { + if (!isH5 || !isPC()) return + touchstart(e, ins) + movable = true + window.onmousemove = function(event) { + if (!isH5 || !isPC() || !movable) return + touchmove(event, ins, e) + } + window.onmouseup = function(event) { + if (!isH5 || !isPC() || !movable) return + touchend(event, ins, e) + movable = false + } +} + +module.exports = { + touchstart: touchstart, + touchmove: touchmove, + touchend: touchend, + mousedown: mousedown, + slidereset: slidereset +} \ No newline at end of file diff --git a/src/components/thorui/tui-slide-view/tui-slide-view.js b/src/components/thorui/tui-slide-view/tui-slide-view.js new file mode 100644 index 0000000..2945652 --- /dev/null +++ b/src/components/thorui/tui-slide-view/tui-slide-view.js @@ -0,0 +1,173 @@ +// #ifndef APP-PLUS|| MP-WEIXIN || H5 + +const MIN_DISTANCE = 10; +export default { + data() { + return { + left: 0, + isShow: false, + ani: false, + moveLeft: '', + moveRight: '', + threshold: 30, + open: false, + rightWidth: 0 + } + }, + watch: { + shown(newVal) { + this.openState(newVal) + }, + left() { + this.moveLeft = `translateX(${this.left}px)` + this.moveRight = `translateX(${this.left+this.rightWidth}px)` + }, + isShow(newVal) { + this.openState(newVal) + }, + buttons() { + this.init() + } + }, + mounted() { + this.$nextTick(() => { + this.init() + }) + }, + methods: { + init() { + clearTimeout(this.timer) + this.timer = setTimeout(() => { + this.getSelectorQuery() + }, 100) + this.left = 0 + this.x = 0 + }, + closeSwipe(e) { + if (!this.autoClose) return + this.left = 0; + }, + touchstart(e) { + if (this.disabled) return + this.ani = false + this.x = this.left || 0 + this.stopTouchStart(e) + // this.autoClose && this.closeSwipe() + }, + touchmove(e) { + if (this.disabled) return + // 是否可以滑动页面 + this.stopTouchMove(e); + if (this.direction !== 'horizontal') { + return; + } + this.move(this.x + this.deltaX) + return false + }, + touchend() { + if (this.disabled) return + this.moveDirection(this.left) + }, + move(value) { + value = value || 0 + const rightWidth = this.rightWidth + this.left = Math.min(Math.max(value, -rightWidth), 0); + }, + moveDirection(left) { + const threshold = this.threshold + const open = this.open || false + const rightWidth = this.rightWidth + if (this.deltaX === 0 || left > 0) { + this.openState(false) + return + } + if ((!open && rightWidth > 0 && -left > threshold) || (open && rightWidth > 0 && rightWidth + left < + threshold)) { + this.openState(true) + } else { + this.openState(false) + } + }, + openState(type) { + const rightWidth = this.rightWidth + let left = '' + this.open = this.open ? this.open : false + if (type) { + left = -rightWidth + } else { + left = 0 + } + if (type) { + this.showButton() + } else { + this.hideButton() + } + this.open = type + // 添加动画类 + this.ani = true + this.$nextTick(() => { + this.move(left) + }) + }, + close() { + this.openState(false) + }, + getDirection(x, y) { + if (x > y && x > MIN_DISTANCE) { + return 'horizontal'; + } + if (y > x && y > MIN_DISTANCE) { + return 'vertical'; + } + return ''; + }, + resetTouchStatus() { + this.direction = ''; + this.deltaX = 0; + this.deltaY = 0; + this.offsetX = 0; + this.offsetY = 0; + }, + stopTouchStart(event) { + this.resetTouchStatus(); + const touch = event.touches[0]; + this.startX = touch.clientX; + this.startY = touch.clientY; + }, + stopTouchMove(event) { + const touch = event.touches[0]; + this.deltaX = touch.clientX - this.startX; + this.deltaY = touch.clientY - this.startY; + this.offsetX = Math.abs(this.deltaX); + this.offsetY = Math.abs(this.deltaY); + this.direction = this.direction || this.getDirection(this.offsetX, this.offsetY); + }, + + getSelectorQuery() { + uni.createSelectorQuery() + // #ifndef MP-ALIPAY + .in(this) + // #endif + .select('.' + this.elClass) + .boundingClientRect(data => { + if (data.length === 0) return + this.rightWidth = data.width || 0 + this.isShow = this.shown + }) + .exec() + }, + onBtnClick(index, data) { + this.closeSwipe() + this.buttonTapByWxs({ + index: index, + data: data + }) + } + } +} + +// #endif + +// #ifdef APP-PLUS|| MP-WEIXIN || H5 +export default {} +// #endif \ No newline at end of file diff --git a/src/components/thorui/tui-slide-view/tui-slide-view.vue b/src/components/thorui/tui-slide-view/tui-slide-view.vue new file mode 100644 index 0000000..72e892a --- /dev/null +++ b/src/components/thorui/tui-slide-view/tui-slide-view.vue @@ -0,0 +1,302 @@ + + + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-slide-view/tui-slide-view.wxs b/src/components/thorui/tui-slide-view/tui-slide-view.wxs new file mode 100644 index 0000000..28545a8 --- /dev/null +++ b/src/components/thorui/tui-slide-view/tui-slide-view.wxs @@ -0,0 +1,288 @@ +var touchstart = function(event, ownerInstance) { + var ins = event.instance + var st = ins.getState() + if (st.disable) return // disable的逻辑 + if (!st.size) return + var touches = event.touches + if (touches && touches.length > 1) return + st.isMoving = true + touches = event.touches ? event.touches[0] : {}; + if (!touches || (touches.pageX === undefined && touches.pageY === undefined)) { + touches = { + pageX: event.pageX, + pageY: event.pageY + }; + } + st.startX = touches.pageX + st.startY = touches.pageY + st.firstAngle = 0 +} +var touchmove = function(event, ownerInstance) { + var ins = event.instance + var st = ins.getState() + if (!st.size || !st.isMoving) return + // console.log('touchmove', JSON.stringify(event)) + var touches = event.touches ? event.touches[0] : {}; + if (!touches || (touches.pageX === undefined && touches.pageY === undefined)) { + touches = { + pageX: event.pageX, + pageY: event.pageY + }; + } + var pagex = touches.pageX - st.startX + var pagey = touches.pageY - st.startY + // 左侧45度角为界限,大于45度则允许水平滑动 + if (st.firstAngle === 0) { + st.firstAngle = Math.abs(pagex) - Math.abs(pagey) + } + if (st.firstAngle < 0) { + return + } + var movex = pagex > 0 ? Math.min(st.max, pagex) : Math.max(-st.max, pagex) + // 往回滑动的情况 + if (st.out) { + // 已经是划出来了,还要往左滑动,忽略 + if (movex < 0) return + ins.setStyle({ + 'transition': '', + 'transform': 'translateX(' + (st.transformx + movex) + 'px)' + }) + var btns = ownerInstance.selectAllComponents('.tui_wxs_btn') + var transformTotal = 0 + var len = btns.length + var i = len - 1; + for (; i >= 0; i--) { + var transform = st.size.buttons[i].width / st.max * movex + var transformx = st.size.buttons[i].max - Math.min(st.size.buttons[i].max, transform + transformTotal) + btns[i].setStyle({ + 'transition': '', + 'transform': 'translateX(' + (-transformx) + 'px)' + }) + transformTotal += transform + } + return false + } + if (movex > 0) movex = 0 + ins.setStyle({ + 'transition': '', + 'transform': 'translateX(' + movex + 'px)' + }) + st.transformx = movex + var btns = ownerInstance.selectAllComponents('.tui_wxs_btn') + var transformTotal = 0 + var len = btns.length + var i = len - 1; + for (; i >= 0; i--) { + var transform = st.size.buttons[i].width / st.max * movex + var transformx = Math.max(-st.size.buttons[i].max, transform + transformTotal) + btns[i].setStyle({ + 'transition': '', + 'transform': 'translateX(' + transformx + 'px)' + }) + st.size.buttons[i].transformx = transformx + transformTotal += transform + } + return false // 禁止垂直方向的滑动 +} +var touchend = function(event, ownerInstance) { + var ins = event.instance + var st = ins.getState() + if (!st.size || !st.isMoving) return + // 左侧45度角为界限,大于45度则允许水平滑动 + if (st.firstAngle < 0) { + return + } + var duration = st.duration / 1000 + st.isMoving = false + // console.log('touchend', JSON.stringify(event)) + var btns = ownerInstance.selectAllComponents('.tui_wxs_btn') + var len = btns.length + var i = len - 1 + // console.log('len size', len) + var touches = event.changedTouches ? event.changedTouches[0] : {}; + if (!touches || (touches.pageX === undefined && touches.pageY === undefined)) { + touches = { + pageX: event.pageX, + pageY: event.pageY + }; + } + if (Math.abs(touches.pageX - st.startX) < st.throttle || touches.pageX - st.startX > + 0) { // 方向也要控制 + st.out = false + ins.setStyle({ + 'transition': 'transform ' + (duration) + 's', + 'transform': 'translate3d(0px, 0, 0)' + + }) + for (; i >= 0; i--) { + btns[i].setStyle({ + 'transition': 'transform ' + (duration) + 's', + 'transform': 'translate3d(0px, 0, 0)' + + }) + } + ownerInstance.callMethod('hideButton') + return + } + showButtons(ins, ownerInstance, duration) + ownerInstance.callMethod('showButton') +} +var REBOUNCE_TIME = 0.2 +var showButtons = function(ins, ownerInstance, withDuration) { + if (!ins || !ins.getState) return; + if (withDuration > 100) { + withDuration = withDuration / 1000 + } + var st = ins.getState() + if (!st.size) return + var rebounceTime = st.rebounce ? REBOUNCE_TIME : 0 + var movex = st.max + st.out = true + var btns = ownerInstance.selectAllComponents('.tui_wxs_btn') || [] + var rebounce = st.rebounce || 0 + var len = btns.length + var i = len - 1 + ins.setStyle({ + 'transition': 'transform ' + (withDuration) + 's', + 'transform': 'translate3d(' + (-movex - rebounce) + 'px, 0, 0)' + }) + st.transformx = -movex + var transformTotal = 0 + if (!btns || btns.length === 0) return; + for (; i >= 0; i--) { + var transform = st.size.buttons[i].width / st.max * movex + var transformx = (-(transform + transformTotal)) + btns[i].setStyle({ + 'transition': 'transform ' + (withDuration ? withDuration + rebounceTime : withDuration) + 's', + 'transform': 'translate3d(' + transformx + 'px, 0, 0)' + + }) + st.size.buttons[i].transformx = transformx + transformTotal += transform + } +} +var innerHideButton = function(ownerInstance) { + var ins = ownerInstance.selectComponent('.tui_wxs_left') + if (!ins) return; + var st = ins.getState() + if (!st.size) return + var duration = st.duration ? st.duration / 1000 : 0 + var btns = ownerInstance.selectAllComponents('.tui_wxs_btn') + var len = btns.length + var i = len - 1 + ins.setStyle({ + 'transition': 'transform ' + (duration) + 's', + 'transform': 'translate3d(0px, 0, 0)' + }) + st.transformx = 0 + for (; i >= 0; i--) { + btns[i].setStyle({ + 'transition': 'transform ' + (duration) + 's', + 'transform': 'translate3d(0px, 0, 0)' + }) + st.size.buttons[i].transformx = 0 + } + st.out = false +} +var hideButton = function(event, ownerInstance) { + var dataset = event.currentTarget.dataset; + if (dataset.isclose == 1) { + innerHideButton(ownerInstance) + } + ownerInstance.callMethod('buttonTapByWxs', { + index: dataset.index, + data: dataset.data + }) + return false +} +var sizeReady = function(newVal, oldVal, ownerInstance, ins) { + var st = ins.getState() + // console.log(newVal) + st.disable = newVal && newVal.disable + st.duration = newVal && newVal.duration + if (newVal && newVal.button && newVal.buttons) { + st.size = newVal + st.transformx = 0 + // var min = newVal.button.width + var max = 0 + var len = newVal.buttons.length + var i = newVal.buttons.length - 1; + var total = 0 + for (; i >= 0; i--) { + max += newVal.buttons[i].width + // if (min > newVal.buttons[i]) { + // min = newVal.buttons[i].width + // } + total += newVal.buttons[i].width + newVal.buttons[i].max = total + newVal.buttons[i].transformx = 0 + } + st.throttle = st.size.throttle || 40 // 固定值 + st.rebounce = st.size.rebounce + st.max = max + var twr = ownerInstance.selectComponent('.tui_wxs_right') + if (twr) { + twr.setStyle({ + 'line-height': newVal.button.height + 'px', + left: (newVal.button.width) + 'px', + width: max + 'px' + }) + } + // console.log('st size', JSON.stringify(newVal)) + if (!st.size.disable && st.size.show) { + showButtons(ins, ownerInstance) + } + } +} +var disableChange = function(newVal, oldVal, ownerInstance, ins) { + if (!ins || !ins.getState) return; + var st = ins.getState() + st.disable = newVal +} +var durationChange = function(newVal, oldVal, ownerInstance, ins) { + if (!ins || !ins.getState) return; + var st = ins.getState() + st.duration = newVal || 350 +} +var showChange = function(newVal, oldVal, ownerInstance, ins) { + if (!ins || !ins.getState) return; + var st = ins.getState() + st.show = newVal + if (st.disable) return + if (st.show) { + showButtons(ins, ownerInstance, st.duration) + } else { + innerHideButton(ownerInstance) + } +} +var rebounceChange = function(newVal, oldVal, ownerInstance, ins) { + if (!ins || !ins.getState) return; + var st = ins.getState() + // console.log('rebounce', st.rebounce) + st.rebounce = newVal +} +var transitionEnd = function(event, ownerInstance) { + // console.log('transition') + var ins = event.instance + var st = ins.getState() + // 回弹效果 + if (st.out && st.rebounce) { + // console.log('transition rebounce', st.rebounce) + ins.setStyle({ + 'transition': 'transform ' + REBOUNCE_TIME + 's', + 'transform': 'translate3d(' + (-st.max) + 'px, 0, 0)' + }) + } +} +module.exports = { + touchstart: touchstart, + touchmove: touchmove, + touchend: touchend, + hideButton: hideButton, + sizeReady: sizeReady, + disableChange: disableChange, + durationChange: durationChange, + showChange: showChange, + rebounceChange: rebounceChange, + transitionEnd: transitionEnd +} \ No newline at end of file diff --git a/src/components/thorui/tui-slider/index.js b/src/components/thorui/tui-slider/index.js new file mode 100644 index 0000000..0032b3d --- /dev/null +++ b/src/components/thorui/tui-slider/index.js @@ -0,0 +1,168 @@ +// #ifndef APP-PLUS || MP-WEIXIN || H5 + +export default { + watch: { + value(val) { + this.initData(val) + }, + endValue(val) { + if (this.section) { + this.initEndData(val) + } + } + }, + data() { + return { + drag: false, + startX: 0, + endX: 0, + lastLeft: 0, + useLast: 0, + lastRight: 0, + useRight: 0, + moveLeft: 'translate3d(0,0,0)', + transLeft: 'translate3d(-100%, 0, 0)', + moveRight: 'translate3d(0,0,0)', + transRight: 'translate3d(100%, 0, 0)', + isRight: false + } + }, + mounted() { + this.initData(this.value) + if (this.section) { + this.initEndData(this.endValue) + } + }, + methods: { + initData(value) { + this.startX = 0; + this.lastLeft = 0; + this.drag = false; + this.styleChange(Number(value), true) + }, + initEndData(value) { + this.endX = 0; + this.lastRight = 0; + this.drag = false; + value = Number(this.max) - Number(value) + Number(this.min) + this.styleSectionChange(value, true) + }, + format(value) { + value = Number(value) + let step = Number(this.step) + return Math.round(Math.max(Number(this.min), Math.min(value, Number(this.max))) / step) * step; + }, + touchstart(e) { + let touch = e.changedTouches[0] || e.touches[0]; + this.startX = touch.clientX + }, + endTouchstart(e) { + let touch = e.changedTouches[0] || e.touches[0]; + this.endX = touch.clientX + }, + changeValue(value, isStart, isEnd) { + var params = { + value: value, + isStart: isStart + } + if (isEnd) { + this.change(params) + } else { + this.changing(params) + } + }, + styleChange(value, isEnd) { + value = this.format(value); + if (this.section) { + value = value > this.end ? this.end : value; + } + this.changeValue(value, true, isEnd) + const min = Number(this.min) + const max = Number(this.max) + var dvalue = max - min; + var maxWidth = Number(this.width) - Number(this.blockWidth); + var width = (value - min) / dvalue * maxWidth; + this.lastLeft = width + if (isEnd) { + this.useLast = width + } + this.transLeft = `translate3d(-${Number(this.width)-width}px,0,0)` + this.moveLeft = `translate3d(${width}px,0,0)` + this.isRight = value === max + }, + styleSectionChange(value, isEnd) { + value = this.format(value); + const min = Number(this.min) + const max = Number(this.max) + var total = max + min; + var val = total - value; + val = val < this.start ? this.start : val; + value = total - val; + this.changeValue(val, false, isEnd) + var dvalue = max - min; + var maxWidth = Number(this.width) - Number(this.blockWidth); + var width = (value - min) / dvalue * maxWidth; + this.lastRight = width + if (isEnd) { + this.useRight = width + } + this.transRight = `translate3d(${Number(this.width)-width}px,0,0)` + this.moveRight = `translate3d(-${width}px,0,0)` + }, + touchmove(e) { + if (this.disabled) return; + let touch = e.changedTouches[0] || e.touches[0]; + let pageX = touch.clientX + let left = pageX - this.startX + (this.useLast || 0); + this.drag = true + left = left < 0 ? 0 : left; + let maxWidth = Number(this.width) - Number(this.blockWidth); + left = left >= maxWidth ? maxWidth : left; + let dvalue = Number(this.max) - Number(this.min); + let value = (left / maxWidth) * dvalue + Number(this.min); + this.lastLeft = left + this.styleChange(value, false) + }, + endTouchmove(e) { + if (this.disabled) return; + let touch = e.changedTouches[0] || e.touches[0]; + let pageX = touch.clientX; + this.drag = true + let left = this.endX - pageX + (this.useRight || 0); + left = left < 0 ? 0 : left; + let maxWidth = Number(this.width) - Number(this.blockWidth); + left = left >= maxWidth ? maxWidth : left; + let dvalue = Number(this.max) - Number(this.min); + let value = (left / maxWidth) * dvalue + Number(this.min); + // this.endX = pageX + this.lastRight = left + this.styleSectionChange(value, false) + }, + touchend(e) { + if (this.disabled) return; + if (this.drag) { + let maxWidth = Number(this.width) - Number(this.blockWidth); + let dvalue = Number(this.max) - Number(this.min); + let value = (this.lastLeft / maxWidth) * dvalue + Number(this.min); + this.styleChange(value, true) + this.drag = false + } + }, + endTouchend(e) { + if (this.disabled) return; + if (this.drag) { + let maxWidth = Number(this.width) - Number(this.blockWidth); + let dvalue = Number(this.max) - Number(this.min); + let value = (this.lastRight / maxWidth) * dvalue + Number(this.min); + this.styleSectionChange(value, true) + this.drag = false + } + } + } +} + +// #endif + +// #ifdef APP-PLUS|| MP-WEIXIN || H5 +export default {} +// #endif diff --git a/src/components/thorui/tui-slider/tui-slider.vue b/src/components/thorui/tui-slider/tui-slider.vue new file mode 100644 index 0000000..a4936f8 --- /dev/null +++ b/src/components/thorui/tui-slider/tui-slider.vue @@ -0,0 +1,459 @@ + + + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-slider/tui-slider.wxs b/src/components/thorui/tui-slider/tui-slider.wxs new file mode 100644 index 0000000..a926c3f --- /dev/null +++ b/src/components/thorui/tui-slider/tui-slider.wxs @@ -0,0 +1,290 @@ +var sliderObj = { + width: 280, + blockWidth: 20, + step: 1, + min: 0, + max: 100, + disabled: false, + section: false, + start: 0, + end: 0, + drag: false +} + +function bool(str) { + return str === 'true' || str == true ? true : false +} + +function format(value) { + return Math.round(Math.max(sliderObj.min, Math.min(value, sliderObj.max)) / sliderObj.step) * sliderObj.step; +} +function isPC() { + if (typeof navigator !== 'object') return false; + var userAgentInfo = navigator.userAgent; + var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; + var flag = true; + for (var v = 0; v < Agents.length - 1; v++) { + if (userAgentInfo.indexOf(Agents[v]) > 0) { + flag = false; + break; + } + } + return flag; +} +var isH5 = false +if (typeof window === 'object') isH5 = true + + +function setInitValue(dataset, isChange) { + sliderObj.drag = false + sliderObj.width = +dataset.width + sliderObj.blockWidth = +dataset.blockwidth + sliderObj.step = +dataset.step + sliderObj.min = +dataset.min || 0 + sliderObj.max = +dataset.max + sliderObj.disabled = bool(dataset.disabled) + sliderObj.section = bool(dataset.section) + sliderObj.start = format(+dataset.value) || 0 + sliderObj.end = format(+dataset.endvalue) +} + +function touchstart(e, ins) { + var state = e.instance.getState() + var touch = e.touches[0] || e.changedTouches[0] + if (isH5 && isPC()) { + touch = e; + } + var dataset = e.instance.getDataset() + state.startX = touch.pageX + setInitValue(dataset) +} + +function sectionTouchstart(e, ins) { + var state = e.instance.getState() + var touch = e.touches[0] || e.changedTouches[0] + if (isH5 && isPC()) { + touch = e; + } + var dataset = e.instance.getDataset() + state.sectionStartX = touch.pageX + setInitValue(dataset) +} + +function changeValue(value, isStart, isEnd, ins) { + var params = { + value: value, + isStart: isStart + } + if (isEnd) { + ins.callMethod('change', params) + } else { + ins.callMethod('changing', params) + } +} + +function styleChange(value, ins, isEnd, state) { + if (!ins) return; + value = format(value); + if (sliderObj.section) { + value = value > sliderObj.end ? sliderObj.end : value; + } + changeValue(value, true, isEnd, ins) + var dvalue = sliderObj.max - sliderObj.min; + var maxWidth = sliderObj.width - sliderObj.blockWidth; + var width = (value - sliderObj.min) / dvalue * maxWidth; + var block = ins.selectComponent('.tui-slider__block'); + var glided = ins.selectComponent('.tui-slider__glided'); + if (!block || !glided) return; + if (state) { + state.lastLeft = width + } + block.setStyle({ + transform: 'translate3d(' + width + 'px,0,0)', + 'z-index': value === sliderObj.max ? 3 : 2 + }) + glided.setStyle({ + width: width + 'px' + }) +} + +function styleSectionChange(value, ins, isEnd, state) { + if (!ins) return; + value = format(value); + var total = sliderObj.max + sliderObj.min; + var val = total - value; + val = val < sliderObj.start ? sliderObj.start : val; + value = total - val; + changeValue(val, false, isEnd, ins) + var dvalue = sliderObj.max - sliderObj.min; + var maxWidth = sliderObj.width - sliderObj.blockWidth; + var width = (value - sliderObj.min) / dvalue * maxWidth; + var block = ins.selectComponent('.tui-section__block'); + var glided = ins.selectComponent('.tui-section__glided'); + if (state) { + state.lastSectionLeft = width + } + if(!block || !glided) return; + block.setStyle({ + transform: 'translate3d(-' + width + 'px,0,0)' + }) + glided.setStyle({ + width: width + 'px' + }) +} + +function touchmove(e, ins, event) { + if (sliderObj.disabled) return; + if (e.preventDefault) { + // 阻止页面滚动 + e.preventDefault() + } + var state = {} + var touch = {} + if (isH5 && isPC()) { + touch = e; + state = event.instance.getState() + } else { + touch = e.touches[0] || e.changedTouches[0] + state = e.instance.getState() + } + var pageX = touch.pageX; + sliderObj.drag = true + var left = pageX - state.startX + (state.lastLeft || 0); + left = left < 0 ? 0 : left; + var maxWidth = sliderObj.width - sliderObj.blockWidth; + left = left >= maxWidth ? maxWidth : left; + var dvalue = sliderObj.max - sliderObj.min; + var value = (left / maxWidth) * dvalue + sliderObj.min; + state.startX = pageX + state.lastLeft = left + styleChange(value, ins, false) +} + +function sectionTouchmove(e, ins, event) { + if (sliderObj.disabled) return; + if (e.preventDefault) { + // 阻止页面滚动 + e.preventDefault() + } + var state = {} + var touch = {} + if (isH5 && isPC()) { + touch = e; + state = event.instance.getState() + } else { + touch = e.touches[0] || e.changedTouches[0] + state = e.instance.getState() + } + var pageX = touch.pageX; + sliderObj.drag = true + var left = state.sectionStartX - pageX + (state.lastSectionLeft || 0); + left = left < 0 ? 0 : left; + var maxWidth = sliderObj.width - sliderObj.blockWidth; + left = left >= maxWidth ? maxWidth : left; + var dvalue = sliderObj.max - sliderObj.min; + var value = (left / maxWidth) * dvalue + sliderObj.min; + state.sectionStartX = pageX + state.lastSectionLeft = left + styleSectionChange(value, ins, false) +} + +function touchend(e, ins, event) { + if (sliderObj.disabled) return; + if (sliderObj.drag) { + var state = {} + if (isH5 && isPC()) { + state = event.instance.getState() + } else { + state = e.instance.getState() + } + var maxWidth = sliderObj.width - sliderObj.blockWidth; + var dvalue = sliderObj.max - sliderObj.min; + var value = (state.lastLeft / maxWidth) * dvalue + sliderObj.min; + styleChange(value, ins, true, state) + } +} + + + +function sectionTouchend(e, ins, event) { + if (sliderObj.disabled) return; + if (sliderObj.drag) { + var state = {} + if (isH5 && isPC()) { + state = event.instance.getState() + } else { + state = e.instance.getState() + } + var maxWidth = sliderObj.width - sliderObj.blockWidth; + var dvalue = sliderObj.max - sliderObj.min; + var value = (state.lastSectionLeft / maxWidth) * dvalue + sliderObj.min; + styleSectionChange(value, ins, true, state) + } +} + +function slidevalue(value, oldValue, owner, ins) { + var state = ins.getState() + state.startX = 0; + state.lastLeft = 0; + var dataset = ins.getDataset() + setInitValue(dataset) + styleChange(value, owner, true, state) +} + + +function sectionSlidevalue(value, oldValue, owner, ins) { + var state = ins.getState() + state.sectionStartX = 0; + state.lastSectionLeft = 0; + var dataset = ins.getDataset() + setInitValue(dataset) + value = sliderObj.max - value + sliderObj.min + styleSectionChange(value, owner, true, state) +} + +var movable = false; + +function mousedown(e, ins) { + if (!isH5 || !isPC()) return + touchstart(e, ins) + movable = true + window.onmousemove = function(event) { + if (!isH5 || !isPC() || !movable) return + touchmove(event, ins, e) + } + window.onmouseup = function(event) { + if (!isH5 || !isPC() || !movable) return + touchend(event, ins, e) + movable = false + } +} + +var endMovable = false; + +function endMousedown(e, ins) { + if (!isH5 || !isPC()) return + sectionTouchstart(e, ins) + endMovable = true + window.onmousemove = function(event) { + if (!isH5 || !isPC() || !endMovable) return + sectionTouchmove(event, ins, e) + } + window.onmouseup = function(event) { + if (!isH5 || !isPC()) return + sectionTouchend(event, ins, e) + endMovable = false + } +} + +module.exports = { + touchstart: touchstart, + touchmove: touchmove, + touchend: touchend, + mousedown: mousedown, + slidevalue: slidevalue, + sectionTouchstart: sectionTouchstart, + sectionTouchmove: sectionTouchmove, + sectionTouchend: sectionTouchend, + endMousedown: endMousedown, + sectionSlidevalue: sectionSlidevalue +} diff --git a/src/components/thorui/tui-status-bar/tui-status-bar.vue b/src/components/thorui/tui-status-bar/tui-status-bar.vue new file mode 100644 index 0000000..9e4ff5b --- /dev/null +++ b/src/components/thorui/tui-status-bar/tui-status-bar.vue @@ -0,0 +1,58 @@ + + + + + diff --git a/src/components/thorui/tui-steps/tui-steps.vue b/src/components/thorui/tui-steps/tui-steps.vue new file mode 100644 index 0000000..b68c8c7 --- /dev/null +++ b/src/components/thorui/tui-steps/tui-steps.vue @@ -0,0 +1,270 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-sticky-wxs/tui-sticky-wxs.vue b/src/components/thorui/tui-sticky-wxs/tui-sticky-wxs.vue new file mode 100644 index 0000000..eb7bd01 --- /dev/null +++ b/src/components/thorui/tui-sticky-wxs/tui-sticky-wxs.vue @@ -0,0 +1,128 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-sticky-wxs/tui-sticky.wxs b/src/components/thorui/tui-sticky-wxs/tui-sticky.wxs new file mode 100644 index 0000000..0d8d41b --- /dev/null +++ b/src/components/thorui/tui-sticky-wxs/tui-sticky.wxs @@ -0,0 +1,47 @@ +var isH5 = false; +if (typeof window === 'object') isH5 = true; +var stickyChange = function(scrollTop, oldScrollTop, ownerInstance, ins) { + if (!oldScrollTop && scrollTop === 0) return false; + var dataset = ins.getDataset() + var top = +dataset.top; + var height = +dataset.height; + var stickyTop = +dataset.stickytop; + var isNativeHeader = dataset.isnativeheader; + var isFixed = false; + var distance = stickyTop + if (isNativeHeader && isH5) { + distance = distance - 44 + distance = distance < 0 ? 0 : distance + } + if (dataset.container) { + isFixed = (scrollTop + distance >= top && scrollTop + distance < top + height) ? true : false + } else { + isFixed = scrollTop + distance >= top ? true : false + } + var tsb = ownerInstance.selectComponent('.tui-sticky-bar') + var tss = ownerInstance.selectComponent('.tui-sticky-seat') + if (!tsb || !tss) return; + if (isFixed) { + tsb.setStyle({ + "top": stickyTop + 'px' + }).addClass('tui-sticky-fixed') + tss.setStyle({ + "display": 'block' + }) + } else { + tsb.setStyle({ + "top": 'auto' + }).removeClass('tui-sticky-fixed') + tss.setStyle({ + "display": 'none' + }) + } + ownerInstance.triggerEvent("sticky", [{ + isFixed: isFixed, + index: parseInt(dataset.index) + }]) +} + +module.exports = { + stickyChange: stickyChange +} \ No newline at end of file diff --git a/src/components/thorui/tui-sticky/tui-sticky.vue b/src/components/thorui/tui-sticky/tui-sticky.vue new file mode 100644 index 0000000..050047f --- /dev/null +++ b/src/components/thorui/tui-sticky/tui-sticky.vue @@ -0,0 +1,166 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-sticky/tui-sticky.wxs b/src/components/thorui/tui-sticky/tui-sticky.wxs new file mode 100644 index 0000000..d2d0b92 --- /dev/null +++ b/src/components/thorui/tui-sticky/tui-sticky.wxs @@ -0,0 +1,47 @@ +var stickyChange = function(scrollTop, oldScrollTop, ownerInstance, ins) { + if (!oldScrollTop) return false; + var dataset = ins.getDataset() + var top = +dataset.top; + var height = +dataset.height; + var stickyTop = +dataset.stickytop; + var isNativeHeader = dataset.isnativeheader; + var isFixed = false; + var distance = stickyTop + // #ifdef H5 + if (isNativeHeader) { + distance = distance - 44 + distance = distance < 0 ? 0 : distance + } + // #endif + if (dataset.container) { + isFixed = (scrollTop + distance >= top && scrollTop + distance < top + height) ? true : false + } else { + isFixed = scrollTop + distance >= top ? true : false + } + var tsb = ownerInstance.selectComponent('.tui-sticky-bar') + var tss = ownerInstance.selectComponent('.tui-sticky-seat') + if (!tsb || !tss) return; + if (isFixed) { + tsb.setStyle({ + "top": stickyTop + 'px' + }).addClass('tui-sticky-fixed') + tss.setStyle({ + "display": 'block' + }) + } else { + tsb.setStyle({ + "top": 'auto' + }).removeClass('tui-sticky-fixed') + tss.setStyle({ + "display": 'none' + }) + } + ownerInstance.triggerEvent("sticky", { + isFixed: isFixed, + index: parseInt(dataset.index) + }) +} + +module.exports = { + stickyChange: stickyChange +} diff --git a/src/components/thorui/tui-swipe-action/tui-swipe-action.vue b/src/components/thorui/tui-swipe-action/tui-swipe-action.vue new file mode 100644 index 0000000..7f58b19 --- /dev/null +++ b/src/components/thorui/tui-swipe-action/tui-swipe-action.vue @@ -0,0 +1,330 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-swiper-dot/tui-swiper-dot.vue b/src/components/thorui/tui-swiper-dot/tui-swiper-dot.vue new file mode 100644 index 0000000..69c3f2f --- /dev/null +++ b/src/components/thorui/tui-swiper-dot/tui-swiper-dot.vue @@ -0,0 +1,158 @@ + + + + + diff --git a/src/components/thorui/tui-switch/tui-switch.vue b/src/components/thorui/tui-switch/tui-switch.vue new file mode 100644 index 0000000..9c30764 --- /dev/null +++ b/src/components/thorui/tui-switch/tui-switch.vue @@ -0,0 +1,231 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-tab/tui-tab.vue b/src/components/thorui/tui-tab/tui-tab.vue new file mode 100644 index 0000000..c9601fd --- /dev/null +++ b/src/components/thorui/tui-tab/tui-tab.vue @@ -0,0 +1,401 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-tabbar/tui-tabbar.vue b/src/components/thorui/tui-tabbar/tui-tabbar.vue new file mode 100644 index 0000000..f9b9a2d --- /dev/null +++ b/src/components/thorui/tui-tabbar/tui-tabbar.vue @@ -0,0 +1,317 @@ + + + + + diff --git a/src/components/thorui/tui-table/tui-table.vue b/src/components/thorui/tui-table/tui-table.vue new file mode 100644 index 0000000..d5cdd86 --- /dev/null +++ b/src/components/thorui/tui-table/tui-table.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/src/components/thorui/tui-tabs/tui-tabs.vue b/src/components/thorui/tui-tabs/tui-tabs.vue new file mode 100644 index 0000000..9651e61 --- /dev/null +++ b/src/components/thorui/tui-tabs/tui-tabs.vue @@ -0,0 +1,346 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-tag/tui-tag.vue b/src/components/thorui/tui-tag/tui-tag.vue new file mode 100644 index 0000000..f152ab5 --- /dev/null +++ b/src/components/thorui/tui-tag/tui-tag.vue @@ -0,0 +1,223 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-td/tui-td.vue b/src/components/thorui/tui-td/tui-td.vue new file mode 100644 index 0000000..43c5853 --- /dev/null +++ b/src/components/thorui/tui-td/tui-td.vue @@ -0,0 +1,251 @@ + + + + + diff --git a/src/components/thorui/tui-text/tui-text.vue b/src/components/thorui/tui-text/tui-text.vue new file mode 100644 index 0000000..23369a8 --- /dev/null +++ b/src/components/thorui/tui-text/tui-text.vue @@ -0,0 +1,207 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-textarea/tui-textarea.vue b/src/components/thorui/tui-textarea/tui-textarea.vue new file mode 100644 index 0000000..91ba6df --- /dev/null +++ b/src/components/thorui/tui-textarea/tui-textarea.vue @@ -0,0 +1,588 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-time-axis/tui-time-axis.vue b/src/components/thorui/tui-time-axis/tui-time-axis.vue new file mode 100644 index 0000000..dc346c0 --- /dev/null +++ b/src/components/thorui/tui-time-axis/tui-time-axis.vue @@ -0,0 +1,38 @@ + + + + + diff --git a/src/components/thorui/tui-timeaxis-item/tui-timeaxis-item.vue b/src/components/thorui/tui-timeaxis-item/tui-timeaxis-item.vue new file mode 100644 index 0000000..154b8f6 --- /dev/null +++ b/src/components/thorui/tui-timeaxis-item/tui-timeaxis-item.vue @@ -0,0 +1,50 @@ + + + + + diff --git a/src/components/thorui/tui-timer/tui-timer.vue b/src/components/thorui/tui-timer/tui-timer.vue new file mode 100644 index 0000000..7516c11 --- /dev/null +++ b/src/components/thorui/tui-timer/tui-timer.vue @@ -0,0 +1,329 @@ + + + + + diff --git a/src/components/thorui/tui-tips/tui-tips.vue b/src/components/thorui/tui-tips/tui-tips.vue new file mode 100644 index 0000000..bd6900a --- /dev/null +++ b/src/components/thorui/tui-tips/tui-tips.vue @@ -0,0 +1,129 @@ + + + + + diff --git a/src/components/thorui/tui-toast/tui-toast.vue b/src/components/thorui/tui-toast/tui-toast.vue new file mode 100644 index 0000000..31b6f8f --- /dev/null +++ b/src/components/thorui/tui-toast/tui-toast.vue @@ -0,0 +1,121 @@ + + + + + diff --git a/src/components/thorui/tui-top-dropdown/tui-top-dropdown.vue b/src/components/thorui/tui-top-dropdown/tui-top-dropdown.vue new file mode 100644 index 0000000..89588e7 --- /dev/null +++ b/src/components/thorui/tui-top-dropdown/tui-top-dropdown.vue @@ -0,0 +1,105 @@ + + + + + diff --git a/src/components/thorui/tui-tr/tui-tr.vue b/src/components/thorui/tui-tr/tui-tr.vue new file mode 100644 index 0000000..1846ab1 --- /dev/null +++ b/src/components/thorui/tui-tr/tui-tr.vue @@ -0,0 +1,122 @@ + + + + + diff --git a/src/components/thorui/tui-tree-node/tui-tree-node.vue b/src/components/thorui/tui-tree-node/tui-tree-node.vue new file mode 100644 index 0000000..b2f5a3e --- /dev/null +++ b/src/components/thorui/tui-tree-node/tui-tree-node.vue @@ -0,0 +1,146 @@ + + + + + diff --git a/src/components/thorui/tui-tree-view/tui-tree-view.vue b/src/components/thorui/tui-tree-view/tui-tree-view.vue new file mode 100644 index 0000000..d780c17 --- /dev/null +++ b/src/components/thorui/tui-tree-view/tui-tree-view.vue @@ -0,0 +1,45 @@ + + + + + diff --git a/src/components/thorui/tui-upload/tui-upload.vue b/src/components/thorui/tui-upload/tui-upload.vue new file mode 100644 index 0000000..1b7fadf --- /dev/null +++ b/src/components/thorui/tui-upload/tui-upload.vue @@ -0,0 +1,613 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-vcode/tui-vcode.vue b/src/components/thorui/tui-vcode/tui-vcode.vue new file mode 100644 index 0000000..f333cf8 --- /dev/null +++ b/src/components/thorui/tui-vcode/tui-vcode.vue @@ -0,0 +1,163 @@ + + + + + diff --git a/src/components/thorui/tui-virtual-item/tui-virtual-item.vue b/src/components/thorui/tui-virtual-item/tui-virtual-item.vue new file mode 100644 index 0000000..d395562 --- /dev/null +++ b/src/components/thorui/tui-virtual-item/tui-virtual-item.vue @@ -0,0 +1,60 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-virtual-list/index.js b/src/components/thorui/tui-virtual-list/index.js new file mode 100644 index 0000000..41a1b00 --- /dev/null +++ b/src/components/thorui/tui-virtual-list/index.js @@ -0,0 +1,32 @@ +export const mapVirtualToProps = ({ + items, + itemHeight +}, { + startIndex, + endIndex +}) => { + const visibleItems = endIndex > -1 ? items.slice(startIndex, endIndex + 1) : [] + + // style + const height = items.length * itemHeight + const paddingTop = startIndex * itemHeight + + return { + items: visibleItems, + style: `height: ${height}px; padding-top: ${paddingTop}px; box-sizing: border-box;` + } +} + +export const getVisibleItemBounds = (viewTop, viewHeight, itemCount, itemHeight, itemBuffer) => { + // visible list inside view + const listViewTop = Math.max(0, viewTop) + + // visible item indexes + const startIndex = Math.max(0, Math.floor(listViewTop / itemHeight) - 9) + const endIndex = Math.min(startIndex + Math.ceil(viewHeight / itemHeight) + itemBuffer - 1, itemCount) + + return { + startIndex, + endIndex, + } +} \ No newline at end of file diff --git a/src/components/thorui/tui-virtual-list/tui-virtual-list.vue b/src/components/thorui/tui-virtual-list/tui-virtual-list.vue new file mode 100644 index 0000000..907783c --- /dev/null +++ b/src/components/thorui/tui-virtual-list/tui-virtual-list.vue @@ -0,0 +1,370 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-virtual-table/debounce.js b/src/components/thorui/tui-virtual-table/debounce.js new file mode 100644 index 0000000..eea27ad --- /dev/null +++ b/src/components/thorui/tui-virtual-table/debounce.js @@ -0,0 +1,147 @@ +function isObject(value) { + let type = typeof value + return !!value && (type == 'object' || type == 'function') +} + +function debounce(func, wait, options) { + let lastArgs, + lastThis, + maxWait, + result, + timerId, + lastCallTime + + let lastInvokeTime = 0 + let leading = false + let maxing = false + let trailing = true + + // Bypass `requestAnimationFrame` by explicitly setting `wait=0`. + const useRAF = false + + if (typeof func !== 'function') { + throw new TypeError('Expected a function') + } + wait = +wait || 0 + if (isObject(options)) { + leading = !!options.leading + maxing = 'maxWait' in options + maxWait = maxing ? Math.max(+options.maxWait || 0, wait) : maxWait + trailing = 'trailing' in options ? !!options.trailing : trailing + } + + function invokeFunc(time) { + const args = lastArgs + const thisArg = lastThis + + lastArgs = lastThis = undefined + lastInvokeTime = time + result = func.apply(thisArg, args) + return result + } + + function startTimer(pendingFunc, wait) { + return setTimeout(pendingFunc, wait) + } + + function cancelTimer(id) { + clearTimeout(id) + } + + function leadingEdge(time) { + // Reset any `maxWait` timer. + lastInvokeTime = time + // Start the timer for the trailing edge. + timerId = startTimer(timerExpired, wait) + // Invoke the leading edge. + return leading ? invokeFunc(time) : result + } + + function remainingWait(time) { + const timeSinceLastCall = time - lastCallTime + const timeSinceLastInvoke = time - lastInvokeTime + const timeWaiting = wait - timeSinceLastCall + + return maxing + ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke) + : timeWaiting + } + + function shouldInvoke(time) { + const timeSinceLastCall = time - lastCallTime + const timeSinceLastInvoke = time - lastInvokeTime + + // Either this is the first call, activity has stopped and we're at the + // trailing edge, the system time has gone backwards and we're treating + // it as the trailing edge, or we've hit the `maxWait` limit. + return (lastCallTime === undefined || (timeSinceLastCall >= wait) || + (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)) + } + + function timerExpired() { + const time = Date.now() + if (shouldInvoke(time)) { + return trailingEdge(time) + } + // Restart the timer. + timerId = startTimer(timerExpired, remainingWait(time)) + } + + function trailingEdge(time) { + timerId = undefined + + // Only invoke if we have `lastArgs` which means `func` has been + // debounced at least once. + if (trailing && lastArgs) { + return invokeFunc(time) + } + lastArgs = lastThis = undefined + return result + } + + function cancel() { + if (timerId !== undefined) { + cancelTimer(timerId) + } + lastInvokeTime = 0 + lastArgs = lastCallTime = lastThis = timerId = undefined + } + + function flush() { + return timerId === undefined ? result : trailingEdge(Date.now()) + } + + function pending() { + return timerId !== undefined + } + + function debounced(...args) { + const time = Date.now() + const isInvoking = shouldInvoke(time) + + lastArgs = args + lastThis = this + lastCallTime = time + + if (isInvoking) { + if (timerId === undefined) { + return leadingEdge(lastCallTime) + } + if (maxing) { + // Handle invocations in a tight loop. + timerId = startTimer(timerExpired, wait) + return invokeFunc(lastCallTime) + } + } + if (timerId === undefined) { + timerId = startTimer(timerExpired, wait) + } + return result + } + debounced.cancel = cancel + debounced.flush = flush + debounced.pending = pending + return debounced +} + +export default debounce diff --git a/src/components/thorui/tui-virtual-table/index.js b/src/components/thorui/tui-virtual-table/index.js new file mode 100644 index 0000000..1d211ad --- /dev/null +++ b/src/components/thorui/tui-virtual-table/index.js @@ -0,0 +1,32 @@ +export const mapVirtualToProps = ({ + items, + itemHeight +}, { + startIndex, + endIndex +}) => { + const visibleItems = endIndex > -1 ? items.slice(startIndex, endIndex + 1) : [] + + // style + const height = items.length * itemHeight + const paddingTop = startIndex * itemHeight + + return { + items: visibleItems, + style: `height: ${height}px; padding-top: ${paddingTop}px; box-sizing: border-box;` + } +} + +export const getVisibleItemBounds = (viewTop, viewHeight, itemCount, itemHeight, itemBuffer) => { + // visible list inside view + const listViewTop = Math.max(0, viewTop) + + // visible item indexes + const startIndex = Math.max(0, Math.floor(listViewTop / itemHeight) - 12) + const endIndex = Math.min(startIndex + Math.ceil(viewHeight / itemHeight) + itemBuffer - 1, itemCount) + + return { + startIndex, + endIndex, + } +} \ No newline at end of file diff --git a/src/components/thorui/tui-virtual-table/tui-virtual-table.vue b/src/components/thorui/tui-virtual-table/tui-virtual-table.vue new file mode 100644 index 0000000..23db818 --- /dev/null +++ b/src/components/thorui/tui-virtual-table/tui-virtual-table.vue @@ -0,0 +1,1302 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-waterfall/tui-waterfall.vue b/src/components/thorui/tui-waterfall/tui-waterfall.vue new file mode 100644 index 0000000..cdf133b --- /dev/null +++ b/src/components/thorui/tui-waterfall/tui-waterfall.vue @@ -0,0 +1,258 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-week-date/tui-week-date.vue b/src/components/thorui/tui-week-date/tui-week-date.vue new file mode 100644 index 0000000..c1e2dbc --- /dev/null +++ b/src/components/thorui/tui-week-date/tui-week-date.vue @@ -0,0 +1,231 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-white-space/tui-white-space.vue b/src/components/thorui/tui-white-space/tui-white-space.vue new file mode 100644 index 0000000..81102c3 --- /dev/null +++ b/src/components/thorui/tui-white-space/tui-white-space.vue @@ -0,0 +1,69 @@ + + + + + \ No newline at end of file diff --git a/src/components/thorui/tui-wing-blank/tui-wing-blank.vue b/src/components/thorui/tui-wing-blank/tui-wing-blank.vue new file mode 100644 index 0000000..603f135 --- /dev/null +++ b/src/components/thorui/tui-wing-blank/tui-wing-blank.vue @@ -0,0 +1,86 @@ + + + + + \ No newline at end of file diff --git a/src/hooks/useSocket.ts b/src/hooks/useSocket.ts index dc63543..2b88ad6 100644 --- a/src/hooks/useSocket.ts +++ b/src/hooks/useSocket.ts @@ -1,14 +1,14 @@ -import { useWebSocket } from '@vueuse/core'; -import { user } from '@/store'; -import { ref } from 'vue'; -import type { UseWebSocketReturn } from '@vueuse/core'; +import { useWebSocket } from '@vueuse/core' +import { user } from '@/store' +import { ref } from 'vue' +import type { UseWebSocketReturn } from '@vueuse/core' -let SOCKET: UseWebSocketReturn; +let SOCKET: UseWebSocketReturn export const useSocket = () => { - const { token, userInfo } = user(); - const inspectorMessage = ref(); - const inspectorDesktopMessage = ref([]); - const desktopPath = ref(); + const { token, userInfo } = user() + const inspectorMessage = ref() + const inspectorDesktopMessage = ref([]) + const desktopPath = ref() enum SOCKET_MSG_TYPE { lockScreen = 'lockScreen', unLockScreen = 'unLockScreen', @@ -24,7 +24,7 @@ export const useSocket = () => { retries: 5, delay: 3000, onFailed() { - console.log('重新连接失败'); + console.log('重新连接失败') }, }, heartbeat: { @@ -37,26 +37,26 @@ export const useSocket = () => { onError, onMessage, }, - ); + ) sendMsg({ type: 'ping', - }); + }) } function onConnected(ws: WebSocket) { // ws.binaryType = 'arraybuffer'; - console.log('ws已连接'); + console.log('ws已连接') } function onDisconnected() { - console.log('ws已关闭'); + console.log('ws已关闭') } function onError(ws: WebSocket, event: Event) { // console.log(event); } function onMessage(ws: WebSocket, event: MessageEvent) { - const data = JSON.parse(event.data); - console.log(data); + const data = JSON.parse(event.data) + console.log(data) switch (data.type) { // case SOCKET_MSG_TYPE.lockScreen: // // 执行锁屏 @@ -73,14 +73,14 @@ export const useSocket = () => { // }); // break; case SOCKET_MSG_TYPE.desktopPreview: - onDesktopPreview(); - break; + onDesktopPreview() + break case SOCKET_MSG_TYPE.inspectorTalkMessage: - inspectorMessage.value = data.msg; - break; + inspectorMessage.value = data.msg + break case SOCKET_MSG_TYPE.desktopScreenshotImage: - inspectorDesktopMessage.value = data; - break; + inspectorDesktopMessage.value = data + break } } // 桌面预览 @@ -102,26 +102,26 @@ export const useSocket = () => { // ); } // 发送消息 - function sendMsg(data: anyObj, config = {}) { + function sendMsg(data: any, config = {}) { if (!SOCKET) { - console.error('ws不存在'); - return; + console.error('ws不存在') + return } - inspectorDesktopMessage.value = []; - SOCKET.send(JSON.stringify(data)); + inspectorDesktopMessage.value = [] + SOCKET.send(JSON.stringify(data)) } function textToBuffer(str: string) { - return new TextEncoder().encode(str); + return new TextEncoder().encode(str) } function bufferToText(buffer: ArrayBuffer) { - return new TextDecoder().decode(buffer); + return new TextDecoder().decode(buffer) } return { init, sendMsg, inspectorMessage, inspectorDesktopMessage, - }; -}; + } +} diff --git a/src/pages.json b/src/pages.json index dd6ad9b..33d280c 100644 --- a/src/pages.json +++ b/src/pages.json @@ -373,7 +373,6 @@ "navigationBarTitleText": "督学服务" } } - /*督学师==============END=======================*/ ], "tabBar": { "color": "#333333", @@ -396,7 +395,9 @@ "^qy-(.*)": "~@/components/$1/index.vue", "^svg-(.*)": "~@/components/svgs/$1/index.vue", "^svgs-(.*)": "~@/components/svgs/svgs-$1.vue", - "^isp-(.*)": "~@/components/inspector/isp-$1.vue" + "^isp-(.*)": "~@/components/inspector/isp-$1.vue", + "^mj-(.*)": "~@/components/mjui/mj-$1/mj-$1.vue", + "^tui-(.*)": "~@/components/thorui/tui-$1/tui-$1.vue" } } } diff --git a/src/pages/academicReport/index.vue b/src/pages/academicReport/index.vue index 363bf44..c5fb99e 100644 --- a/src/pages/academicReport/index.vue +++ b/src/pages/academicReport/index.vue @@ -1,12 +1,12 @@