添加组件及页面

This commit is contained in:
zhengw
2026-01-21 17:05:30 +08:00
parent a89e69c381
commit 7ff1a911dd
54 changed files with 1078 additions and 1009 deletions

View File

@@ -16,9 +16,9 @@ Component({
},
lifetimes: {
attached() {
setTimeout(() => {
this.getSlotHeight();
}, 100);
// setTimeout(() => {
// this.getSlotHeight();
// }, 100);
},
},
@@ -27,7 +27,7 @@ Component({
*/
data: {
showMore: false,
showMoreBar: false,
showMoreBar: true,
},
/**
* 组件的方法列表
@@ -38,7 +38,7 @@ Component({
const query = wx.createSelectorQuery().in(this);
// 2. 查询插槽容器节点
query
.select("#contentSlot")
.select('#contentSlot')
.boundingClientRect((rect) => {
if (rect) {
const height = rect.height; // 获取节点高度单位px
@@ -54,7 +54,7 @@ Component({
.exec(); // 执行查询
},
click(e: any) {
this.triggerEvent("tap", e);
this.triggerEvent('tap', e);
},
showMoreTap() {
this.setData({

View File

@@ -1,9 +1,13 @@
<view class="card_plugin {{className}}" style="border: 1rpx solid #ddd;margin-bottom: 12px;border-radius: 4px;{{customStyle}}" bind:tap="click">
<view class="header" style="border-bottom: 1rpx solid #ddd;padding: 8px 12px;font-weight: bold;{{headerStyle || ''}}">
<view class="card_plugin {{className}}"
style="border: 1rpx solid #ddd;margin-bottom: 24rpx;border-radius: 8rpx;{{customStyle}}"
bind:tap="click">
<view class="header"
style="border-bottom: 1rpx solid #ddd;padding: 16rpx 24rpx;font-weight: bold;{{headerStyle || ''}}">
<slot name="header" />
</view>
<view class="content" style="padding:8px 12px;{{contentStyle || ''}}">
<view id="contentSlot" style="height: {{showMoreBar ? showMore ? 'auto' : 'calc(3em * 1.57)' : 'auto'}};overflow: hidden;">
<view class="content" style="padding:16rpx 24rpx;{{contentStyle || ''}}">
<view id="contentSlot"
style="height: {{showMoreBar ? showMore ? 'auto' : 'calc(3em * 1.57)' : 'auto'}};overflow: hidden;">
<slot name="content" />
</view>
<view wx:if="{{showMoreBar}}" class="show-more" catch:tap="showMoreTap">
@@ -14,5 +18,4 @@
<view class="footer" style="{{footerStyle||''}}">
<slot name="footer" />
</view>
</view>
</view>

View File

@@ -26,7 +26,7 @@
<slot name="tbody" />
</block>
<block wx:else>
<view wx:if="{{data.length == 0}}" class="tr" style="height: 32px" />
<view wx:if="{{data.length == 0}}" class="tr" style="height: 64rpx" />
<block wx:for="{{data}}" wx:key="index" wx:for-item="record">
<view class="tr">
<block wx:for="{{columns}}" wx:key="index">
@@ -37,5 +37,4 @@
</block>
</view>
</view>
<view wx:if="{{!useTbodySlot && data.length == 0}}" class="empty-data">暂无数据</view>
<view wx:if="{{!useTbodySlot && data.length == 0}}" class="empty-data">暂无数据</view>

View File

@@ -1,7 +1,7 @@
.table-box {
border-left: 1px solid #ddd;
border-right: 1px solid #ddd;
border-bottom: 1px solid #ddd;
border-left: 1rpx solid #ddd;
border-right: 1rpx solid #ddd;
border-bottom: 1rpx solid #ddd;
overflow: auto;
}
@@ -38,14 +38,14 @@
.th,
.td {
display: table-cell;
border-bottom: 1px solid #ddd;
padding: 4px;
border-right: 1px solid #ddd;
border-bottom: 1rpx solid #ddd;
padding: 8rpx;
border-right: 1rpx solid #ddd;
vertical-align: middle;
}
.tr .th {
border-top: 1px solid #ddd;
border-top: 1rpx solid #ddd;
}
.tr .th:last-child,
@@ -65,7 +65,7 @@
.empty-data {
text-align: center;
margin-top: -33px;
line-height: 30px;
margin-top: -66rpx;
line-height: 60rpx;
color: #999;
}

View File

@@ -1,4 +1,4 @@
<view style="min-height: 95vh;display: flex;justify-content: center;flex-direction: column;">
<view style="min-height: 90vh;display: flex;justify-content: center;flex-direction: column;">
<t-empty icon="info-circle-filled">
<view slot="description" style="color: #000;">
<view>抱歉!您当前没有权限访问该页面</view>
@@ -7,4 +7,4 @@
</view>
<t-button theme="primary" slot="action" bind:tap="navIndex">前往首页</t-button>
</t-empty>
</view>
</view>

View File

@@ -1,6 +1,7 @@
import { base, defaultAvatarUrl } from "@/utils/config";
import { Subscribe } from "@/utils/subscribe";
import { setStorage } from "@/utils/util";
import { base, defaultAvatarUrl } from '@/utils/config';
import { login } from '@/utils/https';
import { Subscribe } from '@/utils/subscribe';
import { isArray, setStorage } from '@/utils/util';
// import { IStorage } from "@/utils/storage";
// const app = getApp();
@@ -13,6 +14,7 @@ Component({
loading: Boolean,
isAuth: null,
customStyle: null,
hasTabBar: null,
},
// attached() {
@@ -35,24 +37,24 @@ Component({
appletName: base.appletName,
show: false,
companyList: [],
encryptedData: "",
iv: "",
encryptedData: '',
iv: '',
},
methods: {
handleLogin(e: any) {
this.triggerEvent("handleLogin", e.detail);
this.triggerEvent('handleLogin', e.detail);
},
getPhoneNumberToast() {
setStorage("isLogin", 1);
Subscribe.set("isLogin", "zzzuz");
wx.showToast({ title: "请先勾选协议", icon: "none" });
setStorage('isLogin', 1);
Subscribe.set('isLogin', 'zzzuz');
wx.showToast({ title: '请先勾选协议', icon: 'none' });
},
changeAgreementCheck(event: any) {
this.setData({ isAgree: event.detail.checked });
},
navAgreement(e: any) {
wx.navigateTo({
url: "../agreement/agreement?type=" + e.target.dataset.type,
url: '../agreement/agreement?type=' + e.target.dataset.type,
});
},
// getPhoneNumber(e) {
@@ -64,23 +66,23 @@ Component({
this.data.iv = e.detail.iv;
console.log(e);
// login(e.detail.encryptedData, e.detail.iv)
// .then((res) => {
// console.log(res);
// if (isArray(res.data)) {
// this.setData({
// companyList: res.data,
// show: true,
// });
// } else {
// this.triggerEvent("handleLogin", true);
// }
// })
// .catch((err) => {
// this.triggerEvent("handleLogin", false);
// });
login(e.detail.encryptedData, e.detail.iv)
.then((res) => {
console.log(res);
if (isArray(res.data)) {
this.setData({
companyList: res.data,
show: true,
});
} else {
this.triggerEvent('handleLogin', true);
}
})
.catch((err) => {
this.triggerEvent('handleLogin', false);
});
} else {
wx.showToast({ title: e.detail.errMsg, icon: "none" });
wx.showToast({ title: e.detail.errMsg, icon: 'none' });
}
},
login2(e: any) {

View File

@@ -1,38 +1,43 @@
<block wx:if="{{isLogin}}">
<view wx:if="{{isAuth}}" style="padding: 12px;padding-bottom: env(safe-area-inset-bottom);{{customStyle ||''}}">
<view wx:if="{{isAuth}}"
style="padding: 24rpx;padding-bottom: {{ hasTabBar == '1' ? 'calc(var(--td-tab-bar-height,80rpx) + env(safe-area-inset-bottom) + 32rpx)' :'env(safe-area-inset-bottom)'}};{{customStyle ||''}}">
<slot></slot>
</view>
<no-auth-plugin wx:else />
</block>
<block wx:else>
<t-loading wx:if="{{loading}}" theme="spinner" fullscreen text="加载中..." layout="vertical" />
<view wx:else style="padding: 0 16px;height: 100vh;justify-content: center;display: flex;flex-direction: column;">
<view wx:else
style="padding: 0 32rpx;height: 90vh;justify-content: center;display: flex;flex-direction: column;">
<view style="display: flex;justify-content: center;">
<view style="width: 80px;height: 80px;overflow: hidden;border-radius: 80px;">
<image style="width: 100%;height: 100%;object-fit: cover;" src="{{avatarUrl}}" mode="cover" />
<view style="width: 160rpx;height: 160rpx;overflow: hidden;border-radius: 160rpx;">
<image style="width: 100%;height: 100%;object-fit: cover;" src="{{avatarUrl}}"
mode="cover" />
</view>
</view>
<view style="padding: 20px 0">
<view style="padding: 40rpx 0">
<view>本小程序仅供{{appletName}}用户使用</view>
<view>申请获取以下权限</view>
<view>获取您的公开信息(昵称,头像等)</view>
</view>
<t-button wx:if="{{isAgree}}" block open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" theme="primary">
<t-button wx:if="{{isAgree}}" block open-type="getPhoneNumber"
bindgetphonenumber="getPhoneNumber" theme="primary">
一键登录
</t-button>
<t-button wx:else block type="primary" bindtap="getPhoneNumberToast">
一键登录
</t-button>
<t-checkbox borderless style="padding: 0;margin: 1em 0;" value="{{isAgree}}" bind:change="changeAgreementCheck">
<t-checkbox borderless style="padding: 0;margin: 1em 0;" value="{{isAgree}}"
bind:change="changeAgreementCheck">
我已阅读并同意
</t-checkbox>
<t-link theme="primary" bindtap="navAgreement" data-type="user" style="margin-bottom: 8px;">
<t-link theme="primary" bindtap="navAgreement" data-type="user" style="margin-bottom: 16rpx;">
《{{appletName}}平台用户服务协议》
</t-link>
<t-link theme="primary" bindtap="navAgreement" data-type="privacy" style="margin-bottom: 8px;">
<t-link theme="primary" bindtap="navAgreement" data-type="privacy"
style="margin-bottom: 16rpx;">
《{{appletName}}隐私权政策》
</t-link>
</view>
</block>
</block>

View File

@@ -1,42 +1,19 @@
<view class="box">
<view wx:if="{{total}}" class="box">
<view>共{{total}}条</view>
<t-button
size="small"
disabled="{{curr_page == 1}}"
bindtap="pageChange"
data-page="prev"
icon="chevron-left"
style="padding-left: 8px;padding-right: 8px"
/>
<t-button size="small" disabled="{{curr_page == 1}}" bindtap="pageChange" data-page="prev"
icon="chevron-left" style="padding-left: 16rpx;padding-right: 16rpx" />
<block wx:for="{{pages}}" wx:key="index">
<t-button
size="small"
theme="{{curr_page == item ? 'primary': ''}}"
variant="{{curr_page == item ? 'outline': ''}}"
bindtap="pageChange"
data-page="{{item}}"
>{{item}}
<t-button size="small" theme="{{curr_page == item ? 'primary': ''}}"
variant="{{curr_page == item ? 'outline': ''}}" bindtap="pageChange" data-page="{{item}}">
{{item}}
</t-button>
</block>
<t-button
size="small"
disabled="{{curr_page == totalPage}}"
bindtap="pageChange"
data-page="next"
icon="chevron-right"
style="padding-left: 8px;padding-right: 8px"
/>
<t-button size="small" bindtap="pageSelect" style="padding-left: 8px;padding-right: 8px">跳转
<t-button size="small" disabled="{{curr_page == totalPage}}" bindtap="pageChange" data-page="next"
icon="chevron-right" style="padding-left: 16rpx;padding-right: 16rpx" />
<t-button size="small" bindtap="pageSelect" style="padding-left: 16rpx;padding-right: 16rpx">跳转
</t-button>
<t-picker
title="选择页码"
visible="{{open}}"
value="{{[curr_page]}}"
cancelBtn="取消"
confirmBtn="确认"
bind:confirm="onConfirm"
>
<t-picker-item options="{{pickerPages}}" />
</t-picker>
</view>
<t-picker title="选择页码" visible="{{open}}" value="{{[curr_page]}}" cancelBtn="取消" confirmBtn="确认"
bind:confirm="onConfirm">
<t-picker-item options="{{pickerPages}}" />
</t-picker>

View File

@@ -1,8 +1,8 @@
.box {
display: flex;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(0, max-content));
column-gap: 16rpx;
row-gap: 16rpx;
align-items: center;
justify-content: center;
flex-wrap: wrap;
column-gap: 8px;
row-gap: 8px;
}

View File

@@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"t-input": "tdesign-miniprogram/input/input"
}
}

View File

@@ -0,0 +1,24 @@
Component({
options: { multipleSlots: true },
/**
* 组件的属性列表
*/
properties: { label: null },
/**
* 组件的初始数据
*/
data: {},
/**
* 组件的方法列表
*/
methods: {
onChange(e: any) {
this.triggerEvent('change', { value: e.detail.value });
},
onClear() {
this.triggerEvent('change', { value: '' });
},
},
});

View File

@@ -0,0 +1 @@
<t-input label="{{label}}" bind:change="onChange" bind:clear="onClear" clearable />

View File

@@ -1,60 +1,29 @@
<view style="display: flex;align-items: center;margin-bottom: 12px;{{customStyle}}">
<view style="flex: 1;margin-right: {{hideMore ? 0 : '12px'}};">
<view style="display: flex;align-items: center;margin-bottom: 24rpx;{{customStyle}}">
<view style="flex: 1;margin-right: {{hideMore ? 0 : '24rpx'}};">
<block wx:if="{{useInputSlot}}">
<slot name='input' />
</block>
<block wx:else>
<t-input
wx:if="{{!hideInput}}"
placeholder="{{placeholder || '请输入关键字'}}"
clearable
borderless
bindchange="change"
value="{{value || ''}}"
data-key="{{dataKey}}"
confirm-type="search"
<t-input wx:if="{{!hideInput}}" placeholder="{{placeholder || '请输入关键字'}}" clearable borderless
bindchange="change" value="{{value || ''}}" data-key="{{dataKey}}" confirm-type="search"
bind:clear="clear"
custom-style="background:#f5f5f5;min-height: var(--td-button-small-height,64rpx);height:var(--td-button-small-height,64rpx);padding: 0;"
size="small"
t-class="aaaaaa"
>
<t-button
name="search"
slot="prefix-icon"
size="small"
theme="primary"
bindtap="scanCode"
icon="scan"
/>
<t-button
slot="suffix-icon"
bindtap="search"
icon="search"
theme="primary"
size="small"
/>
size="small" t-class="aaaaaa">
<t-button name="search" slot="prefix-icon" size="small" theme="primary" bindtap="scanCode"
icon="scan" />
<t-button slot="suffix-icon" bindtap="search" icon="search" theme="primary" size="small" />
</t-input>
</block>
</view>
<t-button
wx:if="{{!hideMore}}"
bindtap="showSearch"
theme="primary"
size="small"
>筛选
<t-button wx:if="{{!hideMore}}" bindtap="showSearch" theme="primary" size="small">筛选
</t-button>
</view>
<popup-plugin visible="{{ show }}" bind:close="close" title="筛选条件">
<slot name='content' />
<slot wx:if="{{useFooterSlot}}" name="footer" />
<view wx:else style="padding: 12px 0;display: flex;justify-content: center;position: sticky;bottom: 0;left: 0;background-color: #fff;z-index: 1;">
<t-button
bindtap="ok"
style="min-width: 80px;"
size="small"
theme="primary"
>搜索
<view wx:else
style="padding: 24rpx 0;display: flex;justify-content: center;position: sticky;bottom: 0;left: 0;background-color: #fff;z-index: 1;">
<t-button bindtap="ok" style="min-width: 80px;" size="small" theme="primary">搜索
</t-button>
</view>
</popup-plugin>
</popup-plugin>

View File

@@ -1,44 +1,24 @@
<view style="display: contents" bindtap="click">
<slot/>
<slot />
</view>
<popup-plugin visible="{{visible}}" bind:close="close" title="{{title}}">
<view style="padding: 12px 0;">
<t-radio-group
wx:if="{{mode == 'single'}}"
bind:change="radioChange"
allow-uncheck
value="{{val}}"
borderless
>
<t-radio
wx:for="{{options}}"
wx:key="index"
value="{{item.value}}"
style="padding-bottom: 6px;padding-top: 6px;"
>{{item.label}}
<view style="padding: 24rpx 0;">
<t-radio-group wx:if="{{mode == 'single'}}" bind:change="radioChange" allow-uncheck
value="{{val}}" borderless>
<t-radio wx:for="{{options}}" wx:key="index" value="{{item.value}}"
style="padding-bottom: 12rpx;padding-top: 12rpx;">{{item.label}}
</t-radio>
</t-radio-group>
<t-checkbox-group
wx:else
value="{{val}}"
bind:change="checkboxChange"
borderless
>
<t-checkbox
style="padding-bottom: 6px;padding-top: 6px;"
wx:for="{{options}}"
icon="rectangle"
wx:key="index"
value="{{item.value}}"
>{{item.label}}
<t-checkbox-group wx:else value="{{val}}" bind:change="checkboxChange" borderless>
<t-checkbox style="padding-bottom: 12rpx;padding-top: 12rpx;" wx:for="{{options}}"
icon="rectangle" wx:key="index" value="{{item.value}}">{{item.label}}
</t-checkbox>
</t-checkbox-group>
</view>
<view class="footer" wx:if="{{ mode == 'multiple' }}">
<t-button size="small" theme="primary" bindtap="ok">确定</t-button>
</view>
</popup-plugin>
</popup-plugin>

View File

@@ -6,5 +6,5 @@
bottom: 0;
background: #fff;
z-index: 1;
padding-top: 12px;
padding-top: 24rpx;
}

View File

@@ -1,5 +1,6 @@
<t-tab-bar t-class="t-tab-bar" value="{{active}}" bindchange="onChange" theme="normal" fixed="{{true}}" split="{{false}}">
<t-tab-bar custom-style="z-index: 9999" bordered value="{{active}}" bindchange="onChange"
theme="normal" fixed="{{true}}" split="{{false}}">
<t-tab-bar-item wx:for="{{list}}" wx:key="value" value="{{item.value}}" icon="{{item.icon}}">
{{item.label}}
</t-tab-bar-item>
</t-tab-bar>
</t-tab-bar>