Просмотр исходного кода

Merge branch 'feature/addBtn' of ssh://121.43.162.141:10022/six.fe/health.applet into release/2.0.1

张田田 7 месяцев назад
Родитель
Сommit
e67df1a9a5

+ 24 - 15
miniprogram/module/article/pages/science-info/science-info.ts

@@ -1,30 +1,39 @@
 import PageContainerBehavior from "../../../../core/behavior/page-container.behavior";
 import PageContainerBehavior from "../../../../core/behavior/page-container.behavior";
-import tickleBehavior, { getTickleContext } from "../../../../core/behavior/tickle.behavior";
+import tickleBehavior, {
+  getTickleContext,
+} from "../../../../core/behavior/tickle.behavior";
 import { getScienceMethod } from "../../request";
 import { getScienceMethod } from "../../request";
 // module/diet/pages/science-info/science-info.ts
 // module/diet/pages/science-info/science-info.ts
 Component({
 Component({
-  behaviors: [
-    PageContainerBehavior,
-    tickleBehavior,
-  ],
+  behaviors: [PageContainerBehavior, tickleBehavior],
   lifetimes: {
   lifetimes: {
     attached() {
     attached() {
       const channel = this.getOpenerEventChannel();
       const channel = this.getOpenerEventChannel();
-      channel.on?.('load', (data: AnyObject) => {
-        this.setData({ title: data?.title ?? '' });
-      })
+      channel.on?.("load", (data: AnyObject) => {
+        // 支持直接传入外链 URL,直接使用 web-view 打开 新加的
+        if (data?.url) {
+          this.setData({
+            dataset: { content: data.url },
+            title: data?.title ?? "",
+          });
+          return;
+        }
+        // ===end===
+
+        this.setData({ title: data?.title ?? "" });
+      });
       this.load();
       this.load();
-    }
+    },
   },
   },
   properties: {
   properties: {
-    id: { type: String, value: '' },
+    id: { type: String, value: "" },
   },
   },
   data: {
   data: {
-    title: ''
+    title: "",
   },
   },
   methods: {
   methods: {
     async load() {
     async load() {
-      wx.showLoading({ title: '加载中' });
+      wx.showLoading({ title: "加载中" });
       try {
       try {
         const dataset = await getScienceMethod(this.data.id);
         const dataset = await getScienceMethod(this.data.id);
         this.setData({ dataset, title: dataset.name });
         this.setData({ dataset, title: dataset.name });
@@ -32,6 +41,6 @@ Component({
         getTickleContext.call(this).showWarnMessage(error.errMsg);
         getTickleContext.call(this).showWarnMessage(error.errMsg);
       }
       }
       wx.hideLoading();
       wx.hideLoading();
-    }
-  }
-})
+    },
+  },
+});

+ 2 - 2
miniprogram/module/health/pages/home/home.wxml

@@ -17,9 +17,9 @@
     </report-health-index>
     </report-health-index>
     <!--我的调养方案-->
     <!--我的调养方案-->
     <care-scheme></care-scheme>
     <care-scheme></care-scheme>
-      <!--随访记录-->
+    <!--随访记录-->
     <follow-record></follow-record>
     <follow-record></follow-record>
-      <!--随访评估-->
+    <!--随访评估-->
     <follow-evaluation></follow-evaluation>
     <follow-evaluation></follow-evaluation>
     <!--调养记录-->
     <!--调养记录-->
     <care-record></care-record>
     <care-record></care-record>

+ 38 - 2
miniprogram/module/health/pages/scheme/scheme.scss

@@ -13,19 +13,24 @@
   background-position: inherit;
   background-position: inherit;
   background-size: cover;
   background-size: cover;
 }
 }
+
 .header-row {
 .header-row {
   display: flex;
   display: flex;
   justify-content: space-between;
   justify-content: space-between;
   align-items: center;
   align-items: center;
   width: 100%;
   width: 100%;
 }
 }
-.t-cell__note, .t-cell__title {
+
+.t-cell__note,
+.t-cell__title {
   margin-left: 0px !important;
   margin-left: 0px !important;
 }
 }
+
 .date-text {
 .date-text {
   display: flex;
   display: flex;
   align-items: center;
   align-items: center;
 }
 }
+
 .recuperate-btn {
 .recuperate-btn {
   display: inline-block;
   display: inline-block;
   padding: 9px 12px;
   padding: 9px 12px;
@@ -35,6 +40,7 @@
   font-size: 14px;
   font-size: 14px;
   text-align: center;
   text-align: center;
 }
 }
+
 .card-wrapper {
 .card-wrapper {
   --button-line-1: 10px;
   --button-line-1: 10px;
 }
 }
@@ -46,7 +52,7 @@
     &-title {
     &-title {
       font-size: 14px;
       font-size: 14px;
       text-align: center;
       text-align: center;
-      margin-bottom: 8px;
+      // margin-bottom: 8px;
     }
     }
   }
   }
 
 
@@ -55,6 +61,8 @@
     font-weight: 600;
     font-weight: 600;
     // color: #34A76B;
     // color: #34A76B;
     color: #1d6ff6;
     color: #1d6ff6;
+    width: 55%;
+    text-align: right;
   }
   }
 
 
   &__description {
   &__description {
@@ -112,4 +120,32 @@
       }
       }
     }
     }
   }
   }
+}
+
+.buy-title {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  width: 55%;
+  text-align: right;
+}
+
+.buy-container {
+  display: flex;
+  width: 100%;
+  position: relative;
+  height: 100rpx;
+}
+
+.buy-box {
+  border: 1px solid #1d6ff6;
+  color: #1d6ff6;
+  border-radius: 4px;
+  font-size: 14px;
+  position: absolute;
+  right: 0;
+  width: 25%;
+  height: 33px;
+  line-height: 33px;
+  text-align: center;
 }
 }

+ 43 - 2
miniprogram/module/health/pages/scheme/scheme.ts

@@ -29,7 +29,7 @@ Component({
       try {
       try {
         const dataset = await healthSchemeMethod(id);
         const dataset = await healthSchemeMethod(id);
         console.log(dataset, '1-->');
         console.log(dataset, '1-->');
-        
+
         this.setData({ dataset });
         this.setData({ dataset });
       } catch (error) {
       } catch (error) {
         console.log(error);
         console.log(error);
@@ -38,6 +38,47 @@ Component({
       }
       }
       wx.hideLoading();
       wx.hideLoading();
     },
     },
-    toReportPage() { toReportPage(this.data.id); }
+    toReportPage() { toReportPage(this.data.id); },
+    // 去购买
+    goBuy(this: any, e: any) {
+      const item = e.currentTarget.dataset.item || {};
+      const type: string = (item.type || item.jumpType || '').toLowerCase();
+      const appId: string = item.appId || item.appID || item.appid || '';
+      const miniPath: string = item.path || item.miniPath || '';
+      const url: string = item.url || item.link || '';
+
+      // 优先按显式类型判断
+      if (type === 'miniprogram' || (!!appId && !type)) {
+        wx.navigateToMiniProgram({
+          appId,
+          path: miniPath,
+          envVersion: 'release',
+          fail: (err) => {
+            getTickleContext.call(this).showWarnMessage(err.errMsg || '跳转小程序失败');
+          }
+        });
+        return;
+      }
+
+      if (type === 'h5' || (!!url && !type)) {
+        if (!url) {
+          getTickleContext.call(this).showWarnMessage('无有效链接');
+          return;
+        }
+        wx.navigateTo({
+          url: '/module/article/pages/science-info/science-info',
+          success: (res) => {
+            res.eventChannel?.emit?.('load', { title: item.title || '详情', url });
+          },
+          fail: (err) => {
+            getTickleContext.call(this).showWarnMessage(err.errMsg || '打开页面失败');
+          }
+        });
+        return;
+      }
+
+      // 无法识别
+      getTickleContext.call(this).showWarnMessage('未识别的跳转类型');
+    }
   }
   }
 })
 })

+ 34 - 30
miniprogram/module/health/pages/scheme/scheme.wxml

@@ -1,43 +1,47 @@
 <!--module/health/pages/scheme/scheme.wxml-->
 <!--module/health/pages/scheme/scheme.wxml-->
 <view class="scheme-container">
 <view class="scheme-container">
-<t-navbar title="调理方案" left-arrow />
+  <t-navbar title="调理方案" left-arrow />
 
 
-<scroll-view class="page-scroll__container" type="list" scroll-y style="{{containerStyle}}">
-  <view class="card-wrapper">   
-    <view class="card-header no-body" bordered="{{false}}" style="background:transparent;padding-right: 6px;padding-left: 6px;" >
-     <view slot="title" class="header-row">
-       <view class="date-text"><text style="color:#8C8C8C">方案日期:</text><text style="color:black">{{dataset.reportTime}}</text></view>
-        <view class="recuperate-btn" bind:tap="toReportPage">健康分析报告</view>
+  <scroll-view class="page-scroll__container" type="list" scroll-y style="{{containerStyle}}">
+    <view class="card-wrapper">
+      <view class="card-header no-body" bordered="{{false}}" style="background:transparent;padding-right: 6px;padding-left: 6px;">
+        <view slot="title" class="header-row">
+          <view class="date-text"><text style="color:#8C8C8C">方案日期:</text><text style="color:black">{{dataset.reportTime}}</text></view>
+          <view class="recuperate-btn" bind:tap="toReportPage">健康分析报告</view>
         </view>
         </view>
+      </view>
     </view>
     </view>
-  </view>
 
 
 
 
-  <view class="card-wrapper" wx:for="{{dataset.children}}" wx:key="title">
-    <t-cell t-class="card-header cell-border-gradient" title="{{item.title}}" />
-    <view class="card-body">
-      <view class="scheme__item" wx:for="{{item.children}}" wx:key="title">
-        <view class="scheme__item-title scheme__title" wx:if="{{item.title}}">{{item.title}}</view>
-        <horizontal-scrollable dataset="{{item.children}}"></horizontal-scrollable>
-        <view class="scheme__description" wx:if="{{item.description}}">{{item.description}}</view>
-        <span class="scheme__description" wx:for="{{item.descriptions}}" wx:key="id">
-          <text class="scheme__title">【{{item.name}}】</text>
-          <text>{{item.description}}</text>
-        </span>
-      </view>
-      <view class="scheme-wrapper">
-        <view class="media-container">
-          <view class="media" wx:for="{{item.media}}" wx:key="*this">
-            <view class="name">{{item.name}}</view>
-            <image wx:if="{{item.type==='picture'}}" src="{{item.mediaUrl}}" mode="aspectFit"></image>
-            <video wx:elif="{{item.type==='video'}}" src="{{item.mediaUrl}}" poster="{{item.imgUrl}}"></video>
-            <view class="description">{{item.description}}</view>
+    <view class="card-wrapper" wx:for="{{dataset.children}}" wx:key="title">
+      <t-cell t-class="card-header cell-border-gradient" title="{{item.title}}" />
+      <view class="card-body">
+        <view class="scheme__item" wx:for="{{item.children}}" wx:key="title">
+          <view class="buy-container">
+            <view class="scheme__item-title scheme__title" wx:if="{{item.title}}">{{item.title}}</view>
+            <view class="scheme__item-title scheme__title" wx:else></view>
+            <view class="buy-box" bindtap="goBuy" data-item="{{item}}" wx:if="{{false}}">去购买</view>
+          </view>
+          <horizontal-scrollable dataset="{{item.children}}"></horizontal-scrollable>
+          <view class="scheme__description" wx:if="{{item.description}}">{{item.description}}</view>
+          <span class="scheme__description" wx:for="{{item.descriptions}}" wx:key="id">
+            <text class="scheme__title">【{{item.name}}】</text>
+            <text>{{item.description}}</text>
+          </span>
+        </view>
+        <view class="scheme-wrapper">
+          <view class="media-container">
+            <view class="media" wx:for="{{item.media}}" wx:key="*this">
+              <view class="name">{{item.name}}</view>
+              <image wx:if="{{item.type==='picture'}}" src="{{item.mediaUrl}}" mode="aspectFit"></image>
+              <video wx:elif="{{item.type==='video'}}" src="{{item.mediaUrl}}" poster="{{item.imgUrl}}"></video>
+              <view class="description">{{item.description}}</view>
+            </view>
           </view>
           </view>
+          <view class="description" wx:for="{{item.descriptions}}" wx:key="*this">{{item}}</view>
         </view>
         </view>
-        <view class="description" wx:for="{{item.descriptions}}" wx:key="*this">{{item}}</view>
       </view>
       </view>
     </view>
     </view>
-  </view>
-</scroll-view>
+  </scroll-view>
 </view>
 </view>
 <t-message id="{{$messageId}}"></t-message>
 <t-message id="{{$messageId}}"></t-message>