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

+ 1 - 0
miniprogram/app.json

@@ -26,6 +26,7 @@
         "pages/diet-list/diet-list",
         "pages/diet-info/diet-info",
         "pages/science-list/science-list",
+        "pages/education-list/education-list",
         "pages/science-info/science-info",
         "pages/manage-address/manage-address",
         "pages/add-address/add-address",

+ 5 - 0
miniprogram/module/article/components/education-card/education-card.json

@@ -0,0 +1,5 @@
+{
+  "renderer": "skyline",
+  "component": true,
+  "usingComponents": {}
+}

+ 58 - 0
miniprogram/module/article/components/education-card/education-card.scss

@@ -0,0 +1,58 @@
+/* module/article/components/science-card/science-card.wxss */
+.list-card-item {
+  position: relative;
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+  min-height: 125px;
+  padding: 10px 0;
+  box-sizing: border-box;
+  padding-left: 10px;
+
+  .cover {
+    flex: none;
+    width: 100px;
+    height: 100px;
+    margin-right: 16px;
+    border-radius: 12px;
+  }
+
+  .content {
+    flex: auto;
+    display: flex;
+    flex-direction: column;
+    height: 100px;
+    justify-content: space-evenly;
+  }
+
+  .title {
+    font-size: 16px;
+    // color: #fff;
+    color: #191919;
+    font-weight: bold;
+    // margin-bottom: 10px;
+  }
+
+  .description {
+    font-size: 14px;
+    color: #A2AFB2;
+
+    &-2 {
+      font-size: 14px;
+      // color: #34A76B;
+      // color: #8C8C8C;
+      color: #333333;
+    }
+  }
+
+  .border-gradient {
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: 100%;
+    height: 1px;
+    transform: translateY(-1px);
+    // background: linear-gradient(90deg, rgba(15, 34, 38, 0) 0%, var(--primary-color, #E7E7E7) 50%, rgba(15, 34, 38, 0) 100%);
+    background: linear-gradient(90deg, rgba(15, 34, 38, 0) 0%, #E7E7E7 50%, rgba(15, 34, 38, 0) 100%);
+  }
+}

+ 42 - 0
miniprogram/module/article/components/education-card/education-card.ts

@@ -0,0 +1,42 @@
+// module/article/components/science-card/science-card.ts
+// import { HOST } from "../../../../app.config";
+import { Get } from "../../../../lib/request/method";
+Component({
+  properties: {
+    item: { type: Object, value: {} },
+    index: { type: Number, value: 0 },
+    replace: { type: Boolean, value: false },
+  },
+  data: {},
+  methods: {
+    async toInfoPage(event: WechatMiniprogram.TouchEvent) {
+      const id = event.currentTarget.id;
+      if (this.data.replace) {
+        wx.redirectTo({
+          url: `/module/article/pages/science-info/science-info?id=${id}`,
+        });
+      } else {
+        const id = event.currentTarget.id;
+        // const url = `https://${HOST}/admin/editor/preview.html?popularScienceArticleId=${id}`;
+        try {
+          const res = await Get(`/psarticle/clickPsaNotice`, {
+            params: { noticeSendRecordId: id },
+          });
+          const url = res?.data;
+          const item = {
+            url,
+          };
+          wx.navigateTo({
+            url: `/module/article/pages/science-info/science-info`,
+          }).then((res) => {
+            res.eventChannel.emit("load", item);
+          });
+        } catch (error) {
+          console.log(error);
+        }
+        //   wx.navigateTo({ url: `/module/article/pages/science-info/science-info?id=${id}` })
+        //     .then(res => { res.eventChannel.emit('load', this.data.item) })
+      }
+    },
+  },
+});

+ 12 - 0
miniprogram/module/article/components/education-card/education-card.wxml

@@ -0,0 +1,12 @@
+<!--module/article/components/science-card/science-card.wxml-->
+<view class="list-card-item" id="{{item.noticeSendRecordId}}" bind:tap="toInfoPage">
+  <view class="border-gradient" wx:if="{{index}}">
+    <!--边框-->
+  </view>
+  <!--<image class="cover" src="{{item.briefImg}}" mode="aspectFill" fade-in /> -->
+  <view class="content">
+    <text class="title" max-lines="3" overflow="ellipsis">{{item.noticeName}}</text>
+     <text class="description-2" max-lines="1" overflow="ellipsis" wx:if="{{item.createBy}}">推送医生:{{item.createBy}}</text>
+    <text class="description-2" max-lines="1" overflow="ellipsis" wx:if="{{item.sendTime}}">推送时间:{{item.sendTime}}</text>
+  </view>
+</view>

+ 31 - 11
miniprogram/module/article/components/science-card/science-card.ts

@@ -1,5 +1,6 @@
 // module/article/components/science-card/science-card.ts
-import { HOST } from "../../../../app.config";
+// import { HOST } from "../../../../app.config";
+import { Get } from "../../../../lib/request/method";
 Component({
   properties: {
     item: { type: Object, value: {} },
@@ -8,20 +9,39 @@ Component({
   },
   data: {},
   methods: {
-    toInfoPage(event: WechatMiniprogram.TouchEvent) {
+    async toInfoPage(event: WechatMiniprogram.TouchEvent) {
       const id = event.currentTarget.id;
       if (this.data.replace) {
         wx.redirectTo({ url: `/module/article/pages/science-info/science-info?id=${id}` });
       } else {
-        const url = `https://${HOST}/admin/editor/preview.html?popularScienceArticleId=${id}`;
-        const item = {
-          url,
-        };
-        wx.navigateTo({
-          url: `/module/article/pages/science-info/science-info?url=${url}`,
-        }).then((res) => {
-          res.eventChannel.emit("load", item);
-        });
+        const id = event.currentTarget.id;
+        // const url = `https://${HOST}/admin/editor/preview.html?popularScienceArticleId=${id}`;
+      
+        try {
+          const res = await Get(`/psarticle/clickPsarticle`, {
+            params: { popularScienceArticleId: id },
+          });
+          const url = res?.data;
+          const item = {
+            url,
+          };
+          wx.navigateTo({
+            url: `/module/article/pages/science-info/science-info`,
+          }).then((res) => {
+            res.eventChannel.emit("load", item);
+          });
+        } catch (error) {
+          console.log(error);
+        }
+        // const url = `https://${HOST}/admin/editor/preview.html?popularScienceArticleId=${id}`;
+        // const item = {
+        //   url,
+        // };
+        // wx.navigateTo({
+        //   url: `/module/article/pages/science-info/science-info?url=${url}`,
+        // }).then((res) => {
+        //   res.eventChannel.emit("load", item);
+        // });
       //   wx.navigateTo({ url: `/module/article/pages/science-info/science-info?id=${id}` })
       //     .then(res => { res.eventChannel.emit('load', this.data.item) })
       }

+ 1 - 2
miniprogram/module/article/components/waterfall-card/waterfall-card.ts

@@ -1,5 +1,5 @@
 // module/article/components/waterfall-card/waterfall-card.ts
-import { HOST } from "../../../../app.config";
+// import { HOST } from "../../../../app.config";
 import { Get } from "../../../../lib/request/method";
 Component({
   properties: {
@@ -21,7 +21,6 @@ Component({
         const item = {
           url,
         };
-        console.log(item, "item",url);
         wx.navigateTo({
           url: `/module/article/pages/science-info/science-info`,
         }).then((res) => {

+ 7 - 0
miniprogram/module/article/pages/education-list/education-list.json

@@ -0,0 +1,7 @@
+{
+  "renderer": "skyline",
+  "component": true,
+  "usingComponents": {
+    "education-card": "../../components/education-card/education-card"
+  }
+}

+ 18 - 0
miniprogram/module/article/pages/education-list/education-list.scss

@@ -0,0 +1,18 @@
+@import '../../../../themes/page.scss';
+@import '../../searc-list.scss';
+
+/* module/diet/pages/science-list/science-list.wxss */
+.list-wrapper {
+  position: relative;
+  
+  &::after {
+    content: '';
+    position: fixed;
+    bottom: 0;
+    left: 0;
+    right: 0;
+    height: 40px;
+    background: linear-gradient(to bottom, rgba(29, 111, 246, 0), rgba(29, 111, 246, 0.1));
+    pointer-events: none;
+  }
+}

+ 83 - 0
miniprogram/module/article/pages/education-list/education-list.ts

@@ -0,0 +1,83 @@
+import PageContainerBehavior from "../../../../core/behavior/page-container.behavior";
+import tickleBehavior, { getTickleContext } from "../../../../core/behavior/tickle.behavior";
+import { getScienceNoticeListMethod } from "../../request";
+// module/diet/pages/science-list/science-list.ts
+Component({
+  behaviors: [
+    PageContainerBehavior,
+    tickleBehavior,
+  ],
+  lifetimes: {
+    attached() {
+      wx.showLoading({ title: '加载中' });
+      this.load();
+    }
+  },
+  properties: {
+    classify: { type: String, value: '' },
+  },
+  data: {
+    keyword: '',
+    searchInputProps: {
+      placeholderStyle: 'color: #929292;',
+      // cursorColor: '#1D6FF6',
+      // iconColor: '#1D6FF6',
+      cursorColor: '#929292',
+      iconColor: '#929292',
+      focus: false,
+      placeholder: '输入搜索名称',
+    },
+    title: '',
+    dataset: [] as AnyObject[],
+    page: 1, size: 20, total: 0, loading: false, isLastPage: false,
+  },
+  observers: {
+    'classify'(value) {
+      const ref = { tonic: '药膳查询', tea: '中医茶饮' } as any;
+      this.setData({ title: ref[value] || '' })
+    },
+    'page,size,total'(page, size, total) {
+      this.setData({ isLastPage: page * size >= total })
+    }
+  },
+  methods: {
+    async load() {
+      try {
+        const { data, total } = await getScienceNoticeListMethod(1, this.data.size, {
+          keyword: this.data.keyword,
+        });
+        this.setData({ dataset: data, total });
+      } catch (error) {
+        getTickleContext.call(this).showWarnMessage(error.errMsg);
+      }
+      wx.hideLoading();
+    },
+    async loadMore() {
+      if (this.data.isLastPage || this.data.loading) return;
+      this.setData({ loading: true });
+      try {
+        const _page = this.data.page + 1;
+        const { data, total } = await getScienceNoticeListMethod(_page, this.data.size, {
+          keyword: this.data.keyword,
+        });
+        this.setData({ dataset: [...this.data.dataset, ...data], total, page: _page });
+      } catch (error) {
+        getTickleContext.call(this).showWarnMessage(error.errMsg);
+      }
+      this.setData({ loading: false });
+    },
+    onConfirmSearchInput(event: WechatMiniprogram.InputConfirm) {
+      const _keyword = this.data.keyword;
+      this.setData({ keyword: event.detail.value });
+      wx.showLoading({ title: '搜索中' });
+      this.load().catch(() => { this.setData({ keyword: _keyword }) });
+    },
+    toInfoPage(event: WechatMiniprogram.TouchEvent) {
+      const id = event.currentTarget.id;
+      wx.navigateTo({ url: `/module/article/pages/science-info/science-info?id=${id}` })
+        .then(res => {
+          res.eventChannel.emit('load', this.data.dataset.find(item => item.id.toString() === id))
+        })
+    }
+  }
+})

+ 14 - 0
miniprogram/module/article/pages/education-list/education-list.wxml

@@ -0,0 +1,14 @@
+<!--module/diet/pages/science-list/science-list.wxml-->
+<t-navbar title="宣教通知" left-arrow />
+<view style="flex: auto;overflow: hidden;">
+  <scroll-view class="list-wrapper scrollable" scroll-y type="custom" enhanced bind:scrolltolower="loadMore">
+    <list-builder list="{{dataset}}" child-height="125">
+      <education-card slot:item slot:index item="{{item}}" index="{{index}}"></education-card>
+    </list-builder>
+    <view class="tips" wx:if="{{loading}}">加载中...</view>
+    <view class="tips" wx:elif="{{isLastPage}}">没有更多的了</view>
+  </scroll-view>
+</view>
+
+<view style="height: {{container.safeBottomOffset}}px;flex: none;"></view>
+<t-message id="{{$messageId}}" />

+ 25 - 0
miniprogram/module/article/request.ts

@@ -57,6 +57,31 @@ export function getScienceListMethod(
     }
   );
 }
+// 宣教通知
+export function getScienceNoticeListMethod(
+  page: number,
+  size: number,
+  query?: { keyword?: string }
+) {
+  return Post(
+    `/psarticle/pagePsaNotice?pageNum=${page}&pageSize=${size}&keyword=${query?.keyword}`,
+    void 0,
+    {
+      transform({ data }: AnyObject) {
+        return {
+          total: data.total,
+          page: data?.current ?? page,
+          size: data?.size ?? size,
+          data: data.data.map(
+            (item: AnyObject) => (
+              (item.id = item.popularScienceArticleId), item
+            )
+          ),
+        };
+      },
+    }
+  );
+}
 
 export function getScienceMethod(id: string) {
   return Get(`/psarticle/getPsarticleDetailById`, {

+ 3 - 6
miniprogram/pages/mine/mine.ts

@@ -209,14 +209,11 @@ Page({
       url: "/module/article/pages/foot-print/foot-print",
     });
   },
-  // 健康宣教
+  // 宣教通知
   toHealthEducationPage() {
-    // wx.showToast({
-    //   title: "敬请期待",
-    //   icon: "none",
-    // });
+    
     wx.navigateTo({
-      url: '/module/article/pages/science-list/science-list'
+      url: '/module/article/pages/education-list/education-list'
     });
   },
   onAddressTap() {