From b7ed8541113f8fa116b19d13e34a70a929310077 Mon Sep 17 00:00:00 2001
From: litian <C21AF165>
Date: 星期二, 12 三月 2024 14:38:22 +0800
Subject: [PATCH] 样书申请

---
 pages/personalCenter/activateProduct/index.js |  166 ++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 139 insertions(+), 27 deletions(-)

diff --git a/pages/personalCenter/activateProduct/index.js b/pages/personalCenter/activateProduct/index.js
index c914b6c..7b02479 100644
--- a/pages/personalCenter/activateProduct/index.js
+++ b/pages/personalCenter/activateProduct/index.js
@@ -1,11 +1,25 @@
-// pages/personalCenter/activateProduct/index.js
+const app = getApp();
+import moment from 'moment'
+import tool2 from "../../../assets/js/toolClass.js"
+import { getPublicImage } from "../../../assets/js/middleGround/tool.js";
 Page({
 
   /**
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   data: {
-
+    code: "",
+    list: [],
+    //鍒嗛〉
+    page: 1,
+    limit: 4,
+    pageTotalCount: 0,
+    bottomLoading: false,
+    isMoreData: false,
+    // 杩斿洖椤堕儴
+    isBackTop: false,
+    setScrollValue: 0,
+    skeletonLoding: true,
   },
 
   /**
@@ -13,48 +27,146 @@
    */
   onLoad(options) {
     console.log(options);
+    this.getDataList(false)
   },
+  bindTnputBlur: function (e) {
+    this.setData({
+      code: e.detail.value,
+    });
+    console.log(this.data.code)
+  },
+  //婵�娲�
+  onActivation() {
+    var that = this;
+    let lock = true;
+    if (that.data.code == "") {
+      wx.showToast({
+        title: "璇疯緭鍏ユ縺娲荤爜锛�",
+        icon: 'error',
+        duration: 1000,
+      })
+    } else {
+      if (lock) {
+        lock = false;
+        app.MG.store
+          .userActiveCode({
+            code: that.data.code,
+          })
+          .then((res) => {
+            wx.showToast({
+              title: res,
+              icon: 'none',
+              duration: 1000,
+              success: function () {
+                setTimeout(function () {
+                  that.getDataList(false);
+                  that.setData({
+                    list: [],
+                    code: ""
+                  })
+                  lock = true;
+                }, 1000) //寤惰繜鏃堕棿
+              }
+            })
 
-  /**
-   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
-   */
-  onReady() {
+
+          });
+      }
+    }
+
 
   },
+  //鍟嗗搧鍒楄〃
+  getDataList(isReachBottom) {
+    app.MG.store.userActiveCodeList({
+      start: this.data.page * this.data.limit - this.data.limit,
+      size: this.data.limit,
+      sort: {
+        type: "Desc",
+        field: "CreateDate"
+      }
+    }).then((res) => {
+      try {
+        if (res.datas.length > 0) {
+          res.datas.forEach((item, index) => {
+            item.createDate = moment(item.createDate).format("YYYY-MM-DD HH:mm:ss");
+            let oldlist = [];
+            oldlist = item.productList
+            oldlist.forEach(istrue => {
+              istrue.icon = getPublicImage(istrue.icon, "", 400)
+            })
+          })
+          let dataList = res.datas;
+          //瑙﹀簳鍔犺浇鏂版暟鎹苟淇濈暀鑰佹暟鎹�
+          if (isReachBottom) {
+            dataList = [...this.data.list, ...dataList] //灏嗘柊鏁版嵁鍔犲叆鑰佹暟鎹腑
+          }
+          this.setData({
+            list: dataList,
+            pageTotalCount: res.totalSize,
+            bottomLoading: false,
+            isMoreData: dataList.length > 0 ? false : true,
+            skeletonLoding: false,
+            loading: false
+          })
+        } else {
+          this.setData({
+            skeletonLoding: false,
+            loading: false
+          })
+        }
+      } catch (error) {
+        console.log(error)
+      }
 
-  /**
-   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
-   */
-  onShow() {
-
-  },
-
-  /**
-   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
-   */
-  onHide() {
-
-  },
-
-  /**
-   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇
-   */
-  onUnload() {
-
+    })
   },
 
   /**
    * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
    */
   onPullDownRefresh() {
-
+    if (this._freshing) return
+    this.setData({
+      // list: [],
+      page: 1,
+      limit: 4,
+      pageTotalCount: 0,
+      bottomLoading: false,
+      isMoreData: false
+    })
+    this._freshing = true;
+    this.setData({
+      triggered: false,
+    })
+    this.getDataList(false);
+    this._freshing = false
   },
 
   /**
    * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
    */
   onReachBottom() {
-
+    this.setData({
+      bottomLoading: true,
+      isMoreData: false
+    })
+    let bool = false;
+    if (this.data.pageTotalCount > this.data.list.length) {
+      bool = true;
+      this.setData({
+        page: this.data.page + 1,
+      })
+    } else {
+      setTimeout(() => {
+        this.setData({
+          bottomLoading: false,
+          isMoreData: true
+        })
+      }, 100)
+      return false;
+    }
+    this.getDataList(bool);
   },
 
   /**

--
Gitblit v1.9.1