From dc01187c6ca2cf46fef268e84a7ac7fc171f2ebb Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期一, 27 五月 2024 16:12:47 +0800
Subject: [PATCH] 开泵相关
---
pages/wxbind/wxbind.js | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 102 insertions(+), 0 deletions(-)
diff --git a/pages/wxbind/wxbind.js b/pages/wxbind/wxbind.js
new file mode 100644
index 0000000..d0ee79f
--- /dev/null
+++ b/pages/wxbind/wxbind.js
@@ -0,0 +1,102 @@
+// pages/wxbind/wxbind.js
+const app = getApp();
+Page({
+
+ /**
+ * 椤甸潰鐨勫垵濮嬫暟鎹�
+ */
+ data: {
+ mobile: '',
+ code: '',
+ codeSent: false,
+ countdown: 60,
+ isButtonEnabled: false
+ },
+ bindMobileInput(e) {
+ this.setData({
+ mobile: e.detail.value
+ }, this.checkButtonState);
+ },
+
+ bindCodeInput(e) {
+ this.setData({
+ code: e.detail.value
+ }, this.checkButtonState);
+ },
+ checkButtonState() {
+ const {
+ mobile,
+ code
+ } = this.data;
+ const isButtonEnabled = mobile.length === 11 && code.length == 6;
+ this.setData({
+ isButtonEnabled
+ });
+ console.log(isButtonEnabled);
+ },
+ sendCode: function () {
+ if (!this.data.mobile) {
+ wx.showToast({
+ title: '璇疯緭鍏ユ墜鏈哄彿',
+ icon: 'none',
+ duration: 2000,
+ });
+ return;
+ }
+
+ // 鍦ㄨ繖閲屽鐞嗗彂閫侀獙璇佺爜鐨勯�昏緫锛屽彲浠ヨ皟鐢ㄥ悗鍙版帴鍙e疄鐜�
+ // 浠ヤ笅鏄竴涓畝鍗曠殑绀轰緥锛屼粎浣滃弬鑰�
+ wx.showToast({
+ title: '楠岃瘉鐮佸凡鍙戦��',
+ icon: 'success',
+ duration: 2000,
+ });
+
+ this.setData({
+ codeSent: true,
+ });
+
+ // 鍚姩鍊掕鏃�
+ this.startCountdown();
+ },
+ //鍊掕鏃�
+ startCountdown: function () {
+ let that = this;
+ let timer = setInterval(function () {
+ let countdown = that.data.countdown - 1;
+ that.setData({
+ countdown: countdown,
+ });
+
+ if (countdown <= 0) {
+ clearInterval(timer);
+ that.setData({
+ codeSent: false,
+ countdown: 60,
+ });
+ }
+ }, 1000);
+ },
+ bind: function () {
+ if (!this.data.isButtonEnabled) return;
+ wx.showToast({
+ title: '缁戝畾鎴愬姛',
+ icon: 'success'
+ });
+ // 璺宠浆鍒� TabBar 椤甸潰
+ wx.switchTab({
+ url: '/pages/home/home' // 杩欓噷濉啓浣犳兂瑕佽烦杞殑 TabBar 椤甸潰璺緞
+ });
+ },
+ postCode: function () {
+ post('/items', { name: 'New Item' })
+ .then((data) => {
+ this.setData({
+ items: [...this.data.items, data]
+ });
+ })
+ .catch((error) => {
+ console.error('Failed to add item:', error);
+ });
+ }
+})
\ No newline at end of file
--
Gitblit v1.8.0