闫增涛
2024-05-06 e8ec903206cb82e4dbb4687291d5f7788e7ff046
packageDomain/pages/sampleBookList/applicationForm/index.js
@@ -61,24 +61,55 @@
              wx.navigateTo({
                url: "/packageDomain/pages/teacherCertification/index",
              });
            } else {
              wx.navigateBack();
            }
          }
        })
      }
      if (wx.getStorageSync("paperBookList")) {
        const paperBookList = JSON.parse(wx.getStorageSync("paperBookList"))
        for (let index = 0; index < paperBookList.length; index++) {
          const item = paperBookList[index];
          if (item.publicationDate)
            item.publicationDate = this.formatDate(item.publicationDate)
        }
        that.setData({
          paperBookList: JSON.parse(wx.getStorageSync("paperBookList")),
          bookList: JSON.parse(wx.getStorageSync("paperBookList"))
          paperBookList: paperBookList,
          bookList: paperBookList
        })
      }
      if (wx.getStorageSync("electronicBookList")) {
        const electronicBookList = JSON.parse(wx.getStorageSync("electronicBookList"))
        for (let index = 0; index < electronicBookList.length; index++) {
          const item = electronicBookList[index];
          if (item.publicationDate)
            item.publicationDate = this.formatDate(item.publicationDate)
        }
        that.setData({
          electronicBookList: JSON.parse(wx.getStorageSync("electronicBookList"))
          electronicBookList: electronicBookList
        })
      }
      that.getSelectBookCount();
      that.getSelectPaperBookCount();
      that.getPaperType();
    }
  },
  formatDate(inputDate) {
    // 使用正则表达式匹配日期部分
    const dateMatch = inputDate.match(/^(\d{4})\/(\d{1,2})\/(\d{1,2})/);
    if (dateMatch) {
      // 提取年、月、日
      const year = dateMatch[1];
      const month = dateMatch[2].padStart(2, '0'); // 确保月份为两位数
      const day = dateMatch[3].padStart(2, '0'); // 确保日期为两位数
      // 拼接并返回格式化后的日期
      return `${year}-${month}-${day}`;
    } else {
      // 如果没有匹配到日期部分,则返回原始输入或抛出错误
      return inputDate; // 或者 throw new Error('Invalid date format');
    }
  },
@@ -308,7 +339,7 @@
            that.setData({
              bookList: eList
            })
            wx.setStorageSync("electronicBookList", eList);
            wx.setStorageSync("electronicBookList", JSON.stringify(eList));
          } else {
            let pList = that.data.paperBookList;
            pList.forEach((obj, index) => {
@@ -319,7 +350,7 @@
            that.setData({
              bookList: pList
            })
            wx.setStorageSync("paperBookList", pList);
            wx.setStorageSync("paperBookList", JSON.stringify(pList));
          }
        } else if (res.cancel) {}
      }
@@ -332,10 +363,10 @@
    if (!this.data.isIos === 'ios') {
      return
    }
    // 键盘高度
    const height = e.detail.height;
    const className = e.target.dataset.class;
    console.log(height, className)
    if (height === 0) {
      this.scrollToInput(0);
      return;
@@ -354,6 +385,7 @@
          if (bottom <= restHeight) return;
          // 现阶段需要滚动的大小
          let scrollTop = bottom - restHeight;
          console.log(scrollTop, 1)
          this.scrollToInput(height, scrollTop);
        })
        .exec();
@@ -393,6 +425,9 @@
      } catch (error) {}
    }
  },
  changeParam(e) {
    this.scrollToInput(0);
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */