闫增涛
2024-04-09 3d73fb33c46aada16a6060adcd4ea14bb33b6b2a
packageDomain/pages/sampleBookList/applicationForm/index.js
@@ -1,4 +1,6 @@
import { worksDataBytool } from "../../../../assets/js/toolClass.js";
import {
  worksDataBytool
} from "../../../../assets/js/toolClass.js";
const app = getApp();
Page({
  data: {
@@ -9,12 +11,14 @@
      workInfo: null,
      schoolName: "",
      courseName: "",
      detailedAddress: ""
    },
    contactInfo: {
      fullName: "",
      phone: "",
      detailedAddress: ""
    },
    phoneError: false,
    paperBookList: [], //样书单纸质书
    electronicBookList: [], //样书单电子书
    ebookCount: 0,
@@ -25,10 +29,10 @@
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() { },
  onLoad() {},
  /**
 * 生命周期函数--监听页面显示
 */
   * 生命周期函数--监听页面显示
   */
  onShow() {
    if (wx.getStorageSync(app.config.userInfoKey)) {
      this.setData({
@@ -57,16 +61,14 @@
      this.getSelectBookCount();
      this.getSelectPaperBookCount();
      this.getPaperType();
    } else {
      wx.navigateTo({
        url: "/pages/testLogin/index",
      });
    }
  },
  tabClick(item) {
    let that = this;
    that.setData({
      bookList: []
    })
    if (item.detail.value == '1') {
      that.setData({
        active: item.detail.value,
@@ -83,7 +85,9 @@
  },
  getElectronType() {
    app.MG.resource.getCmsTypeByRefCode({ refCodes: ['jsek_electronicSampleBook'] }).then((res) => {
    app.MG.resource.getCmsTypeByRefCode({
      refCodes: ['jsek_electronicSampleBook']
    }).then((res) => {
      this.setData({
        description: res[0].description,
        'teacherInfo.workInfo': res[0].cmsTypeLinks[0].children,
@@ -94,22 +98,22 @@
    app.MG.resource.getCmsTypeByRefCode({
      refCodes: ['jsek_paperVersionSampleBook']
    }).
      then((res) => {
        if (res && res.length > 0) {
          this.setData({
            description: res[0].description,
            'teacherInfo.workInfo': res[0].cmsTypeLinks[0].children,
          })
        }
      })
    then((res) => {
      if (res && res.length > 0) {
        this.setData({
          description: res[0].description,
          'teacherInfo.workInfo': res[0].cmsTypeLinks[0].children,
        })
      }
    })
  },
  //获取当前已申请次数(电子)
  getSelectBookCount() {
    let that = this;
    app.MG.app.getTicketResult({
      ticketRefCodeOrGuid: 'electronicSampleBookapplyNum',
      roleId: that.data.userInfo.roleId
    })
        ticketRefCodeOrGuid: 'electronicSampleBookapplyNum',
        roleId: that.data.userInfo.roleId
      })
      .then((res) => {
        let num = res.totalCount - res.usedCount;
        that.setData({
@@ -121,9 +125,9 @@
  getSelectPaperBookCount() {
    let that = this;
    app.MG.app.getTicketResult({
      ticketRefCodeOrGuid: 'paperSampleBookapplyNum',
      roleId: that.data.userInfo.roleId
    })
        ticketRefCodeOrGuid: 'paperSampleBookapplyNum',
        roleId: that.data.userInfo.roleId
      })
      .then((res) => {
        let count = res.totalCount - res.usedCount;
        that.setData({
@@ -131,6 +135,37 @@
        })
      })
  },
  //姓名
  onFullNameInput(e) {
    this.setData({
      "contactInfo.fullName": e.detail.value,
    });
  },
  //输入手机号
  onPhoneInput(e) {
    const {
      phoneError
    } = this.data;
    if (e.detail.value) {
      const isPhoneNumber = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(e.detail.value);
      if (phoneError === isPhoneNumber) {
        this.setData({
          phoneError: !isPhoneNumber,
          "contactInfo.phone": e.detail.value,
        });
      }
    } else {
      this.setData({
        phoneError: false,
      });
    }
  },
  onAddressInput() {
    this.setData({
      "contactInfo.detailedAddress": e.detail.value,
    });
  },
  submit() {
    let that = this;
@@ -179,10 +214,9 @@
        }
        const mailAddress = JSON.stringify(that.data.contactInfo)
        that.setData({
          teacherInfo: {
            detailedAddress: mailAddress,
          }
          'teacherInfo.detailedAddress': mailAddress
        })
        data = {
          topicIdOrRefCode: 'applyEntityBook',
          name: that.data.userInfo.name || '',
@@ -206,25 +240,23 @@
                electronicBookList: [],
                bookList: [],
              })
              wx.setStorageSync("electronicBookList", that.data.electronicBookList);
              wx.removeStorageSync("electronicBookList")
            } else {
              that.setData({
                paperBookList: [],
                bookList: [],
              })
              wx.setStorageSync("paperBookList", that.data.paperBookList);
              wx.removeStorageSync("paperBookList")
            }
            wx.showModal({
              title: '提示!', //提示的标题
              content: '您的样书申请已提交,管理员审核中!申请状态在【个人中心—样书申请】中查询。', //提示的内容
              success: function (res) {
                if (res.confirm) {
                  wx.navigateTo({
                    url: "/packagePersonal/pages/sampleBooks/index",
                    url: "/packagePersonal/pages/sampleBooks/index?stateTab=1&tabActive=" + that.data.active,
                  });
                } else if (res.cancel) {
                }
                } else if (res.cancel) {}
              }
            })
          })
@@ -271,8 +303,7 @@
            })
            wx.setStorageSync("paperBookList", pList);
          }
        } else if (res.cancel) {
        }
        } else if (res.cancel) {}
      }
    })
  },