wewe
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
||||
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 leejimqiu
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
52
api/request.js
Normal file
@ -0,0 +1,52 @@
|
||||
import config from '~/config';
|
||||
|
||||
const baseUrl = 'https://ddbs.1024tool.vip/';
|
||||
const delay = config.isMock ? 500 : 0;
|
||||
function request(url, method = 'GET', data = {}) {
|
||||
const header = {
|
||||
'content-type': 'application/json',
|
||||
// 有其他content-type需求加点逻辑判断处理即可
|
||||
};
|
||||
// 获取token,有就丢进请求头
|
||||
const tokenString = wx.getStorageSync('access_token');
|
||||
if (tokenString) {
|
||||
header.Authorization = `${tokenString}`;
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.request({
|
||||
url: baseUrl + url,
|
||||
method,
|
||||
data,
|
||||
dataType: 'json', // 微信官方文档中介绍会对数据进行一次JSON.parse
|
||||
header,
|
||||
success(res) {
|
||||
console.log(res)
|
||||
setTimeout(() => {
|
||||
|
||||
if(res.data.code && res.data.code == 10103){
|
||||
wx.removeStorageSync('access_token');
|
||||
wx.switchTab({
|
||||
url: '/pages/my/index',
|
||||
})
|
||||
reject(res.data);
|
||||
} else {
|
||||
console.log(res.data)
|
||||
resolve(res.data);
|
||||
}
|
||||
|
||||
}, delay);
|
||||
},
|
||||
fail(err) {
|
||||
setTimeout(() => {
|
||||
console.log(err)
|
||||
// 断网、服务器挂了都会fail回调,直接reject即可
|
||||
|
||||
reject(err);
|
||||
}, delay);
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 导出请求和服务地址
|
||||
export default request;
|
||||
9
api/user.js
Normal file
@ -0,0 +1,9 @@
|
||||
import request from './request'
|
||||
|
||||
export const userLogin = () => {
|
||||
return request({
|
||||
url: 'patient/password_login',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
66
app.js
Normal file
@ -0,0 +1,66 @@
|
||||
// app.js
|
||||
import config from './config';
|
||||
import Mock from './mock/index';
|
||||
import createBus from './utils/eventBus';
|
||||
import { connectSocket, fetchUnreadNum } from './mock/chat';
|
||||
|
||||
if (config.isMock) {
|
||||
Mock();
|
||||
}
|
||||
|
||||
App({
|
||||
onLaunch() {
|
||||
const updateManager = wx.getUpdateManager();
|
||||
|
||||
updateManager.onCheckForUpdate((res) => {
|
||||
// console.log(res.hasUpdate)
|
||||
});
|
||||
|
||||
updateManager.onUpdateReady(() => {
|
||||
wx.showModal({
|
||||
title: '更新提示',
|
||||
content: '新版本已经准备好,是否重启应用?',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
updateManager.applyUpdate();
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
this.getUnreadNum();
|
||||
this.connect();
|
||||
},
|
||||
globalData: {
|
||||
userInfo: null,
|
||||
unreadNum: 0, // 未读消息数量
|
||||
socket: null, // SocketTask 对象
|
||||
},
|
||||
|
||||
/** 全局事件总线 */
|
||||
eventBus: createBus(),
|
||||
|
||||
/** 初始化WebSocket */
|
||||
connect() {
|
||||
const socket = connectSocket();
|
||||
socket.onMessage((data) => {
|
||||
data = JSON.parse(data);
|
||||
if (data.type === 'message' && !data.data.message.read) this.setUnreadNum(this.globalData.unreadNum + 1);
|
||||
});
|
||||
this.globalData.socket = socket;
|
||||
},
|
||||
|
||||
/** 获取未读消息数量 */
|
||||
getUnreadNum() {
|
||||
fetchUnreadNum().then(({ data }) => {
|
||||
this.globalData.unreadNum = data;
|
||||
this.eventBus.emit('unread-num-change', data);
|
||||
});
|
||||
},
|
||||
|
||||
/** 设置未读消息数量 */
|
||||
setUnreadNum(unreadNum) {
|
||||
this.globalData.unreadNum = unreadNum;
|
||||
this.eventBus.emit('unread-num-change', unreadNum);
|
||||
},
|
||||
});
|
||||
62
app.json
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"pages": ["pages/patients/index", "pages/my/index"],
|
||||
"usingComponents": {
|
||||
"t-toast": "tdesign-miniprogram/toast/toast"
|
||||
},
|
||||
"subpackages": [
|
||||
|
||||
{
|
||||
"root": "pages/my/info-edit",
|
||||
"name": "edit",
|
||||
"pages": ["index"]
|
||||
},
|
||||
|
||||
{
|
||||
"root": "pages/login",
|
||||
"name": "login",
|
||||
"pages": ["login"]
|
||||
},
|
||||
{
|
||||
"root": "pages/loginCode",
|
||||
"name": "loginCode",
|
||||
"pages": ["loginCode"]
|
||||
},
|
||||
{
|
||||
"root": "pages/home",
|
||||
"name": "home",
|
||||
"pages": ["index"]
|
||||
}
|
||||
|
||||
|
||||
],
|
||||
"window": {
|
||||
"backgroundTextStyle": "light",
|
||||
"navigationBarBackgroundColor": "#fff",
|
||||
"navigationBarTitleText": "Weixin",
|
||||
"navigationBarTextStyle": "black"
|
||||
|
||||
},
|
||||
"tabBar": {
|
||||
"color": "#888888",
|
||||
"selectedColor": "#005BA2",
|
||||
"list": [
|
||||
{
|
||||
"iconPath": "assets/images/home/home.png",
|
||||
"selectedIconPath": "assets/images/home/homeAct.png",
|
||||
"pagePath": "pages/patients/index",
|
||||
"text": "患者管理"
|
||||
},
|
||||
|
||||
{
|
||||
"iconPath": "assets/images/home/my.png",
|
||||
"selectedIconPath": "assets/images/home/myAct.png",
|
||||
"pagePath": "pages/my/index",
|
||||
"text": "我的"
|
||||
}
|
||||
]
|
||||
},
|
||||
"resolveAlias": {
|
||||
"~/*": "/*"
|
||||
},
|
||||
"sitemapLocation": "sitemap.json"
|
||||
}
|
||||
36
app.less
Normal file
@ -0,0 +1,36 @@
|
||||
/**app.wxss**/
|
||||
@import 'iconfont.less';
|
||||
page {
|
||||
background-color: #F8F8F8;
|
||||
--td-brand-color: #005BA2; // 任何你想要的主题色
|
||||
--td-bg-color: #F8F8F8;
|
||||
--td-text-color: #222222;
|
||||
font-size: 28rpx;
|
||||
color: #222222;
|
||||
.t-cell__title-text {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
.t-input__control {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
.t-input{
|
||||
|
||||
}
|
||||
.t-input__label:not(:empty) {
|
||||
max-width: 10rem;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
.active{
|
||||
.t-cell__note{
|
||||
color: #222222;
|
||||
}
|
||||
}
|
||||
button{
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.page {
|
||||
height: 100vh;
|
||||
background-color: #fff;
|
||||
}
|
||||
BIN
assets/images/home/home.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
assets/images/home/homeAct.png
Normal file
|
After Width: | Height: | Size: 694 B |
24
assets/images/home/icon_1.svg
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="18px" height="18px" viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>生长曲线备份</title>
|
||||
<defs>
|
||||
<linearGradient x1="50%" y1="0%" x2="50%" y2="97.7014374%" id="linearGradient-1">
|
||||
<stop stop-color="#54A4E6" offset="0%"></stop>
|
||||
<stop stop-color="#1C71B3" offset="100%"></stop>
|
||||
</linearGradient>
|
||||
<rect id="path-2" x="0" y="0" width="18" height="18" rx="4"></rect>
|
||||
</defs>
|
||||
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="02首页-00" transform="translate(-22.000000, -100.000000)">
|
||||
<g id="宝宝生长曲线" transform="translate(12.000000, 100.000000)">
|
||||
<g id="生长曲线备份" transform="translate(10.000000, 0.000000)">
|
||||
<mask id="mask-3" fill="white">
|
||||
<use xlink:href="#path-2"></use>
|
||||
</mask>
|
||||
<use id="蒙版" fill="url(#linearGradient-1)" xlink:href="#path-2"></use>
|
||||
<path d="M13.2887481,8.84531617 C14.1171752,8.84531617 14.7887481,9.51688904 14.7887481,10.3453162 L14.7887481,13.9183441 C14.7887481,14.7467712 14.1171752,15.4183441 13.2887481,15.4183441 L13.0022341,15.4183441 C12.173807,15.4183441 11.5022341,14.7467712 11.5022341,13.9183441 L11.5022341,10.3453162 C11.5022341,9.51688904 12.173807,8.84531617 13.0022341,8.84531617 L13.2887481,8.84531617 Z M4.08650902,12.1308664 C4.91493615,12.1308664 5.58650902,12.8024393 5.58650902,13.6308664 L5.58650902,13.9173803 C5.58650902,14.7458075 4.91493615,15.4173803 4.08650902,15.4173803 L3.79999507,15.4173803 C2.97156795,15.4173803 2.29999507,14.7458075 2.29999507,13.9173803 L2.29999507,13.6308664 C2.29999507,12.8024393 2.97156795,12.1308664 3.79999507,12.1308664 L4.08650902,12.1308664 Z M8.68762856,10.8150892 C9.51605568,10.8150892 10.1876286,11.486662 10.1876286,12.3150892 L10.1876286,13.9162087 C10.1876286,14.7446358 9.51605568,15.4162087 8.68762856,15.4162087 L8.40111461,15.4162087 C7.57268748,15.4162087 6.90111461,14.7446358 6.90111461,13.9162087 L6.90111461,12.3150892 C6.90111461,11.486662 7.57268748,10.8150892 8.40111461,10.8150892 L8.68762856,10.8150892 Z M16.1174277,3.43416352 C16.1291426,3.55601781 16.1183842,3.67898747 16.0856874,3.79695624 L15.2775434,6.71271375 C15.1300309,7.24493411 14.5789985,7.55680143 14.0467782,7.40928892 C13.8518339,7.35525732 13.6778605,7.24337219 13.5478287,7.08840633 L12.9656075,6.3972697 C10.1188007,8.87646671 7.4276443,9.86144651 3.86551098,9.93934871 L3.48661779,9.94422682 L2.98876335,9.94281924 C2.55314138,9.94281924 2.2,9.58967786 2.2,9.15405589 C2.2,8.78914098 2.44902966,8.47819263 2.79724606,8.38965382 L2.90453675,8.3699329 L2.9893466,8.36529383 L3.51583083,8.36645753 C6.88597863,8.34509504 9.31054469,7.49628332 11.9523661,5.18796425 L11.3441794,4.46219937 C10.9891777,4.0391247 11.0443616,3.40836911 11.4674363,3.05336731 C11.6224021,2.92333552 11.8131611,2.84336034 12.0145262,2.82400131 L15.0263196,2.53445076 C15.5760696,2.48159839 16.0645753,2.88441352 16.1174277,3.43416352 Z" id="形状结合" fill="#FFFFFF" mask="url(#mask-3)"></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.2 KiB |
BIN
assets/images/home/icon_2.png
Normal file
|
After Width: | Height: | Size: 701 B |
BIN
assets/images/home/img_1.png
Normal file
|
After Width: | Height: | Size: 7.0 KiB |
BIN
assets/images/home/img_2.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
assets/images/home/img_title_1.png
Normal file
|
After Width: | Height: | Size: 5.8 KiB |
BIN
assets/images/home/img_title_2.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
assets/images/home/my.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
assets/images/home/myAct.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
assets/images/home/sf.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
assets/images/home/sfAct.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
assets/images/home/top-bg.png
Normal file
|
After Width: | Height: | Size: 185 KiB |
BIN
assets/images/logo.jpg
Normal file
|
After Width: | Height: | Size: 31 KiB |
BIN
assets/images/my/baby.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
24
assets/images/my/jkjy.svg
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="20px" height="20px" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>健康教育</title>
|
||||
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="04我的-00-00" transform="translate(-28.000000, -273.000000)">
|
||||
<g id="编组-11备份-3" transform="translate(12.000000, 204.000000)">
|
||||
<g id="健康教育" transform="translate(0.000000, 53.000000)">
|
||||
<g transform="translate(16.000000, 16.000000)">
|
||||
<rect id="矩形" fill="#FFFFFF" opacity="0.00999999978" x="0" y="0" width="20" height="20"></rect>
|
||||
<g id="编组-4" transform="translate(2.000000, 2.000000)">
|
||||
<path d="M14,6.08333333 C14.345178,6.08333333 14.657678,6.22324435 14.8838835,6.44944986 C15.110089,6.67565536 15.25,6.98815536 15.25,7.33333333 L15.25,7.33333333 L15.25,14 C15.25,14.345178 15.110089,14.657678 14.8838835,14.8838835 C14.657678,15.110089 14.345178,15.25 14,15.25 L14,15.25 L11.8649104,15.25 L11.8649104,6.08333333 Z" id="蒙版备份" stroke="#333333" stroke-width="1.5"></path>
|
||||
<path d="M9.44444444,0.75 C10.0657648,0.75 10.6282648,1.00183983 11.0354347,1.40900974 C11.4426046,1.81617966 11.6944444,2.37867966 11.6944444,3 L11.6944444,3 L11.6944444,15.25 L3,15.25 C2.37867966,15.25 1.81617966,14.9981602 1.40900974,14.5909903 C1.00183983,14.1838203 0.75,13.6213203 0.75,13 L0.75,13 L0.75,3 C0.75,2.37867966 1.00183983,1.81617966 1.40900974,1.40900974 C1.81617966,1.00183983 2.37867966,0.75 3,0.75 L3,0.75 Z" id="蒙版" stroke="#333333" stroke-width="1.5"></path>
|
||||
<g id="编组-2" transform="translate(3.111111, 3.400000)" fill="#005BA2">
|
||||
<rect id="矩形" x="0" y="2.44444444" width="6.22222222" height="1.33333333" rx="0.666666667"></rect>
|
||||
<path d="M0.666666667,2.44444444 L5.55555556,2.44444444 C5.92374539,2.44444444 6.22222222,2.74292128 6.22222222,3.11111111 C6.22222222,3.47930094 5.92374539,3.77777778 5.55555556,3.77777778 L0.666666667,3.77777778 C0.298476833,3.77777778 3.64153152e-14,3.47930094 3.64153152e-14,3.11111111 C3.64153152e-14,2.74292128 0.298476833,2.44444444 0.666666667,2.44444444 Z" id="矩形" transform="translate(3.111111, 3.111111) rotate(90.000000) translate(-3.111111, -3.111111) "></path>
|
||||
</g>
|
||||
<rect id="矩形备份" fill="#005BA2" x="2.66666667" y="11.2" width="7.11111111" height="1.33333333" rx="0.666666667"></rect>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
BIN
assets/images/my/my-top-bg.png
Normal file
|
After Width: | Height: | Size: 39 KiB |
22
assets/images/my/yyfa.svg
Normal file
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="20px" height="20px" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>用药方案</title>
|
||||
<g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="04我的-00-00" transform="translate(-28.000000, -220.000000)">
|
||||
<g id="编组-11备份-3" transform="translate(12.000000, 204.000000)">
|
||||
<g id="用药方案" transform="translate(16.000000, 16.000000)">
|
||||
<rect id="Rectangle-3" fill-opacity="0.01" fill="#EEEEEE" x="0" y="0" width="20" height="20"></rect>
|
||||
<g id="编组-14" transform="translate(3.600000, 2.000000)">
|
||||
<rect id="矩形" stroke="#333333" stroke-width="1.5" x="2.25980392" y="0.75" width="8.31372549" height="2.625" rx="1"></rect>
|
||||
<path d="M10.1646069,3.5 L11.8771593,6.09940994 C12.0116516,6.30354996 12.0833333,6.54264578 12.0833333,6.78710705 L12.0833333,6.78710705 L12.0833333,14.5 C12.0833333,14.845178 11.9434223,15.157678 11.7172168,15.3838835 C11.4910113,15.610089 11.1785113,15.75 10.8333333,15.75 L10.8333333,15.75 L2,15.75 C1.65482203,15.75 1.34232203,15.610089 1.11611652,15.3838835 C0.889911016,15.157678 0.75,14.845178 0.75,14.5 L0.75,14.5 L0.75,6.78710705 C0.75,6.54264578 0.821681769,6.30354996 0.95617402,6.09940994 L0.95617402,6.09940994 L2.66872645,3.5 L10.1646069,3.5 Z" id="矩形" stroke="#333333" stroke-width="1.5"></path>
|
||||
<rect id="矩形" x="0" y="7.5625" width="12.8333333" height="6.1875"></rect>
|
||||
<g id="编组-24" transform="translate(3.666667, 7.235119)" fill="#005BA2">
|
||||
<rect id="矩形" x="0" y="2.0625" width="5.5" height="1.375" rx="0.6875"></rect>
|
||||
<path d="M0.6875,2.0625 L4.8125,2.0625 C5.19219577,2.0625 5.5,2.37030423 5.5,2.75 C5.5,3.12969577 5.19219577,3.4375 4.8125,3.4375 L0.6875,3.4375 C0.307804235,3.4375 -1.13686838e-13,3.12969577 -1.13686838e-13,2.75 C-1.13686838e-13,2.37030423 0.307804235,2.0625 0.6875,2.0625 Z" id="矩形" transform="translate(2.750000, 2.750000) rotate(90.000000) translate(-2.750000, -2.750000) "></path>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
BIN
assets/images/top-bg.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
22
behaviors/useToast.js
Normal file
@ -0,0 +1,22 @@
|
||||
import Toast, { hideToast } from 'tdesign-miniprogram/toast/index';
|
||||
|
||||
const useToastBehavior = Behavior({
|
||||
methods: {
|
||||
onShowToast(selector, message) {
|
||||
Toast({
|
||||
context: this,
|
||||
selector,
|
||||
message,
|
||||
});
|
||||
},
|
||||
|
||||
onHideToast(selector) {
|
||||
hideToast({
|
||||
context: this,
|
||||
selector,
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default useToastBehavior;
|
||||
9
components/card/index.js
Normal file
@ -0,0 +1,9 @@
|
||||
Component({
|
||||
properties: {
|
||||
url: String,
|
||||
desc: String,
|
||||
tags: Array,
|
||||
},
|
||||
data: {},
|
||||
methods: {},
|
||||
});
|
||||
7
components/card/index.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-image": "tdesign-miniprogram/image/image",
|
||||
"t-tag": "tdesign-miniprogram/tag/tag"
|
||||
}
|
||||
}
|
||||
27
components/card/index.less
Normal file
@ -0,0 +1,27 @@
|
||||
@import '/variable.less';
|
||||
|
||||
.home-card {
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
width: 340rpx;
|
||||
height: 488rpx;
|
||||
border-radius: 9px;
|
||||
background: @bg-color-white;
|
||||
|
||||
&__image {
|
||||
width: 340rpx;
|
||||
height: 340rpx;
|
||||
}
|
||||
|
||||
&__info {
|
||||
padding: 32rpx;
|
||||
font-weight: 400;
|
||||
font-size: @font-size-small;
|
||||
}
|
||||
|
||||
&__tag-group {
|
||||
display: flex;
|
||||
gap: 16rpx;
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
}
|
||||
9
components/card/index.wxml
Normal file
@ -0,0 +1,9 @@
|
||||
<view class="home-card">
|
||||
<t-image t-class="home-card__image" src="{{url}}" mode="aspectFill" />
|
||||
<view class="home-card__info">
|
||||
<text>{{desc}}</text>
|
||||
<view class="home-card__tag-group">
|
||||
<t-tag wx:for="{{tags}}" wx:key="index" size="small" variant="light" theme="{{item.theme}}">{{item.text}}</t-tag>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
109
components/nav/index.js
Normal file
@ -0,0 +1,109 @@
|
||||
Component({
|
||||
options: {
|
||||
styleIsolation: 'shared',
|
||||
},
|
||||
properties: {
|
||||
navType: {
|
||||
type: String,
|
||||
value: 'title',
|
||||
},
|
||||
titleText: String,
|
||||
},
|
||||
data: {
|
||||
visible: false,
|
||||
sidebar: [
|
||||
{
|
||||
title: '首页',
|
||||
url: 'pages/home/index',
|
||||
isSidebar: true,
|
||||
},
|
||||
{
|
||||
title: '搜索页',
|
||||
url: 'pages/search/index',
|
||||
isSidebar: false,
|
||||
},
|
||||
{
|
||||
title: '发布页',
|
||||
url: 'pages/release/index',
|
||||
isSidebar: false,
|
||||
},
|
||||
{
|
||||
title: '消息列表页',
|
||||
url: 'pages/message/index',
|
||||
isSidebar: true,
|
||||
},
|
||||
{
|
||||
title: '对话页',
|
||||
url: 'pages/chat/index',
|
||||
isSidebar: false,
|
||||
},
|
||||
{
|
||||
title: '个人中心页',
|
||||
url: 'pages/my/index',
|
||||
isSidebar: true,
|
||||
},
|
||||
{
|
||||
title: '个人信息表单页',
|
||||
url: 'pages/my/info-edit/index',
|
||||
isSidebar: false,
|
||||
},
|
||||
{
|
||||
title: '设置页',
|
||||
url: 'pages/setting/index',
|
||||
isSidebar: false,
|
||||
},
|
||||
{
|
||||
title: '数据图表页',
|
||||
url: 'pages/dataCenter/index',
|
||||
isSidebar: false,
|
||||
},
|
||||
{
|
||||
title: '登录注册页',
|
||||
url: 'pages/login/login',
|
||||
isSidebar: false,
|
||||
},
|
||||
],
|
||||
statusHeight: 0,
|
||||
},
|
||||
lifetimes: {
|
||||
ready() {
|
||||
const statusHeight = wx.getWindowInfo().statusBarHeight;
|
||||
this.setData({ statusHeight });
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
openDrawer() {
|
||||
this.setData({
|
||||
visible: true,
|
||||
});
|
||||
},
|
||||
itemClick(e) {
|
||||
const that = this;
|
||||
const { isSidebar, url } = e.detail.item;
|
||||
if (isSidebar) {
|
||||
wx.switchTab({
|
||||
url: `/${url}`,
|
||||
}).then(() => {
|
||||
// 防止点回tab时,sidebar依旧是展开模式
|
||||
that.setData({
|
||||
visible: false,
|
||||
});
|
||||
});
|
||||
} else {
|
||||
wx.navigateTo({
|
||||
url: `/${url}`,
|
||||
}).then(() => {
|
||||
that.setData({
|
||||
visible: false,
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
searchTurn() {
|
||||
wx.navigateTo({
|
||||
url: `/pages/search/index`,
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
9
components/nav/index.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-navbar": "tdesign-miniprogram/navbar/navbar",
|
||||
"t-icon": "tdesign-miniprogram/icon/icon",
|
||||
"t-drawer": "tdesign-miniprogram/drawer/drawer",
|
||||
"t-search": "tdesign-miniprogram/search/search"
|
||||
}
|
||||
}
|
||||
30
components/nav/index.less
Normal file
@ -0,0 +1,30 @@
|
||||
@import '/variable.less';
|
||||
|
||||
.home-navbar {
|
||||
.t-navbar {
|
||||
&__left {
|
||||
margin-left: 12rpx;
|
||||
}
|
||||
}
|
||||
|
||||
&__icon {
|
||||
padding: 12rpx;
|
||||
}
|
||||
|
||||
&__left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 16rpx;
|
||||
|
||||
.t-search {
|
||||
--td-search-height: 64rpx;
|
||||
--td-search-font-size: @font-size-mini;
|
||||
width: 375rpx;
|
||||
|
||||
.t-icon {
|
||||
font-size: @font-size-default !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
--td-drawer-title-font-size: 48rpx;
|
||||
}
|
||||
23
components/nav/index.wxml
Normal file
@ -0,0 +1,23 @@
|
||||
<view class="home-navbar">
|
||||
<t-navbar title="{{ titleText }}">
|
||||
<!-- <view slot="left">
|
||||
<view class="home-navbar__left">
|
||||
<t-icon class="home-navbar__icon" bind:tap="openDrawer" name="view-list" size="48rpx" />
|
||||
<t-search
|
||||
shape="round"
|
||||
placeholder="请搜索你想要的内容"
|
||||
bindtap="searchTurn"
|
||||
wx:if="{{navType === 'search'}}"
|
||||
/>
|
||||
</view>
|
||||
</view> -->
|
||||
</t-navbar>
|
||||
<!-- <t-drawer
|
||||
style="padding-top: {{statusHeight}}px;"
|
||||
visible="{{visible}}"
|
||||
items="{{sidebar}}"
|
||||
placement="left"
|
||||
title="页面目录"
|
||||
bind:item-click="itemClick"
|
||||
/> -->
|
||||
</view>
|
||||
7
config/index.js
Normal file
@ -0,0 +1,7 @@
|
||||
/** 是否使用mock代替api返回 */
|
||||
export const config = {
|
||||
baseUrl: 'https://ddbs.1024tool.vip/',
|
||||
useMock: true,
|
||||
};
|
||||
|
||||
export default { config };
|
||||
57
custom-tab-bar/index.js
Normal file
@ -0,0 +1,57 @@
|
||||
const app = getApp();
|
||||
|
||||
Component({
|
||||
data: {
|
||||
value: '', // 初始值设置为空,避免第一次加载时闪烁
|
||||
unreadNum: 0, // 未读消息数量
|
||||
list: [
|
||||
{
|
||||
icon: 'home',
|
||||
value: 'index',
|
||||
label: '首页',
|
||||
},
|
||||
{
|
||||
icon: 'chat',
|
||||
value: 'notice',
|
||||
label: '随访',
|
||||
},
|
||||
{
|
||||
icon: 'user',
|
||||
value: 'my',
|
||||
label: '我1的',
|
||||
},
|
||||
],
|
||||
},
|
||||
lifetimes: {
|
||||
ready() {
|
||||
const pages = getCurrentPages();
|
||||
const curPage = pages[pages.length - 1];
|
||||
if (curPage) {
|
||||
const nameRe = /pages\/(\w+)\/index/.exec(curPage.route);
|
||||
if (nameRe === null) return;
|
||||
if (nameRe[1] && nameRe) {
|
||||
this.setData({
|
||||
value: nameRe[1],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 同步全局未读消息数量
|
||||
this.setUnreadNum(app.globalData.unreadNum);
|
||||
app.eventBus.on('unread-num-change', (unreadNum) => {
|
||||
this.setUnreadNum(unreadNum);
|
||||
});
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
handleChange(e) {
|
||||
const { value } = e.detail;
|
||||
wx.switchTab({ url: `/pages/${value}/index` });
|
||||
},
|
||||
|
||||
/** 设置未读消息数量 */
|
||||
setUnreadNum(unreadNum) {
|
||||
this.setData({ unreadNum });
|
||||
},
|
||||
},
|
||||
});
|
||||
7
custom-tab-bar/index.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-tab-bar": "tdesign-miniprogram/tab-bar/tab-bar",
|
||||
"t-tab-bar-item": "tdesign-miniprogram/tab-bar-item/tab-bar-item"
|
||||
}
|
||||
}
|
||||
10
custom-tab-bar/index.less
Normal file
@ -0,0 +1,10 @@
|
||||
@import '/variable.less';
|
||||
|
||||
.custom-tab-bar {
|
||||
--td-tab-bar-height: @tab-bar-height;
|
||||
|
||||
&-item {
|
||||
margin: 0;
|
||||
padding: 16rpx 24rpx;
|
||||
}
|
||||
}
|
||||
5
custom-tab-bar/index.wxml
Normal file
@ -0,0 +1,5 @@
|
||||
<t-tab-bar value="{{ value }}" theme="tag" split="{{ false }}" bind:change="handleChange">
|
||||
<t-tab-bar-item icon="home" value="home">首页</t-tab-bar-item>
|
||||
<t-tab-bar-item icon="chat" value="message">随访</t-tab-bar-item>
|
||||
<t-tab-bar-item icon="user" value="my">我的</t-tab-bar-item>
|
||||
</t-tab-bar>
|
||||
284
ec-canvas/ec-canvas.js
Normal file
@ -0,0 +1,284 @@
|
||||
import WxCanvas from './wx-canvas';
|
||||
import * as echarts from './echarts.min';
|
||||
|
||||
let ctx;
|
||||
|
||||
function compareVersion(v1, v2) {
|
||||
v1 = v1.split('.')
|
||||
v2 = v2.split('.')
|
||||
const len = Math.max(v1.length, v2.length)
|
||||
|
||||
while (v1.length < len) {
|
||||
v1.push('0')
|
||||
}
|
||||
while (v2.length < len) {
|
||||
v2.push('0')
|
||||
}
|
||||
|
||||
for (let i = 0; i < len; i++) {
|
||||
const num1 = parseInt(v1[i])
|
||||
const num2 = parseInt(v2[i])
|
||||
|
||||
if (num1 > num2) {
|
||||
return 1
|
||||
} else if (num1 < num2) {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
Component({
|
||||
properties: {
|
||||
canvasId: {
|
||||
type: String,
|
||||
value: 'ec-canvas'
|
||||
},
|
||||
|
||||
ec: {
|
||||
type: Object
|
||||
},
|
||||
|
||||
forceUseOldCanvas: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
}
|
||||
},
|
||||
|
||||
data: {
|
||||
isUseNewCanvas: false
|
||||
},
|
||||
|
||||
ready: function () {
|
||||
// Disable prograssive because drawImage doesn't support DOM as parameter
|
||||
// See https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.drawImage.html
|
||||
echarts.registerPreprocessor(option => {
|
||||
if (option && option.series) {
|
||||
if (option.series.length > 0) {
|
||||
option.series.forEach(series => {
|
||||
series.progressive = 0;
|
||||
});
|
||||
}
|
||||
else if (typeof option.series === 'object') {
|
||||
option.series.progressive = 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!this.data.ec) {
|
||||
console.warn('组件需绑定 ec 变量,例:<ec-canvas id="mychart-dom-bar" '
|
||||
+ 'canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.data.ec.lazyLoad) {
|
||||
this.init();
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
init: function (callback) {
|
||||
const version = wx.getSystemInfoSync().SDKVersion
|
||||
|
||||
const canUseNewCanvas = compareVersion(version, '2.9.0') >= 0;
|
||||
const forceUseOldCanvas = this.data.forceUseOldCanvas;
|
||||
const isUseNewCanvas = canUseNewCanvas && !forceUseOldCanvas;
|
||||
this.setData({ isUseNewCanvas });
|
||||
|
||||
if (forceUseOldCanvas && canUseNewCanvas) {
|
||||
console.warn('开发者强制使用旧canvas,建议关闭');
|
||||
}
|
||||
|
||||
if (isUseNewCanvas) {
|
||||
// console.log('微信基础库版本大于2.9.0,开始使用<canvas type="2d"/>');
|
||||
// 2.9.0 可以使用 <canvas type="2d"></canvas>
|
||||
this.initByNewWay(callback);
|
||||
} else {
|
||||
const isValid = compareVersion(version, '1.9.91') >= 0
|
||||
if (!isValid) {
|
||||
console.error('微信基础库版本过低,需大于等于 1.9.91。'
|
||||
+ '参见:https://github.com/ecomfe/echarts-for-weixin'
|
||||
+ '#%E5%BE%AE%E4%BF%A1%E7%89%88%E6%9C%AC%E8%A6%81%E6%B1%82');
|
||||
return;
|
||||
} else {
|
||||
console.warn('建议将微信基础库调整大于等于2.9.0版本。升级后绘图将有更好性能');
|
||||
this.initByOldWay(callback);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
initByOldWay(callback) {
|
||||
// 1.9.91 <= version < 2.9.0:原来的方式初始化
|
||||
ctx = wx.createCanvasContext(this.data.canvasId, this);
|
||||
const canvas = new WxCanvas(ctx, this.data.canvasId, false);
|
||||
|
||||
if (echarts.setPlatformAPI) {
|
||||
echarts.setPlatformAPI({
|
||||
createCanvas: () => canvas,
|
||||
});
|
||||
} else {
|
||||
echarts.setCanvasCreator(() => canvas);
|
||||
};
|
||||
// const canvasDpr = wx.getSystemInfoSync().pixelRatio // 微信旧的canvas不能传入dpr
|
||||
const canvasDpr = 1
|
||||
var query = wx.createSelectorQuery().in(this);
|
||||
query.select('.ec-canvas').boundingClientRect(res => {
|
||||
if (typeof callback === 'function') {
|
||||
this.chart = callback(canvas, res.width, res.height, canvasDpr);
|
||||
}
|
||||
else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
|
||||
this.chart = this.data.ec.onInit(canvas, res.width, res.height, canvasDpr);
|
||||
}
|
||||
else {
|
||||
this.triggerEvent('init', {
|
||||
canvas: canvas,
|
||||
width: res.width,
|
||||
height: res.height,
|
||||
canvasDpr: canvasDpr // 增加了dpr,可方便外面echarts.init
|
||||
});
|
||||
}
|
||||
}).exec();
|
||||
},
|
||||
|
||||
initByNewWay(callback) {
|
||||
// version >= 2.9.0:使用新的方式初始化
|
||||
const query = wx.createSelectorQuery().in(this)
|
||||
query
|
||||
.select('.ec-canvas')
|
||||
.fields({ node: true, size: true })
|
||||
.exec(res => {
|
||||
const canvasNode = res[0].node
|
||||
this.canvasNode = canvasNode
|
||||
|
||||
const canvasDpr = wx.getSystemInfoSync().pixelRatio
|
||||
const canvasWidth = res[0].width
|
||||
const canvasHeight = res[0].height
|
||||
|
||||
const ctx = canvasNode.getContext('2d')
|
||||
|
||||
const canvas = new WxCanvas(ctx, this.data.canvasId, true, canvasNode)
|
||||
if (echarts.setPlatformAPI) {
|
||||
echarts.setPlatformAPI({
|
||||
createCanvas: () => canvas,
|
||||
loadImage: (src, onload, onerror) => {
|
||||
if (canvasNode.createImage) {
|
||||
const image = canvasNode.createImage();
|
||||
image.onload = onload;
|
||||
image.onerror = onerror;
|
||||
image.src = src;
|
||||
return image;
|
||||
}
|
||||
console.error('加载图片依赖 `Canvas.createImage()` API,要求小程序基础库版本在 2.7.0 及以上。');
|
||||
// PENDING fallback?
|
||||
}
|
||||
})
|
||||
} else {
|
||||
echarts.setCanvasCreator(() => canvas)
|
||||
}
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
this.chart = callback(canvas, canvasWidth, canvasHeight, canvasDpr)
|
||||
} else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
|
||||
this.chart = this.data.ec.onInit(canvas, canvasWidth, canvasHeight, canvasDpr)
|
||||
} else {
|
||||
this.triggerEvent('init', {
|
||||
canvas: canvas,
|
||||
width: canvasWidth,
|
||||
height: canvasHeight,
|
||||
dpr: canvasDpr
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
canvasToTempFilePath(opt) {
|
||||
if (this.data.isUseNewCanvas) {
|
||||
// 新版
|
||||
const query = wx.createSelectorQuery().in(this)
|
||||
query
|
||||
.select('.ec-canvas')
|
||||
.fields({ node: true, size: true })
|
||||
.exec(res => {
|
||||
const canvasNode = res[0].node
|
||||
opt.canvas = canvasNode
|
||||
wx.canvasToTempFilePath(opt)
|
||||
})
|
||||
} else {
|
||||
// 旧的
|
||||
if (!opt.canvasId) {
|
||||
opt.canvasId = this.data.canvasId;
|
||||
}
|
||||
ctx.draw(true, () => {
|
||||
wx.canvasToTempFilePath(opt, this);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
touchStart(e) {
|
||||
if (this.chart && e.touches.length > 0) {
|
||||
var touch = e.touches[0];
|
||||
var handler = this.chart.getZr().handler;
|
||||
handler.dispatch('mousedown', {
|
||||
zrX: touch.x,
|
||||
zrY: touch.y,
|
||||
preventDefault: () => {},
|
||||
stopImmediatePropagation: () => {},
|
||||
stopPropagation: () => {}
|
||||
});
|
||||
handler.dispatch('mousemove', {
|
||||
zrX: touch.x,
|
||||
zrY: touch.y,
|
||||
preventDefault: () => {},
|
||||
stopImmediatePropagation: () => {},
|
||||
stopPropagation: () => {}
|
||||
});
|
||||
handler.processGesture(wrapTouch(e), 'start');
|
||||
}
|
||||
},
|
||||
|
||||
touchMove(e) {
|
||||
if (this.chart && e.touches.length > 0) {
|
||||
var touch = e.touches[0];
|
||||
var handler = this.chart.getZr().handler;
|
||||
handler.dispatch('mousemove', {
|
||||
zrX: touch.x,
|
||||
zrY: touch.y,
|
||||
preventDefault: () => {},
|
||||
stopImmediatePropagation: () => {},
|
||||
stopPropagation: () => {}
|
||||
});
|
||||
handler.processGesture(wrapTouch(e), 'change');
|
||||
}
|
||||
},
|
||||
|
||||
touchEnd(e) {
|
||||
if (this.chart) {
|
||||
const touch = e.changedTouches ? e.changedTouches[0] : {};
|
||||
var handler = this.chart.getZr().handler;
|
||||
handler.dispatch('mouseup', {
|
||||
zrX: touch.x,
|
||||
zrY: touch.y,
|
||||
preventDefault: () => {},
|
||||
stopImmediatePropagation: () => {},
|
||||
stopPropagation: () => {}
|
||||
});
|
||||
handler.dispatch('click', {
|
||||
zrX: touch.x,
|
||||
zrY: touch.y,
|
||||
preventDefault: () => {},
|
||||
stopImmediatePropagation: () => {},
|
||||
stopPropagation: () => {}
|
||||
});
|
||||
handler.processGesture(wrapTouch(e), 'end');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function wrapTouch(event) {
|
||||
for (let i = 0; i < event.touches.length; ++i) {
|
||||
const touch = event.touches[i];
|
||||
touch.offsetX = touch.x;
|
||||
touch.offsetY = touch.y;
|
||||
}
|
||||
return event;
|
||||
}
|
||||
4
ec-canvas/ec-canvas.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
4
ec-canvas/ec-canvas.wxml
Normal file
@ -0,0 +1,4 @@
|
||||
<!-- 新的:接口对其了H5 -->
|
||||
<canvas wx:if="{{isUseNewCanvas}}" type="2d" class="ec-canvas" canvas-id="{{ canvasId }}" bindinit="init" bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}"></canvas>
|
||||
<!-- 旧的 -->
|
||||
<canvas wx:else class="ec-canvas" canvas-id="{{ canvasId }}" bindinit="init" bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}"></canvas>
|
||||
16
ec-canvas/ec-canvas.wxss
Normal file
@ -0,0 +1,16 @@
|
||||
.ec-canvas {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
ec-canvas {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
canvas {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
1
ec-canvas/echarts.min.js
vendored
Normal file
111
ec-canvas/wx-canvas.js
Normal file
@ -0,0 +1,111 @@
|
||||
export default class WxCanvas {
|
||||
constructor(ctx, canvasId, isNew, canvasNode) {
|
||||
this.ctx = ctx;
|
||||
this.canvasId = canvasId;
|
||||
this.chart = null;
|
||||
this.isNew = isNew
|
||||
if (isNew) {
|
||||
this.canvasNode = canvasNode;
|
||||
}
|
||||
else {
|
||||
this._initStyle(ctx);
|
||||
}
|
||||
|
||||
// this._initCanvas(zrender, ctx);
|
||||
|
||||
this._initEvent();
|
||||
}
|
||||
|
||||
getContext(contextType) {
|
||||
if (contextType === '2d') {
|
||||
return this.ctx;
|
||||
}
|
||||
}
|
||||
|
||||
// canvasToTempFilePath(opt) {
|
||||
// if (!opt.canvasId) {
|
||||
// opt.canvasId = this.canvasId;
|
||||
// }
|
||||
// return wx.canvasToTempFilePath(opt, this);
|
||||
// }
|
||||
|
||||
setChart(chart) {
|
||||
this.chart = chart;
|
||||
}
|
||||
|
||||
addEventListener() {
|
||||
// noop
|
||||
}
|
||||
|
||||
attachEvent() {
|
||||
// noop
|
||||
}
|
||||
|
||||
detachEvent() {
|
||||
// noop
|
||||
}
|
||||
|
||||
_initCanvas(zrender, ctx) {
|
||||
zrender.util.getContext = function () {
|
||||
return ctx;
|
||||
};
|
||||
|
||||
zrender.util.$override('measureText', function (text, font) {
|
||||
ctx.font = font || '12px sans-serif';
|
||||
return ctx.measureText(text);
|
||||
});
|
||||
}
|
||||
|
||||
_initStyle(ctx) {
|
||||
ctx.createRadialGradient = () => {
|
||||
return ctx.createCircularGradient(arguments);
|
||||
};
|
||||
}
|
||||
|
||||
_initEvent() {
|
||||
this.event = {};
|
||||
const eventNames = [{
|
||||
wxName: 'touchStart',
|
||||
ecName: 'mousedown'
|
||||
}, {
|
||||
wxName: 'touchMove',
|
||||
ecName: 'mousemove'
|
||||
}, {
|
||||
wxName: 'touchEnd',
|
||||
ecName: 'mouseup'
|
||||
}, {
|
||||
wxName: 'touchEnd',
|
||||
ecName: 'click'
|
||||
}];
|
||||
eventNames.forEach(name => {
|
||||
this.event[name.wxName] = e => {
|
||||
const touch = e.touches[0];
|
||||
this.chart.getZr().handler.dispatch(name.ecName, {
|
||||
zrX: name.wxName === 'tap' ? touch.clientX : touch.x,
|
||||
zrY: name.wxName === 'tap' ? touch.clientY : touch.y,
|
||||
preventDefault: () => {},
|
||||
stopImmediatePropagation: () => {},
|
||||
stopPropagation: () => {}
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
set width(w) {
|
||||
if (this.canvasNode) this.canvasNode.width = w
|
||||
}
|
||||
set height(h) {
|
||||
if (this.canvasNode) this.canvasNode.height = h
|
||||
}
|
||||
|
||||
get width() {
|
||||
if (this.canvasNode)
|
||||
return this.canvasNode.width
|
||||
return 0
|
||||
}
|
||||
get height() {
|
||||
if (this.canvasNode)
|
||||
return this.canvasNode.height
|
||||
return 0
|
||||
}
|
||||
}
|
||||
82
iconfont.less
Normal file
@ -0,0 +1,82 @@
|
||||
@font-face {
|
||||
font-family: "iconfont"; /* Project id 4945922 */
|
||||
src: url('//at.alicdn.com/t/c/font_4945922_ou2nla6911e.woff2?t=1750598435466') format('woff2'),
|
||||
url('//at.alicdn.com/t/c/font_4945922_ou2nla6911e.woff?t=1750598435466') format('woff'),
|
||||
url('//at.alicdn.com/t/c/font_4945922_ou2nla6911e.ttf?t=1750598435466') format('truetype');
|
||||
}
|
||||
|
||||
.iconfont {
|
||||
font-family: "iconfont" !important;
|
||||
font-size: 16px;
|
||||
font-style: normal;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.icon-fanhui:before {
|
||||
content: "\e601";
|
||||
}
|
||||
|
||||
.icon-sousuo:before {
|
||||
content: "\e733";
|
||||
}
|
||||
|
||||
.icon-riqi:before {
|
||||
content: "\e675";
|
||||
}
|
||||
|
||||
.icon-nanbaobao:before {
|
||||
content: "\e60a";
|
||||
}
|
||||
|
||||
.icon-jiahao2:before {
|
||||
content: "\e660";
|
||||
}
|
||||
|
||||
.icon-zengjiatianjiajiahao:before {
|
||||
content: "\e62a";
|
||||
}
|
||||
|
||||
.icon-gantanhao_icon:before {
|
||||
content: "\e65b";
|
||||
}
|
||||
|
||||
.icon-touxiang:before {
|
||||
content: "\e62c";
|
||||
}
|
||||
|
||||
.icon-youjiantou:before {
|
||||
content: "\e612";
|
||||
}
|
||||
|
||||
.icon-shouji:before {
|
||||
content: "\e6f7";
|
||||
}
|
||||
|
||||
.icon-xiaoxi:before {
|
||||
content: "\e600";
|
||||
}
|
||||
|
||||
.icon-jiahao1:before {
|
||||
content: "\e727";
|
||||
}
|
||||
|
||||
.icon-jiahao:before {
|
||||
content: "\e783";
|
||||
}
|
||||
|
||||
.icon-dianzan:before {
|
||||
content: "\e694";
|
||||
}
|
||||
|
||||
.icon-bianji:before {
|
||||
content: "\e67b";
|
||||
}
|
||||
|
||||
.icon-shanchu1:before {
|
||||
content: "\e67d";
|
||||
}
|
||||
|
||||
.icon-xiangji:before {
|
||||
content: "\e609";
|
||||
}
|
||||
1
miniprogram_npm/tdesign-miniprogram/.wechatide.ib.json
Normal file
85
miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.d.ts
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
import { SuperComponent } from '../common/src/index';
|
||||
export default class ActionSheet extends SuperComponent {
|
||||
static show: (options: import("./show").ActionSheetShowOption) => WechatMiniprogram.Component.TrivialInstance;
|
||||
behaviors: string[];
|
||||
externalClasses: string[];
|
||||
properties: {
|
||||
align?: {
|
||||
type: StringConstructor;
|
||||
value?: "left" | "center";
|
||||
};
|
||||
cancelText?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
count?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
description?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
items: {
|
||||
type: ArrayConstructor;
|
||||
value?: (string | import("./type").ActionSheetItem)[];
|
||||
required?: boolean;
|
||||
};
|
||||
popupProps?: {
|
||||
type: ObjectConstructor;
|
||||
value?: import("../popup").TdPopupProps;
|
||||
};
|
||||
showCancel?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
showOverlay?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
theme?: {
|
||||
type: StringConstructor;
|
||||
value?: "list" | "grid";
|
||||
};
|
||||
usingCustomNavbar?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
visible?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
defaultVisible?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
};
|
||||
data: {
|
||||
prefix: string;
|
||||
classPrefix: string;
|
||||
gridThemeItems: any[];
|
||||
currentSwiperIndex: number;
|
||||
defaultPopUpProps: {};
|
||||
defaultPopUpzIndex: number;
|
||||
};
|
||||
controlledProps: {
|
||||
key: string;
|
||||
event: string;
|
||||
}[];
|
||||
observers: {
|
||||
'visible, items'(visible: boolean): void;
|
||||
};
|
||||
methods: {
|
||||
init(): void;
|
||||
memoInitialData(): void;
|
||||
splitGridThemeActions(): void;
|
||||
show(options: any): void;
|
||||
close(): void;
|
||||
onPopupVisibleChange({ detail }: {
|
||||
detail: any;
|
||||
}): void;
|
||||
onSwiperChange(e: WechatMiniprogram.TouchEvent): void;
|
||||
onSelect(event: WechatMiniprogram.TouchEvent): void;
|
||||
onCancel(): void;
|
||||
};
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
import{__decorate}from"tslib";import{chunk}from"../common/utils";import{SuperComponent,wxComponent}from"../common/src/index";import config from"../common/config";import{ActionSheetTheme,show}from"./show";import props from"./props";import useCustomNavbar from"../mixins/using-custom-navbar";const{prefix:prefix}=config,name=`${prefix}-action-sheet`;let ActionSheet=class extends SuperComponent{constructor(){super(...arguments),this.behaviors=[useCustomNavbar],this.externalClasses=[`${prefix}-class`,`${prefix}-class-content`,`${prefix}-class-cancel`],this.properties=Object.assign({},props),this.data={prefix:prefix,classPrefix:name,gridThemeItems:[],currentSwiperIndex:0,defaultPopUpProps:{},defaultPopUpzIndex:11500},this.controlledProps=[{key:"visible",event:"visible-change"}],this.observers={"visible, items"(e){e&&this.init()}},this.methods={init(){this.memoInitialData(),this.splitGridThemeActions()},memoInitialData(){this.initialData=Object.assign(Object.assign({},this.properties),this.data)},splitGridThemeActions(){this.data.theme===ActionSheetTheme.Grid&&this.setData({gridThemeItems:chunk(this.data.items,this.data.count)})},show(e){this.setData(Object.assign(Object.assign(Object.assign({},this.initialData),e),{visible:!0})),this.splitGridThemeActions(),this.autoClose=!0,this._trigger("visible-change",{visible:!0})},close(){this.triggerEvent("close",{trigger:"command"}),this._trigger("visible-change",{visible:!1})},onPopupVisibleChange({detail:e}){e.visible||(this.triggerEvent("close",{trigger:"overlay"}),this._trigger("visible-change",{visible:!1})),this.autoClose&&(this.setData({visible:!1}),this.autoClose=!1)},onSwiperChange(e){const{current:t}=e.detail;this.setData({currentSwiperIndex:t})},onSelect(e){const{currentSwiperIndex:t,items:i,gridThemeItems:s,count:o,theme:r}=this.data,{index:n}=e.currentTarget.dataset,a=r===ActionSheetTheme.Grid,h=a?s[t][n]:i[n],c=a?n+t*o:n;h&&(this.triggerEvent("selected",{selected:h,index:c}),h.disabled||(this.triggerEvent("close",{trigger:"select"}),this._trigger("visible-change",{visible:!1})))},onCancel(){this.triggerEvent("cancel"),this.autoClose&&(this.setData({visible:!1}),this.autoClose=!1)}}}};ActionSheet.show=show,ActionSheet=__decorate([wxComponent()],ActionSheet);export default ActionSheet;
|
||||
@ -0,0 +1 @@
|
||||
{"component":true,"styleIsolation":"apply-shared","usingComponents":{"t-icon":"../icon/icon","t-popup":"../popup/popup","t-grid":"../grid/grid","t-grid-item":"../grid-item/grid-item"}}
|
||||
@ -0,0 +1 @@
|
||||
<wxs src="./action-sheet.wxs" module="_this"/><wxs src="../common/utils.wxs" module="_"/><import src="./template/list.wxml"/><import src="./template/grid.wxml"/><view id="{{classPrefix}}" style="{{_._style([style, customStyle])}}" class="{{classPrefix}} class {{prefix}}-class"><t-popup visible="{{visible}}" placement="bottom" usingCustomNavbar="{{usingCustomNavbar}}" bind:visible-change="onPopupVisibleChange" show-overlay="{{showOverlay}}" z-index="{{ popupProps.zIndex || defaultPopUpzIndex }}" overlay-props="{{ popupProps.overlayProps || defaultPopUpProps }}"><view class="{{_.cls(classPrefix + '__content', [['grid', gridThemeItems.length]])}} {{prefix}}-class-content" tabindex="0"><view wx:if="{{description}}" tabindex="0" class="{{_.cls(classPrefix + '__description', [align])}}">{{description}}</view><block wx:if="{{gridThemeItems.length}}"><template is="grid" data="{{classPrefix, prefix, gridThemeItems, count, currentSwiperIndex}}"/></block><view wx:elif="{{items && items.length}}" class="{{classPrefix}}__list"><block wx:for="{{ items }}" wx:key="index"><template is="list" data="{{index, classPrefix, listThemeItemClass: _.cls(classPrefix + '__list-item', [align, [disabled, item.disabled]]), item}}"/></block></view></view><slot/><view wx:if="{{showCancel}}" class="{{classPrefix}}__footer"><view class="{{classPrefix}}__gap-{{theme}}"/><view class="{{classPrefix}}__cancel {{prefix}}-class-cancel" hover-class="{{classPrefix}}__cancel--hover" hover-stay-time="70" bind:tap="onCancel" aria-role="button">{{ cancelText || '取消' }}</view></view></t-popup></view>
|
||||
@ -0,0 +1,19 @@
|
||||
var getListThemeItemClass = function (props) {
|
||||
var classPrefix = props.classPrefix;
|
||||
var item = props.item;
|
||||
var prefix = props.prefix;
|
||||
var classList = [classPrefix + '__list-item'];
|
||||
if (item.disabled) {
|
||||
classList.push(prefix + '-is-disabled');
|
||||
}
|
||||
return classList.join(' ');
|
||||
};
|
||||
|
||||
var isImage = function (name) {
|
||||
return name.indexOf('/') !== -1;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getListThemeItemClass: getListThemeItemClass,
|
||||
isImage: isImage,
|
||||
};
|
||||
@ -0,0 +1 @@
|
||||
@import '../common/style/index.wxss';.t-action-sheet__content{color:var(--td-action-sheet-color,var(--td-text-color-primary,var(--td-font-gray-1,rgba(0,0,0,.9))));border-top-left-radius:var(--td-action-sheet-border-radius,var(--td-radius-extra-large,24rpx));border-top-right-radius:var(--td-action-sheet-border-radius,var(--td-radius-extra-large,24rpx));background-color:var(--td-bg-color-container,var(--td-font-white-1,#fff));overflow:hidden}.t-action-sheet__content--grid{padding-top:16rpx}.t-action-sheet__content:focus{outline:0}.t-action-sheet__grid{padding-bottom:16rpx}.t-action-sheet__grid--swiper{padding-bottom:48rpx}.t-action-sheet__description{color:var(--td-action-sheet-description-color,var(--td-text-color-placeholder,var(--td-font-gray-3,rgba(0,0,0,.4))));line-height:44rpx;font-size:28rpx;text-align:var(--td-action-sheet-text-align,center);padding:24rpx 32rpx;position:relative}.t-action-sheet__description:focus{outline:0}.t-action-sheet__description::after{content:'';display:block;position:absolute;top:unset;bottom:0;left:unset;right:unset;background-color:var(--td-action-sheet-border-color,var(--td-border-level-1-color,var(--td-gray-color-3,#e7e7e7)))}.t-action-sheet__description::after{height:1px;left:0;right:0;transform:scaleY(.5)}.t-action-sheet__description--left{text-align:left}.t-action-sheet__description--left::after{left:32rpx}.t-action-sheet__list-item{display:flex;align-items:center;justify-content:center;position:relative;height:var(--td-action-sheet-list-item-height,112rpx);padding:0 32rpx}.t-action-sheet__list-item::after{content:'';display:block;position:absolute;top:unset;bottom:0;left:unset;right:unset;background-color:var(--td-action-sheet-border-color,var(--td-border-level-1-color,var(--td-gray-color-3,#e7e7e7)))}.t-action-sheet__list-item::after{height:1px;left:0;right:0;transform:scaleY(.5)}.t-action-sheet__list-item:focus{outline:0}.t-action-sheet__list-item--left{justify-content:start}.t-action-sheet__list-item--left::after{left:32rpx}.t-action-sheet__list-item--disabled{color:var(--td-action-sheet-list-item-disabled-color,var(--td-text-color-disabled,var(--td-font-gray-4,rgba(0,0,0,.26))))}.t-action-sheet__list-item-text{font-size:var(--td-font-size-m,32rpx);word-wrap:normal;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.t-action-sheet__list-item-icon{margin-right:16rpx}.t-action-sheet__list-item-icon--suffix{margin-left:auto}.t-action-sheet__swiper-wrap{margin-top:8rpx;position:relative}.t-action-sheet__footer{background-color:var(--td-bg-color-container,var(--td-font-white-1,#fff))}.t-action-sheet__gap-list{height:16rpx;background-color:var(--td-action-sheet-gap-color,var(--td-bg-color-page,var(--td-gray-color-1,#f3f3f3)))}.t-action-sheet__gap-grid{height:1rpx;background-color:var(--td-action-sheet-border-color,var(--td-border-level-1-color,var(--td-gray-color-3,#e7e7e7)))}.t-action-sheet__cancel{display:flex;align-items:center;justify-content:center;color:var(--td-action-sheet-cancel-color,var(--td-text-color-primary,var(--td-font-gray-1,rgba(0,0,0,.9))));height:var(--td-action-sheet-cancel-height,96rpx)}.t-action-sheet__dots{position:absolute;left:50%;bottom:32rpx;transform:translateX(-50%);display:flex;flex-direction:row}.t-action-sheet__dots-item{width:16rpx;height:16rpx;background-color:#dcdcdc;border-radius:50%;margin:0 16rpx;transition:all .4s ease-in}.t-action-sheet__dots-item.t-is-active{background-color:#0052d9}
|
||||
8
miniprogram_npm/tdesign-miniprogram/action-sheet/index.d.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
/// <reference types="miniprogram-api-typings" />
|
||||
import { ActionSheetItem, ActionSheetTheme, ActionSheetShowOption } from './show';
|
||||
export { ActionSheetItem, ActionSheetTheme, ActionSheetShowOption };
|
||||
declare const _default: {
|
||||
show(options: ActionSheetShowOption): WechatMiniprogram.Component.TrivialInstance;
|
||||
close(options: ActionSheetShowOption): void;
|
||||
};
|
||||
export default _default;
|
||||
@ -0,0 +1 @@
|
||||
import{show,close,ActionSheetTheme}from"./show";export{ActionSheetTheme};export default{show:e=>show(e),close:e=>close(e)};
|
||||
3
miniprogram_npm/tdesign-miniprogram/action-sheet/props.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { TdActionSheetProps } from './type';
|
||||
declare const props: TdActionSheetProps;
|
||||
export default props;
|
||||
@ -0,0 +1 @@
|
||||
const props={align:{type:String,value:"center"},cancelText:{type:String,value:""},count:{type:Number,value:8},description:{type:String,value:""},items:{type:Array,required:!0},popupProps:{type:Object,value:{}},showCancel:{type:Boolean,value:!0},showOverlay:{type:Boolean,value:!0},theme:{type:String,value:"list"},usingCustomNavbar:{type:Boolean,value:!1},visible:{type:Boolean,value:null},defaultVisible:{type:Boolean,value:!1}};export default props;
|
||||
26
miniprogram_npm/tdesign-miniprogram/action-sheet/show.d.ts
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
/// <reference types="miniprogram-api-typings" />
|
||||
/// <reference types="miniprogram-api-typings" />
|
||||
import { ActionSheetItem } from './type';
|
||||
export { ActionSheetItem };
|
||||
declare type Context = WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance;
|
||||
export declare enum ActionSheetTheme {
|
||||
List = "list",
|
||||
Grid = "grid"
|
||||
}
|
||||
interface ActionSheetProps {
|
||||
align: 'center' | 'left';
|
||||
cancelText?: string;
|
||||
count?: number;
|
||||
description: string;
|
||||
items: Array<string | ActionSheetItem>;
|
||||
showCancel?: boolean;
|
||||
theme?: ActionSheetTheme;
|
||||
visible: boolean;
|
||||
defaultVisible?: boolean;
|
||||
}
|
||||
export interface ActionSheetShowOption extends Omit<ActionSheetProps, 'visible'> {
|
||||
context?: Context;
|
||||
selector?: string;
|
||||
}
|
||||
export declare const show: (options: ActionSheetShowOption) => WechatMiniprogram.Component.TrivialInstance;
|
||||
export declare const close: (options: ActionSheetShowOption) => void;
|
||||
1
miniprogram_npm/tdesign-miniprogram/action-sheet/show.js
Normal file
@ -0,0 +1 @@
|
||||
import{__rest}from"tslib";import{getInstance}from"../common/utils";export var ActionSheetTheme;!function(t){t.List="list",t.Grid="grid"}(ActionSheetTheme||(ActionSheetTheme={}));export const show=function(t){const e=Object.assign({},t),{context:o,selector:n="#t-action-sheet"}=e,c=__rest(e,["context","selector"]),s=getInstance(o,n);if(s)return s.show(Object.assign({},c)),s;console.error("未找到组件,请确认 selector && context 是否正确")};export const close=function(t){const{context:e,selector:o="#t-action-sheet"}=Object.assign({},t),n=getInstance(e,o);n&&n.close()};
|
||||
@ -0,0 +1 @@
|
||||
<template name="grid"><block wx:if="{{gridThemeItems.length === 1}}"><t-grid align="center" t-class="{{classPrefix}}__grid" column="{{count / 2}}" class="{{classPrefix}}__single-wrap"><t-grid-item t-class="{{classPrefix}}__grid-item" class="{{classPrefix}}__square" wx:for="{{gridThemeItems[0]}}" wx:key="index" bind:tap="onSelect" data-index="{{index}}" icon="{{ { name: item.icon, color: item.color } }}" text="{{item.label || ''}}" image="{{item.image || ''}}" style="--td-grid-item-text-color: {{item.color}}"></t-grid-item></t-grid></block><block wx:elif="{{gridThemeItems.length > 1}}"><view class="{{classPrefix}}__swiper-wrap"><swiper style="height: 456rpx" autoplay="{{false}}" current="{{currentSwiperIndex}}" bindchange="onSwiperChange"><swiper-item wx:for="{{gridThemeItems}}" wx:key="index"><t-grid align="center" t-class="{{classPrefix}}__grid {{classPrefix}}__grid--swiper" column="{{count / 2}}"><t-grid-item t-class="{{classPrefix}}__grid-item" class="{{classPrefix}}__square" wx:for="{{item}}" wx:key="index" data-index="{{index}}" bind:tap="onSelect" icon="{{ { name: item.icon, color: item.color } }}" text="{{item.label || ''}}" image="{{item.image || ''}}" style="--td-grid-item-text-color: {{item.color}}"></t-grid-item></t-grid></swiper-item></swiper><view class="{{classPrefix}}__nav"><view class="{{classPrefix}}__dots"><view wx:for="{{gridThemeItems.length}}" wx:key="index" class="{{classPrefix}}__dots-item {{index === currentSwiperIndex ? prefix + '-is-active' : ''}}"/></view></view></view></block></template>
|
||||
@ -0,0 +1 @@
|
||||
<template name="list"><view data-index="{{index}}" style="{{ item.color ? 'color: ' + item.color : '' }}" class="{{listThemeItemClass}}" bind:tap="onSelect" aria-role="{{ariaRole || 'button'}}" aria-label="{{item.label || item}}" tabindex="0"><t-icon wx:if="{{item.icon}}" name="{{item.icon}}" class="{{classPrefix}}__list-item-icon" size="48rpx"></t-icon><view class="{{classPrefix}}__list-item-text">{{item.label || item}}</view><t-icon wx:if="{{item.suffixIcon}}" name="{{item.suffixIcon}}" class="{{classPrefix}}__list-item-icon {{classPrefix}}__list-item-icon--suffix" size="48rpx"></t-icon></view></template>
|
||||
59
miniprogram_npm/tdesign-miniprogram/action-sheet/type.d.ts
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
import { PopupProps } from '../popup/index';
|
||||
export interface TdActionSheetProps {
|
||||
align?: {
|
||||
type: StringConstructor;
|
||||
value?: 'center' | 'left';
|
||||
};
|
||||
cancelText?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
count?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
description?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
items: {
|
||||
type: ArrayConstructor;
|
||||
value?: Array<string | ActionSheetItem>;
|
||||
required?: boolean;
|
||||
};
|
||||
popupProps?: {
|
||||
type: ObjectConstructor;
|
||||
value?: PopupProps;
|
||||
};
|
||||
showCancel?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
showOverlay?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
theme?: {
|
||||
type: StringConstructor;
|
||||
value?: 'list' | 'grid';
|
||||
};
|
||||
usingCustomNavbar?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
visible?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
defaultVisible?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
}
|
||||
export interface ActionSheetItem {
|
||||
label: string;
|
||||
color?: string;
|
||||
disabled?: boolean;
|
||||
icon?: string;
|
||||
suffixIcon?: string;
|
||||
}
|
||||
1
miniprogram_npm/tdesign-miniprogram/action-sheet/type.js
Normal file
@ -0,0 +1 @@
|
||||
export{};
|
||||
28
miniprogram_npm/tdesign-miniprogram/avatar-group/avatar-group.d.ts
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
import { SuperComponent, RelationsOptions } from '../common/src/index';
|
||||
export default class AvatarGroup extends SuperComponent {
|
||||
externalClasses: string[];
|
||||
properties: import("./type").TdAvatarGroupProps;
|
||||
data: {
|
||||
prefix: string;
|
||||
classPrefix: string;
|
||||
hasChild: boolean;
|
||||
length: number;
|
||||
className: string;
|
||||
};
|
||||
options: {
|
||||
multipleSlots: boolean;
|
||||
};
|
||||
relations: RelationsOptions;
|
||||
lifetimes: {
|
||||
attached(): void;
|
||||
ready(): void;
|
||||
};
|
||||
observers: {
|
||||
'cascading, size'(): void;
|
||||
};
|
||||
methods: {
|
||||
setClass(): void;
|
||||
handleMax(): void;
|
||||
onCollapsedItemClick(e: WechatMiniprogram.CustomEvent): void;
|
||||
};
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
import{__decorate}from"tslib";import{SuperComponent,wxComponent}from"../common/src/index";import config from"../common/config";import avatarGroupProps from"./props";const{prefix:prefix}=config,name=`${prefix}-avatar-group`;let AvatarGroup=class extends SuperComponent{constructor(){super(...arguments),this.externalClasses=[`${prefix}-class`,`${prefix}-class-content`,`${prefix}-class-image`],this.properties=avatarGroupProps,this.data={prefix:prefix,classPrefix:name,hasChild:!0,length:0,className:""},this.options={multipleSlots:!0},this.relations={"../avatar/avatar":{type:"descendant"}},this.lifetimes={attached(){this.setClass()},ready(){this.setData({length:this.$children.length}),this.handleMax()}},this.observers={"cascading, size"(){this.setClass()}},this.methods={setClass(){const{cascading:e,size:t}=this.properties,s=e.split("-")[0],a=[name,`${prefix}-class`,`${name}-offset-${s}`,`${name}-offset-${s}-${t.indexOf("px")>-1?"medium":t||"medium"}`];this.setData({className:a.join(" ")})},handleMax(){const{max:e}=this.data,t=this.$children.length;if(!e||e>t)return;this.$children.splice(e,t-e).forEach((e=>{e.hide()}))},onCollapsedItemClick(e){this.triggerEvent("collapsed-item-click",e.detail)}}}};AvatarGroup=__decorate([wxComponent()],AvatarGroup);export default AvatarGroup;
|
||||
@ -0,0 +1 @@
|
||||
{"component":true,"styleIsolation":"shared","usingComponents":{"t-avatar":"../avatar/avatar"}}
|
||||
@ -0,0 +1 @@
|
||||
<wxs src="../common/utils.wxs" module="_"/><view style="{{_._style([style, customStyle])}}" class="{{className}} class"><slot/><view class="{{classPrefix}}__collapse--slot"><slot name="collapse-avatar"/></view><view class="{{classPrefix}}__collapse--default" wx:if="{{max && (max < length)}}" bindtap="onCollapsedItemClick"><t-avatar t-class-image="{{prefix}}-avatar--border {{prefix}}-avatar--border-{{size}} {{prefix}}-class-image" t-class-content="{{prefix}}-class-content" size="{{size}}" shape="{{shape}}" icon="{{ collapseAvatar ? '' : 'user-add'}}" aria-role="none">{{collapseAvatar}}</t-avatar></view></view>
|
||||
3
miniprogram_npm/tdesign-miniprogram/avatar-group/props.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { TdAvatarGroupProps } from './type';
|
||||
declare const props: TdAvatarGroupProps;
|
||||
export default props;
|
||||
@ -0,0 +1 @@
|
||||
const props={cascading:{type:String,value:"left-up"},collapseAvatar:{type:String},max:{type:Number},shape:{type:String},size:{type:String,value:""}};export default props;
|
||||
24
miniprogram_npm/tdesign-miniprogram/avatar-group/type.d.ts
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
import { ShapeEnum } from '../common/common';
|
||||
export interface TdAvatarGroupProps {
|
||||
cascading?: {
|
||||
type: StringConstructor;
|
||||
value?: CascadingValue;
|
||||
};
|
||||
collapseAvatar?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
max?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
shape?: {
|
||||
type: StringConstructor;
|
||||
value?: ShapeEnum;
|
||||
};
|
||||
size?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
}
|
||||
export declare type CascadingValue = 'left-up' | 'right-up';
|
||||
1
miniprogram_npm/tdesign-miniprogram/avatar-group/type.js
Normal file
@ -0,0 +1 @@
|
||||
export{};
|
||||
22
miniprogram_npm/tdesign-miniprogram/avatar/avatar.d.ts
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
/// <reference types="miniprogram-api-typings" />
|
||||
import { SuperComponent, RelationsOptions } from '../common/src/index';
|
||||
export default class Avatar extends SuperComponent {
|
||||
options: WechatMiniprogram.Component.ComponentOptions;
|
||||
externalClasses: string[];
|
||||
properties: import("./type").TdAvatarProps;
|
||||
data: {
|
||||
prefix: string;
|
||||
classPrefix: string;
|
||||
isShow: boolean;
|
||||
zIndex: number;
|
||||
systemInfo: WechatMiniprogram.WindowInfo | WechatMiniprogram.SystemInfo;
|
||||
};
|
||||
relations: RelationsOptions;
|
||||
observers: {
|
||||
icon(icon: any): void;
|
||||
};
|
||||
methods: {
|
||||
hide(): void;
|
||||
onLoadError(e: WechatMiniprogram.CustomEvent): void;
|
||||
};
|
||||
}
|
||||
1
miniprogram_npm/tdesign-miniprogram/avatar/avatar.js
Normal file
@ -0,0 +1 @@
|
||||
import{__decorate}from"tslib";import{SuperComponent,wxComponent}from"../common/src/index";import config from"../common/config";import avatarProps from"./props";import{setIcon,systemInfo}from"../common/utils";const{prefix:prefix}=config,name=`${prefix}-avatar`;let Avatar=class extends SuperComponent{constructor(){super(...arguments),this.options={multipleSlots:!0},this.externalClasses=[`${prefix}-class`,`${prefix}-class-image`,`${prefix}-class-icon`,`${prefix}-class-alt`,`${prefix}-class-content`],this.properties=avatarProps,this.data={prefix:prefix,classPrefix:name,isShow:!0,zIndex:0,systemInfo:systemInfo},this.relations={"../avatar-group/avatar-group":{type:"ancestor",linked(t){this.parent=t,this.setData({shape:this.data.shape||t.data.shape||"circle",size:this.data.size||t.data.size,bordered:!0})}}},this.observers={icon(t){const s=setIcon("icon",t,"");this.setData(Object.assign({},s))}},this.methods={hide(){this.setData({isShow:!1})},onLoadError(t){this.properties.hideOnLoadFailed&&this.setData({isShow:!1}),this.triggerEvent("error",t.detail)}}}};Avatar=__decorate([wxComponent()],Avatar);export default Avatar;
|
||||
1
miniprogram_npm/tdesign-miniprogram/avatar/avatar.json
Normal file
@ -0,0 +1 @@
|
||||
{"component":true,"styleIsolation":"shared","usingComponents":{"t-icon":"../icon/icon","t-badge":"../badge/badge","t-image":"../image/image"}}
|
||||
1
miniprogram_npm/tdesign-miniprogram/avatar/avatar.wxml
Normal file
@ -0,0 +1 @@
|
||||
<import src="../common/template/icon.wxml"/><wxs src="../common/utils.wxs" module="_"/><wxs src="./avatar.wxs" module="_this"/><view class="{{classPrefix}}__wrapper class {{prefix}}-class" style="{{_._style([_this.getStyles(isShow), style, customStyle])}}"><t-badge color="{{badgeProps.color || ''}}" content="{{badgeProps.content || ''}}" count="{{badgeProps.count || 0}}" dot="{{badgeProps.dot || false}}" max-count="{{badgeProps.maxCount || 99}}" offset="{{badgeProps.offset || []}}" shape="{{badgeProps.shape || 'circle'}}" show-zero="{{badgeProps.showZero || false}}" size="{{badgeProps.size || 'medium'}}" t-class="{{badgeProps.tClass}}" t-class-content="{{badgeProps.tClassContent}}" t-class-count="{{badgeProps.tClassCount}}"><view class="{{_this.getClass(classPrefix, size || 'medium', shape, bordered)}} {{prefix}}-class-image" style="{{_this.getSize(size, systemInfo)}}" aria-label="{{ ariaLabel || alt ||'头像'}}" aria-role="{{ ariaRole || 'img'}}" aria-hidden="{{ ariaHidden }}"><t-image wx:if="{{image}}" t-class="{{prefix}}-image {{classPrefix}}__image" t-class-load="{{prefix}}-class-alt" style="{{imageProps && imageProps.style || ''}}" src="{{image}}" mode="{{imageProps && imageProps.mode || 'aspectFill'}}" lazy="{{imageProps && imageProps.lazy || false}}" loading="{{imageProps && imageProps.loading || 'default'}}" shape="{{imageProps && imageProps.shape || 'round'}}" webp="{{imageProps && imageProps.webp || false}}" error="{{alt || 'default'}}" bind:error="onLoadError"/><template wx:elif="{{iconName || _.isNoEmptyObj(iconData)}}" is="icon" data="{{tClass: classPrefix + '__icon ' + prefix + '-class-icon', name: iconName, ...iconData}}"/><view wx:else class="{{classPrefix}}__text {{prefix}}-class-content"><slot/></view></view></t-badge></view>
|
||||
30
miniprogram_npm/tdesign-miniprogram/avatar/avatar.wxs
Normal file
@ -0,0 +1,30 @@
|
||||
module.exports = {
|
||||
getClass: function (classPrefix, size, shape, bordered) {
|
||||
var hasPx = (size || '').indexOf('px') > -1;
|
||||
var borderSize = hasPx ? 'medium' : size;
|
||||
var classNames = [
|
||||
classPrefix,
|
||||
classPrefix + (shape === 'round' ? '--round' : '--circle'),
|
||||
bordered ? classPrefix + '--border' + ' ' + classPrefix + '--border-' + borderSize : '',
|
||||
hasPx ? '' : classPrefix + '--' + size,
|
||||
];
|
||||
return classNames.join(' ');
|
||||
},
|
||||
|
||||
getSize: function (size = 'medium', systemInfo) {
|
||||
var res = getRegExp('^([0-9]+)(px|rpx)$').exec(size);
|
||||
|
||||
if (res && res.length >= 3) {
|
||||
var px = res[1];
|
||||
if (res[2] === 'rpx') {
|
||||
px = Math.floor((systemInfo.windowWidth * res[1]) / 750);
|
||||
}
|
||||
|
||||
return 'width:' + size + ';height:' + size + ';font-size:' + ((px / 8) * 3 + 2) + 'px';
|
||||
}
|
||||
},
|
||||
|
||||
getStyles: function (isShow) {
|
||||
return isShow ? '' : 'display: none;';
|
||||
},
|
||||
};
|
||||
1
miniprogram_npm/tdesign-miniprogram/avatar/avatar.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/style/index.wxss';.t-avatar{display:flex;align-items:center;justify-content:center;box-sizing:border-box;background-color:var(--td-avatar-bg-color,var(--td-brand-color-light-active,var(--td-primary-color-2,#d9e1ff)));color:var(--td-avatar-content-color,var(--td-brand-color,var(--td-primary-color-7,#0052d9)))}.t-avatar__wrapper{display:inline-flex;position:relative;vertical-align:top;margin-left:var(--td-avatar-margin-left,0)}.t-avatar--large{width:var(--td-avatar-large-width,128rpx);height:var(--td-avatar-large-width,128rpx);font-size:var(--td-avatar-text-large-font-size,var(--td-font-size-xl,40rpx))}.t-avatar--large .t-avatar__icon{font-size:var(--td-avatar-icon-large-font-size,64rpx)}.t-avatar--medium{width:var(--td-avatar-medium-width,96rpx);height:var(--td-avatar-medium-width,96rpx);font-size:var(--td-avatar-text-medium-font-size,var(--td-font-size-m,32rpx))}.t-avatar--medium .t-avatar__icon{font-size:var(--td-avatar-icon-medium-font-size,48rpx)}.t-avatar--small{width:var(--td-avatar-small-width,80rpx);height:var(--td-avatar-small-width,80rpx);font-size:var(--td-avatar-text-small-font-size,var(--td-font-size-base,28rpx))}.t-avatar--small .t-avatar__icon{font-size:var(--td-avatar-icon-small-font-size,40rpx)}.t-avatar .t-image,.t-avatar__image{width:100%;height:100%}.t-avatar--circle{border-radius:var(--td-avatar-circle-border-radius,var(--td-radius-circle,50%));overflow:hidden}.t-avatar--round{border-radius:var(--td-avatar-round-border-radius,var(--td-radius-default,12rpx));overflow:hidden}.t-avatar__icon,.t-avatar__text{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.t-avatar__icon:empty,.t-avatar__text:empty{width:0;height:0}.t-avatar--border{border-color:var(--td-avatar-border-color,#fff);border-style:solid}.t-avatar--border-small{border-width:var(--td-avatar-border-width-small,2rpx)}.t-avatar--border-medium{border-width:var(--td-avatar-border-width-medium,4rpx)}.t-avatar--border-large{border-width:var(--td-avatar-border-width-large,6rpx)}
|
||||
3
miniprogram_npm/tdesign-miniprogram/avatar/props.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { TdAvatarProps } from './type';
|
||||
declare const props: TdAvatarProps;
|
||||
export default props;
|
||||
1
miniprogram_npm/tdesign-miniprogram/avatar/props.js
Normal file
@ -0,0 +1 @@
|
||||
const props={alt:{type:String,value:""},badgeProps:{type:Object},bordered:{type:Boolean,value:!1},hideOnLoadFailed:{type:Boolean,value:!1},icon:{type:null},image:{type:String,value:""},imageProps:{type:Object},shape:{type:String},size:{type:String,value:""}};export default props;
|
||||
41
miniprogram_npm/tdesign-miniprogram/avatar/type.d.ts
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
import { BadgeProps } from '../badge/index';
|
||||
import { ImageProps } from '../image/index';
|
||||
import { ShapeEnum } from '../common/common';
|
||||
export interface TdAvatarProps {
|
||||
alt?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
badgeProps?: {
|
||||
type: ObjectConstructor;
|
||||
value?: BadgeProps;
|
||||
};
|
||||
bordered?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
hideOnLoadFailed?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
icon?: {
|
||||
type: null;
|
||||
value?: string | object;
|
||||
};
|
||||
image?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
imageProps?: {
|
||||
type: ObjectConstructor;
|
||||
value?: ImageProps;
|
||||
};
|
||||
shape?: {
|
||||
type: StringConstructor;
|
||||
value?: ShapeEnum;
|
||||
};
|
||||
size?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
}
|
||||
1
miniprogram_npm/tdesign-miniprogram/avatar/type.js
Normal file
@ -0,0 +1 @@
|
||||
export{};
|
||||
26
miniprogram_npm/tdesign-miniprogram/back-top/back-top.d.ts
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
import { SuperComponent, RelationsOptions } from '../common/src/index';
|
||||
export default class BackTop extends SuperComponent {
|
||||
externalClasses: string[];
|
||||
options: {
|
||||
multipleSlots: boolean;
|
||||
};
|
||||
properties: import("./type").TdBackTopProps;
|
||||
relations: RelationsOptions;
|
||||
data: {
|
||||
prefix: string;
|
||||
classPrefix: string;
|
||||
_icon: any;
|
||||
hidden: boolean;
|
||||
};
|
||||
observers: {
|
||||
icon(): void;
|
||||
scrollTop(value: number): void;
|
||||
};
|
||||
lifetimes: {
|
||||
ready(): void;
|
||||
};
|
||||
methods: {
|
||||
setIcon(v: any): void;
|
||||
toTop(): void;
|
||||
};
|
||||
}
|
||||
1
miniprogram_npm/tdesign-miniprogram/back-top/back-top.js
Normal file
@ -0,0 +1 @@
|
||||
import{__decorate}from"tslib";import{SuperComponent,wxComponent}from"../common/src/index";import config from"../common/config";import props from"./props";import{calcIcon}from"../common/utils";const{prefix:prefix}=config,name=`${prefix}-back-top`;let BackTop=class extends SuperComponent{constructor(){super(...arguments),this.externalClasses=[`${prefix}-class`,`${prefix}-class-icon`,`${prefix}-class-text`],this.options={multipleSlots:!0},this.properties=props,this.relations={"../pull-down-refresh/pull-down-refresh":{type:"ancestor"}},this.data={prefix:prefix,classPrefix:name,_icon:null,hidden:!0},this.observers={icon(){this.setIcon()},scrollTop(o){const{visibilityHeight:t}=this.properties;this.setData({hidden:o<t})}},this.lifetimes={ready(){const{icon:o}=this.properties;this.setIcon(o)}},this.methods={setIcon(o){this.setData({_icon:calcIcon(o,"backtop")})},toTop(){var o;this.triggerEvent("to-top"),this.$parent?(null===(o=this.$parent)||void 0===o||o.setScrollTop(0),this.setData({hidden:!0})):wx.pageScrollTo({scrollTop:0,duration:300})}}}};BackTop=__decorate([wxComponent()],BackTop);export default BackTop;
|
||||
@ -0,0 +1 @@
|
||||
{"component":true,"styleIsolation":"apply-shared","usingComponents":{"t-icon":"../icon/icon"}}
|
||||
@ -0,0 +1 @@
|
||||
<import src="../common/template/icon.wxml"/><wxs src="../common/utils.wxs" module="_"/><view style="{{_._style([style, customStyle])}}" class="class {{prefix}}-class {{_.cls(classPrefix, [['fixed', fixed], theme])}}" bindtap="toTop" aria-role="button" hidden="{{hidden}}"><view class="{{classPrefix}}__icon" aria-hidden><slot name="icon"/><template wx:if="{{_icon}}" is="icon" data="{{tClass: prefix + '-class-icon', ..._icon }}"/></view><view wx:if="{{!!text}}" class="{{classPrefix}}__text--{{theme}} {{prefix}}-class-text">{{text}}</view><slot/></view>
|
||||
@ -0,0 +1 @@
|
||||
@import '../common/style/index.wxss';.t-back-top{display:flex;flex-direction:column;align-items:center;justify-content:center;background-color:transparent;overflow:hidden;box-sizing:border-box;transition:height .2s;height:auto}.t-back-top--fixed{position:fixed;right:var(--td-spacer,16rpx);bottom:calc(var(--td-spacer-2,32rpx) + env(safe-area-inset-bottom))}.t-back-top--round,.t-back-top--round-dark{width:96rpx;height:96rpx;border-radius:var(--td-back-top-round-border-radius,var(--td-radius-circle,50%))}.t-back-top--half-round,.t-back-top--round{color:var(--td-back-top-round-color,var(--td-text-color-primary,var(--td-font-gray-1,rgba(0,0,0,.9))));border:1rpx solid var(--td-back-top-round-border-color,var(--td-component-border,var(--td-gray-color-4,#dcdcdc)));background-color:var(--td-back-top-round-bg-color,var(--td-bg-color-container,var(--td-font-white-1,#fff)))}.t-back-top--half-round-dark,.t-back-top--round-dark{color:var(--td-back-top-round-dark-color,var(--td-text-color-anti,var(--td-font-white-1,#fff)));background-color:var(--td-back-top-round-dark-bg-color,var(--td-gray-color-13,#242424))}.t-back-top--half-round,.t-back-top--half-round-dark{width:120rpx;height:80rpx;border-radius:0;border-top-left-radius:var(--td-back-top-half-round-border-radius,var(--td-radius-round,999px));border-bottom-left-radius:var(--td-back-top-half-round-border-radius,var(--td-radius-round,999px));flex-direction:row;right:0}.t-back-top__text--half-round,.t-back-top__text--half-round-dark,.t-back-top__text--round,.t-back-top__text--round-dark{font-size:var(--td-font-size,20rpx);line-height:24rpx}.t-back-top__text--half-round,.t-back-top__text--half-round-dark{width:48rpx}.t-back-top__icon:not(:empty)+.t-back-top__text--half-round,.t-back-top__icon:not(:empty)+.t-back-top__text--half-round-dark{margin-left:8rpx}.t-back-top__icon{display:flex;justify-content:center;align-items:center;font-size:44rpx}
|
||||
3
miniprogram_npm/tdesign-miniprogram/back-top/props.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { TdBackTopProps } from './type';
|
||||
declare const props: TdBackTopProps;
|
||||
export default props;
|
||||
1
miniprogram_npm/tdesign-miniprogram/back-top/props.js
Normal file
@ -0,0 +1 @@
|
||||
const props={fixed:{type:Boolean,value:!0},icon:{type:null,value:!0},scrollTop:{type:Number,value:0},style:{type:String,value:""},text:{type:String,value:""},theme:{type:String,value:"round"},visibilityHeight:{type:Number,value:200}};export default props;
|
||||
30
miniprogram_npm/tdesign-miniprogram/back-top/type.d.ts
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
export interface TdBackTopProps {
|
||||
fixed?: {
|
||||
type: BooleanConstructor;
|
||||
value?: boolean;
|
||||
};
|
||||
icon?: {
|
||||
type: null;
|
||||
value?: string | boolean | object;
|
||||
};
|
||||
scrollTop?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
style?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
text?: {
|
||||
type: StringConstructor;
|
||||
value?: string;
|
||||
};
|
||||
theme?: {
|
||||
type: StringConstructor;
|
||||
value?: 'round' | 'half-round' | 'round-dark' | 'half-round-dark';
|
||||
};
|
||||
visibilityHeight?: {
|
||||
type: NumberConstructor;
|
||||
value?: number;
|
||||
};
|
||||
}
|
||||
1
miniprogram_npm/tdesign-miniprogram/back-top/type.js
Normal file
@ -0,0 +1 @@
|
||||
export{};
|
||||
21
miniprogram_npm/tdesign-miniprogram/badge/badge.d.ts
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
import { SuperComponent } from '../common/src/index';
|
||||
import type { TdBadgeProps } from './type';
|
||||
export interface BadgeProps extends TdBadgeProps {
|
||||
}
|
||||
export default class Badge extends SuperComponent {
|
||||
options: {
|
||||
multipleSlots: boolean;
|
||||
};
|
||||
externalClasses: string[];
|
||||
properties: TdBadgeProps;
|
||||
data: {
|
||||
prefix: string;
|
||||
classPrefix: string;
|
||||
value: string;
|
||||
labelID: string;
|
||||
descriptionID: string;
|
||||
};
|
||||
lifetimes: {
|
||||
ready(): void;
|
||||
};
|
||||
}
|
||||
1
miniprogram_npm/tdesign-miniprogram/badge/badge.js
Normal file
@ -0,0 +1 @@
|
||||
import{__decorate}from"tslib";import{SuperComponent,wxComponent}from"../common/src/index";import config from"../common/config";import props from"./props";import{uniqueFactory}from"../common/utils";const{prefix:prefix}=config,name=`${prefix}-badge`,getUniqueID=uniqueFactory("badge");let Badge=class extends SuperComponent{constructor(){super(...arguments),this.options={multipleSlots:!0},this.externalClasses=[`${prefix}-class`,`${prefix}-class-count`,`${prefix}-class-content`],this.properties=props,this.data={prefix:prefix,classPrefix:name,value:"",labelID:"",descriptionID:""},this.lifetimes={ready(){const e=getUniqueID();this.setData({labelID:`${e}_label`,descriptionID:`${e}_description`})}}}};Badge=__decorate([wxComponent()],Badge);export default Badge;
|
||||
1
miniprogram_npm/tdesign-miniprogram/badge/badge.json
Normal file
@ -0,0 +1 @@
|
||||
{"component":true,"styleIsolation":"apply-shared","usingComponents":{}}
|
||||
1
miniprogram_npm/tdesign-miniprogram/badge/badge.wxml
Normal file
@ -0,0 +1 @@
|
||||
<wxs src="./badge.wxs" module="_this"/><wxs src="../common/utils.wxs" module="_"/><view style="{{_._style([style, customStyle])}}" class="{{_this.getBadgeOuterClass({shape})}} class {{prefix}}-class" aria-labelledby="{{labelID}}" aria-describedby="{{descriptionID}}" aria-role="{{ ariaRole || 'option'}}"><view id="{{labelID}}" class="{{classPrefix}}__content {{prefix}}-class-content" aria-hidden="true"><slot wx:if="{{!content}}" class="{{classPrefix}}__content-slot"/><text wx:else class="{{classPrefix}}__content-text">{{content}}</text></view><view aria-hidden="true" aria-label="{{ ariaLabel || _.getBadgeAriaLabel({dot, count, maxCount}) }}" wx:if="{{_this.isShowBadge({dot,count,showZero})}}" id="{{descriptionID}}" class="{{_this.getBadgeInnerClass({dot, size, shape, count})}} {{prefix}}-has-count {{prefix}}-class-count" style="{{_._style([_this.getBadgeStyles({color, offset})])}}" aria-hidden="true" aria-label="{{ ariaLabel || _.getBadgeAriaLabel({dot, count, maxCount}) }}">{{ _this.getBadgeValue({dot, count, maxCount}) }}</view><slot name="count"/></view>
|
||||
71
miniprogram_npm/tdesign-miniprogram/badge/badge.wxs
Normal file
@ -0,0 +1,71 @@
|
||||
var getBadgeValue = function (props) {
|
||||
if (props.dot) {
|
||||
return '';
|
||||
}
|
||||
if (isNaN(props.count) || isNaN(props.maxCount)) {
|
||||
return props.count;
|
||||
}
|
||||
return parseInt(props.count) > props.maxCount ? props.maxCount + '+' : props.count;
|
||||
};
|
||||
|
||||
var hasUnit = function (unit) {
|
||||
return (
|
||||
unit.indexOf('px') > 0 ||
|
||||
unit.indexOf('rpx') > 0 ||
|
||||
unit.indexOf('em') > 0 ||
|
||||
unit.indexOf('rem') > 0 ||
|
||||
unit.indexOf('%') > 0 ||
|
||||
unit.indexOf('vh') > 0 ||
|
||||
unit.indexOf('vm') > 0
|
||||
);
|
||||
};
|
||||
|
||||
var getBadgeStyles = function (props) {
|
||||
var styleStr = '';
|
||||
if (props.color) {
|
||||
styleStr += 'background:' + props.color + ';';
|
||||
}
|
||||
if (props.offset[0]) {
|
||||
styleStr +=
|
||||
'left: calc(100% + ' + (hasUnit(props.offset[0].toString()) ? props.offset[0] : props.offset[0] + 'px') + ');';
|
||||
}
|
||||
if (props.offset[1]) {
|
||||
styleStr += 'top:' + (hasUnit(props.offset[1].toString()) ? props.offset[1] : props.offset[1] + 'px') + ';';
|
||||
}
|
||||
return styleStr;
|
||||
};
|
||||
|
||||
var getBadgeOuterClass = function (props) {
|
||||
var baseClass = 't-badge';
|
||||
var classNames = [baseClass, props.shape === 'ribbon' ? baseClass + '__ribbon-outer' : ''];
|
||||
return classNames.join(' ');
|
||||
};
|
||||
|
||||
var getBadgeInnerClass = function (props) {
|
||||
var baseClass = 't-badge';
|
||||
var classNames = [
|
||||
baseClass + '--basic',
|
||||
props.dot ? baseClass + '--dot' : '',
|
||||
baseClass + '--' + props.size,
|
||||
baseClass + '--' + props.shape,
|
||||
!props.dot && props.count ? baseClass + '--count' : '',
|
||||
];
|
||||
return classNames.join(' ');
|
||||
};
|
||||
|
||||
var isShowBadge = function (props) {
|
||||
if (props.dot) {
|
||||
return true;
|
||||
}
|
||||
if (!props.showZero && !isNaN(props.count) && parseInt(props.count) === 0) {
|
||||
return false;
|
||||
}
|
||||
if (props.count == null) return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports.getBadgeValue = getBadgeValue;
|
||||
module.exports.getBadgeStyles = getBadgeStyles;
|
||||
module.exports.getBadgeOuterClass = getBadgeOuterClass;
|
||||
module.exports.getBadgeInnerClass = getBadgeInnerClass;
|
||||
module.exports.isShowBadge = isShowBadge;
|
||||
1
miniprogram_npm/tdesign-miniprogram/badge/badge.wxss
Normal file
@ -0,0 +1 @@
|
||||
@import '../common/style/index.wxss';.t-badge{position:relative;display:inline-flex;align-items:start}.t-badge--basic{z-index:100;padding:0 var(--td-badge-basic-padding,8rpx);font-size:var(--td-badge-font-size,var(--td-font-size-xs,var(--td-font-size,20rpx)));color:var(--td-badge-text-color,var(--td-text-color-anti,var(--td-font-white-1,#fff)));background-color:var(--td-badge-bg-color,var(--td-error-color,var(--td-error-color-6,#d54941)));text-align:center;height:var(--td-badge-basic-height,32rpx);line-height:var(--td-badge-basic-height,32rpx);font-weight:var(--td-badge-font-weight,600);border-radius:var(--td-badge-border-radius,4rpx)}.t-badge--dot{height:var(--td-badge-dot-size,16rpx);border-radius:50%;min-width:var(--td-badge-dot-size,16rpx);padding:0}.t-badge--count{min-width:var(--td-badge-basic-width,32rpx);white-space:nowrap;box-sizing:border-box}.t-badge--circle{border-radius:calc(var(--td-badge-basic-height,32rpx)/ 2)}.t-badge__ribbon-outer{position:absolute;top:0;right:0}.t-badge--ribbon{position:relative;display:inline-block;transform-origin:center center;transform:translate(calc(50% - var(--td-badge-basic-height,32rpx) + 1rpx),calc(-50% + var(--td-badge-basic-height,32rpx) - 1rpx)) rotate(45deg);border-radius:0}.t-badge--ribbon::after,.t-badge--ribbon::before{content:'';position:absolute;width:0;height:0;bottom:0;border-bottom:var(--td-badge-basic-height,32rpx) solid var(--td-badge-bg-color,var(--td-error-color,var(--td-error-color-6,#d54941)));font-size:0}.t-badge--ribbon::before{left:calc(-1 * var(--td-badge-basic-height,32rpx) + 1rpx);border-left:var(--td-badge-basic-height,32rpx) solid transparent}.t-badge--ribbon::after{right:calc(-1 * var(--td-badge-basic-height,32rpx) + 1rpx);border-right:var(--td-badge-basic-height,32rpx) solid transparent}.t-badge--bubble{border-radius:var(--td-badge-bubble-border-radius,20rpx 20rpx 20rpx 1px)}.t-badge--large{font-size:var(--td-badge-large-font-size,var(--td-font-size-s,24rpx));height:var(--td-badge-large-height,40rpx);min-width:var(--td-badge-large-height,40rpx);line-height:var(--td-badge-large-height,40rpx);padding:0 var(--td-badge-large-padding,10rpx)}.t-badge--large.t-badge--circle{border-radius:calc(var(--td-badge-large-height,40rpx)/ 2)}.t-badge__content:not(:empty)+.t-has-count{transform-origin:center center;transform:translate(-50%,-50%);position:absolute;left:100%;top:0}.t-badge__content-text{display:block;line-height:48rpx;color:var(--td-badge-content-text-color,var(--td-text-color-primary,var(--td-font-gray-1,rgba(0,0,0,.9))))}
|
||||
3
miniprogram_npm/tdesign-miniprogram/badge/index.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export * from './type';
|
||||
export * from './props';
|
||||
export * from './badge';
|
||||