添加组件及页面

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

@@ -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>