UNPKG

h5-cli

Version:

hello

125 lines (101 loc) 4.29 kB
"use strict"; define(function (require, exports, module) { var VModule = require("component/VModule"); var PageTopTip = require("mods/page-top-tip/index"); var page = VModule.render({ init: function init() { var self = this; this.type = this.query.type; this.regMode = this.query.regMode; this.corpId = this.query.corpId; this.state = { type: this.type, corpId: this.corpId, loading: true, //\u641c\u7d22key searchKey: null, depts: [], //\u53ef\u662f\u5217\u8868 corp: {} //\u533b\u9662\u4fe1\u606f }; this.module = this.initModule(this.state, '#J_Page'); //\u4fdd\u5b58\u4e0a\u4e00\u4e2a\u9875\u9762\u9009\u62e9\u7684\u6570\u636e \u5230 localStorage var registerData = this.cache.getCacheModule(); registerData.set("type", this.type, "\u9884\u7ea6/\u6302\u53f7\u7c7b\u578b"); registerData.set("regMode", this.regMode, "\u9884\u7ea6/\u6302\u53f7"); // departmentlist2 \u7528\u4e8e\u5728\u5e7f\u5dde\u533b\u9662\u53ef\u9009\u62e9\u533b\u751f this.get("/user-web/restapi/common/reservation/departmentlist2", { corpId: this.corpId, type: this.type }); this.regEvent(); }, regEvent: function regEvent() { var self = this; $('.ui-searchbar').click(function () { $('.ui-searchbar-wrap').addClass('focus'); $('.ui-searchbar-input input').focus(); }); $('.ui-searchbar-cancel').click(function () { $('.ui-searchbar-wrap').removeClass('focus'); $('#J_SearchInput').val(""); self.setState({ searchKey: null }); }); $('#J_SearchClear').click(function () { $('#J_SearchInput').val(""); self.setState({ searchKey: null }); }); $('#J_SearchInput')[0].oninput = function () { // console.log(123) var key = $.trim($(this).val()); self.setState({ searchKey: key ? key : null }); }; }, onSuccess: function onSuccess(result) { var depts = result.data.depts; this.setState({ success: true, loading: false, depts: result.data.depts, corp: result.data.corp }); //\u9009\u62e9\u79d1\u5ba4\u5217\u8868 \u63d0\u793a\u4fe1\u606f if (depts && depts.length) { PageTopTip.init('#J_SectionTip', 'selectDept'); } }, render: function render(state) { var _state = this.state, searchKey = _state.searchKey, corp = _state.corp, depts = _state.depts, type = _state.type, corpId = _state.corpId; var reg = searchKey ? new RegExp(searchKey, "i") : null; //\u4e0d\u540c\u7684\u533b\u9662\u53ef\u80fd\u4e0b\u4e00\u6b65\u5230 \u9009\u62e9\u533b\u751f \u6216\u8005\u9009\u62e9\u6392\u7248\u7684\u9875\u9762 var nextPage = corp.scheduleRule == 2 ? "select-doctor.html" : "../select-scheduling.html"; //\u8fc7\u6ee4 if (searchKey) { depts = depts.filter(function (item) { return reg.test(item.deptName) || reg.test(item.deptSimplePY) || reg.test(item.deptPY); }); } if (depts.length == 0) { return this.renderError(); } return "\n <ul class=\"ui-list ui-list-text ui-list-link ui-border-tb\">\n " + depts.map(function (item) { return "\n <li class=\"ui-border-t\">\n <a href=\"" + nextPage + "?deptCode=" + (item.deptCode || "") + "&type=" + type + "&corpId=" + corpId + "&deptName=" + (item.deptName || "") + "&parentDeptCode=" + (item.parentDeptCode || "") + "&target=_blank\">\n <h4 class=\"ui-nowrap\">" + item.deptName + " <span>(" + item.deptSimplePY + ")</span></h4>\n </a>\n </li>\n "; }).join("") + "\n </ul>\n "; }, renderError: function renderError() { return "\n <div id=\"J_KeshiList\">\n <section class=\"ui-notice\" >\n <i></i>\n <p>\u6CA1\u6709\u6392\u73ED\u79D1\u5BA4</p>\n </section>\n </div>\n "; } }); page.init(); module.exports = page; });