cc12458 5 месяцев назад
Родитель
Сommit
2424a7cb7b

+ 3 - 1
miniprogram/components/button/button.json

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

+ 2 - 0
miniprogram/components/button/button.scss

@@ -31,6 +31,8 @@
       color: white;
       border-radius: 5px;
       left: 10px;
+
+      --td-loading-color: #fff;
     }
   }
 

+ 1 - 1
miniprogram/components/button/button.ts

@@ -4,7 +4,7 @@ Component({
   observers: {
     loading(this: any, val: boolean) {
       // 当外部声明 loading 时,同步禁用状态
-      this.setData({ isDisabled: !!val });
+      if (this.data.disableOnClick) this.setData({ isDisabled: !!val });
     },
   },
   lifetimes: {

+ 2 - 1
miniprogram/components/button/button.wxml

@@ -11,6 +11,7 @@
     disabled="{{isDisabled}}"
     hover-class="{{isDisabled ? '' : 'hover'}}"
   >
-    {{list[index].name}}
+    <t-loading wx:if="{{loading}}" theme="spinner" size="36rpx" slot="note" />
+    <block wx:else>{{list[index].name}}</block>
   </button>
 </view>

+ 3 - 1
miniprogram/lib/use/use-phone.ts

@@ -26,7 +26,7 @@ export function usePhoneNumber() {
       _updateStatus.push(callback);
       callback(status)
     },
-    getPhoneNumber(event: WechatMiniprogram.ButtonGetPhoneNumber) {
+    getPhoneNumber(event: WechatMiniprogram.ButtonGetPhoneNumber, callback?: (value?: string) => void) {
       const code = event.detail.code;
       if (!code) return;
       _updateStatus.forEach(cb => cb('loading'))
@@ -38,10 +38,12 @@ export function usePhoneNumber() {
       }).then(phone => {
         value = phone;
         status = 'success';
+        if (typeof callback === 'function') callback(value)
 
         _updataValue.forEach(cb => cb(value))
         _updateStatus.forEach(cb => cb(status))
       }, (error) => {
+        if (typeof callback === 'function') callback()
         _updateStatus.forEach(cb => cb('pending'))
         wx.showModal({ title: '获取失败', content: error.errMsg || error.message, showCancel: false })
       })

+ 3 - 0
miniprogram/lib/wx/update.ts

@@ -1,5 +1,8 @@
 const updateManager = wx.getUpdateManager();
+const env = wx.getAccountInfoSync().miniProgram.envVersion;
 export function appUpdate(force = false) {
+  if (env !== wx.getStorageSync('env')) wx.clearStorageSync();
+  wx.setStorageSync('env', env);
   updateManager.onUpdateReady(function () {
     wx.showModal({
       title: '更新提示',

+ 24 - 4
miniprogram/module/chats/components/guide/guide.ts

@@ -2,6 +2,9 @@
 import { getPatients } from "../../../../pages/home/request";
 import { toCertificationPage } from "../../../../pages/home/router";
 import { Post } from "../../../../lib/request/method";
+
+let next: 'handleA' | 'handleB' | 'handleC';
+
 Component({
   lifetimes: {
     attached(this: any) {
@@ -18,7 +21,14 @@ Component({
   pageLifetimes: {
     show(this: any) {
       // 获取评估剩余次数
-      this.setAnalysisCount();
+      this.setAnalysisCount().then(() => {
+        if (next) {
+          const patientId = wx.getStorageSync('patientId');
+          if (patientId) this[next]();
+          else wx.showToast({ title: '请先完善信息!', icon: 'none' });
+          next = undefined;
+        }
+      });
     },
   },
   properties: {
@@ -41,6 +51,7 @@ Component({
           {},
           {
             transform({ data }: any) {
+              if (data?.usedCou === 0 && data.residuedCou === 0) data.residuedCou = 3;
               return data?.residuedCou;
             },
           }
@@ -52,7 +63,10 @@ Component({
     },
     async handleA() {
       const { patient } = await getPatients(/*this.data.patientId*/);
-      if (!patient) await toCertificationPage();
+      if (!patient) {
+        await toCertificationPage();
+        next = 'handleA';
+      }
       else {
         if (this.data.active) {
           this.triggerEvent("next", {
@@ -65,7 +79,10 @@ Component({
     },
     async handleB() {
       const { patient } = await getPatients(/*this.data.patientId*/);
-      if (!patient) await toCertificationPage();
+      if (!patient) {
+        await toCertificationPage();
+        next = 'handleB';
+      }
       else {
         if (this.data.active)
           wx.navigateTo({
@@ -76,7 +93,10 @@ Component({
     },
     async handleC() {
       const { patient } = await getPatients(/*this.data.patientId*/);
-      if (!patient) await toCertificationPage();
+      if (!patient){
+        await toCertificationPage();
+        next = 'handleC';
+      }
       else {
         if (this.data.active)
           wx.navigateTo({

+ 14 - 8
miniprogram/module/user/pages/user-certification/user-certification.ts

@@ -80,11 +80,10 @@ Component({
       else this.setData({ "privacyContract.agree": agree });
     },
     onAgree() {
-      const submitBtn = this.selectComponent("#submitBtn");
-      console.log("onAgree-->");
-
       this.setData({ "privacyContract.agree": true });
-      if (submitBtn) submitBtn.resetState();
+    },
+    onDisagree() {
+      this.setData({ "privacyContract.agree": false });
     },
     async verifyCardno(event: WechatMiniprogram.InputConfirm) {
       const value = event.detail.value;
@@ -104,19 +103,18 @@ Component({
     },
     async onSubmit(event: WechatMiniprogram.FormSubmit) {
       if (this.data.submitting) return;
-      this.setData({ submitting: true });
+      this.resetSubmitState(true);
       const data = { ...this.data.model, ...event.detail.value };
       data.phone = this.data.model.phone;
-      const submitBtn = this.selectComponent("#submitBtn");
       if (!data.phone) {
-        if (submitBtn) submitBtn.resetState();
+        this.resetSubmitState(false);
         return getTickleContext.call(this).showWarnMessage("请获取手机号码");
       }
       if (!data.agemust) {
         data.agemust = this.data.privacyContract.agree ? "Y" : "N";
       }
       if (data.agemust === "N") {
-        if (submitBtn) submitBtn.resetState();
+        this.resetSubmitState(false);
         this.setData({ "privacyContract.show": true });
         return wx.showToast({
           title: `请阅读并同意${this.data.privacyContract.name}`,
@@ -146,5 +144,13 @@ Component({
         wx.hideLoading();
       }
     },
+    resetSubmitState(loading: boolean) {
+      if (loading) this.setData({ submitting: true });
+      else {
+        this.setData({ submitting: false });
+        const submitBtn = this.selectComponent("#submitBtn");
+        if (submitBtn) submitBtn.resetState();
+      }
+    }
   },
 });

+ 2 - 2
miniprogram/module/user/pages/user-certification/user-certification.wxml

@@ -1,6 +1,6 @@
 <wxs src="../../../../core/wxs/dictionary.wxs" module="dictionary" />
 <!--module/user/pages/user-certification/user-certification.wxml-->
-<t-navbar title="完善信息" left-arrow />
+<t-navbar title="完善信息" left-arrow="{{!hide}}" />
 <scroll-view class="page-scroll__container" type="list" scroll-y style="{{containerStyle}}">
   <form bindsubmit="onSubmit">
     <view class="open-button">
@@ -37,4 +37,4 @@
 </scroll-view>
 
 <t-message id="{{$messageId}}" />
-<popup-privacy show="{{privacyContract.show}}" bind:setting="onPrivacySetting" bind:agree="onAgree"></popup-privacy>
+<popup-privacy show="{{privacyContract.show}}" bind:setting="onPrivacySetting" bind:agree="onAgree" bind:disagree="onDisagree"></popup-privacy>