初始化项目, 添加TDesign等包
This commit is contained in:
9
miniprogram/pages/components/page-plugin/index.json
Normal file
9
miniprogram/pages/components/page-plugin/index.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"t-button": "tdesign-miniprogram/button/button",
|
||||
"t-checkbox": "tdesign-miniprogram/checkbox/checkbox",
|
||||
"t-divider": "tdesign-miniprogram/divider/divider",
|
||||
"t-link": "tdesign-miniprogram/link/link"
|
||||
}
|
||||
}
|
||||
115
miniprogram/pages/components/page-plugin/index.ts
Normal file
115
miniprogram/pages/components/page-plugin/index.ts
Normal file
@@ -0,0 +1,115 @@
|
||||
import { base, defaultAvatarUrl } from "@/utils/config";
|
||||
import { Subscribe } from "@/utils/subscribe";
|
||||
import { getCurrentPageRoute, getStorage, setStorage } from "@/utils/util";
|
||||
// import { IStorage } from "@/utils/storage";
|
||||
|
||||
// const app = getApp();
|
||||
// const Storage: IStorage = app.Storage;
|
||||
|
||||
Component({
|
||||
options: { addGlobalClass: true },
|
||||
properties: {
|
||||
isLogin: Boolean,
|
||||
loading: Boolean,
|
||||
isAuth: null,
|
||||
style: null,
|
||||
},
|
||||
|
||||
attached() {
|
||||
this.setData({ isLogin: getStorage("isLogin") == 1 });
|
||||
|
||||
console.log("attached");
|
||||
Subscribe.on("isLogin", getCurrentPageRoute(), () => {
|
||||
this.setData({ isLogin: getStorage("isLogin") == 1 });
|
||||
console.log("监听到 isLogin 变化:");
|
||||
});
|
||||
},
|
||||
detached() {
|
||||
console.log("detached");
|
||||
Subscribe.off("isLogin", getCurrentPageRoute());
|
||||
},
|
||||
|
||||
data: {
|
||||
avatarUrl: defaultAvatarUrl,
|
||||
isAgree: false,
|
||||
appletName: base.appletName,
|
||||
show: false,
|
||||
companyList: [],
|
||||
encryptedData: "",
|
||||
iv: "",
|
||||
},
|
||||
methods: {
|
||||
handleLogin(e: any) {
|
||||
this.triggerEvent("handleLogin", e.detail);
|
||||
},
|
||||
getPhoneNumberToast() {
|
||||
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,
|
||||
});
|
||||
},
|
||||
// getPhoneNumber(e) {
|
||||
// this.triggerEvent("getPhoneNumber", e);
|
||||
// },
|
||||
getPhoneNumber(e: any) {
|
||||
if (e.detail.encryptedData) {
|
||||
this.data.encryptedData = e.detail.encryptedData;
|
||||
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);
|
||||
// });
|
||||
} else {
|
||||
wx.showToast({ title: e.detail.errMsg, icon: "none" });
|
||||
}
|
||||
},
|
||||
login2(e: any) {
|
||||
console.log(e.currentTarget.dataset.company_id);
|
||||
// login(
|
||||
// this.data.encryptedData,
|
||||
// this.data.iv,
|
||||
// 2,
|
||||
// e.currentTarget.dataset.company_id
|
||||
// )
|
||||
// .then((res) => {
|
||||
// console.log(res);
|
||||
// if (isArray(res.data)) {
|
||||
// this.setData({
|
||||
// companyList: res.data,
|
||||
// });
|
||||
// } else {
|
||||
// this.setData({
|
||||
// show: false,
|
||||
// });
|
||||
// this.triggerEvent("handleLogin", true);
|
||||
// }
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// this.triggerEvent("handleLogin", false);
|
||||
// });
|
||||
},
|
||||
close() {
|
||||
this.setData({ show: false });
|
||||
},
|
||||
},
|
||||
});
|
||||
37
miniprogram/pages/components/page-plugin/index.wxml
Normal file
37
miniprogram/pages/components/page-plugin/index.wxml
Normal file
@@ -0,0 +1,37 @@
|
||||
<block wx:if="{{isLogin}}">
|
||||
<view wx:if="{{!isAuth}}" style="padding: 12px;padding-bottom: env(safe-area-inset-bottom);{{style ||''}}">
|
||||
<slot></slot>
|
||||
</view>
|
||||
<no_auth_plugin wx:else />
|
||||
</block>
|
||||
<block wx:else>
|
||||
<!-- <loading_plugin wx:if="{{loading}}" /> -->
|
||||
<view style="padding: 0 16px;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"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view style="padding: 20px 0">
|
||||
<view>本小程序仅供{{appletName}}用户使用</view>
|
||||
<view>申请获取以下权限</view>
|
||||
<view>获取您的公开信息(昵称,头像等)</view>
|
||||
</view>
|
||||
<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>
|
||||
<!-- <t-divider /> -->
|
||||
<t-link theme="primary" bindtap="navAgreement" data-type="user" style="margin-bottom: 8px;">
|
||||
《{{appletName}}平台用户服务协议》</t-link>
|
||||
<t-link theme="primary" bindtap="navAgreement" data-type="privacy" style="margin-bottom: 8px;">
|
||||
《{{appletName}}隐私权政策》</t-link>
|
||||
|
||||
</view>
|
||||
</block>
|
||||
1
miniprogram/pages/components/page-plugin/index.wxss
Normal file
1
miniprogram/pages/components/page-plugin/index.wxss
Normal file
@@ -0,0 +1 @@
|
||||
/* components/page-plugin/index.wxss */
|
||||
Reference in New Issue
Block a user