UNPKG

h5-cli

Version:

hello

326 lines (291 loc) 13.5 kB
"use strict"; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; define(function (require, exports, module) { var md5 = require("libs/md5"); var VModule = require("component/VModule"); var page = VModule.render({ init: function init() { // this.patientId = this.query.patientId; // this.patientName = this.query.patientName; // //\u7ed1\u5b9a\u65b0\u5361\u7247\u9700\u8981\u8df3\u8f6c\u5230\u539f\u6765\u5c31\u8bca\u4eba\u9875\u9762 // this.newCard = this.query.newCard; // //\u672c\u9875\u9762 unionId corpId \u4e8c\u90091 this.unionId = this.query.unionId; this.corpId = this.query.corpId; this.patientId = this.query.patientId; this.redirect = this.query.redirect; console.log(this.redirect); this.isSendMsg = false; this.state = this.util.vis({ loading: false, success: true, sendCodeMsgTime: 0, newCard: this.query.newCard, unionId: this.unionId, corpId: this.corpId, patientId: this.patientId, patientName: this.query.patientName, cardName: this.query.cardName, cardType: "", phone: "", cardNo: "", validCode: "", cards: null }); this.module = this.initModule(this.state, '#J_Page'); this.regEvent(); this.loadCards(); this.getMsg(); }, regEvent: function regEvent() { var _this = this; $('#J_Page').delegate('.J_Submit', 'click', function () { _this.getFormData(); _this.submit(); }); //\u53d1\u9001\u9a8c\u8bc1\u7801 $('#J_Page').delegate('.J_SendCode', 'click', function () { _this.getFormData(); if (_this.state.sendCodeMsgTime > 0) { return; } var cardType = _this.state.cardType; var cardNo = _this.state.cardNo; var phone = _this.state.phone; if (!cardType) { _this.util.alert("\u65e0\u53ef\u7528\u7684\u5c31\u8bca\u5361\u7c7b\u578b"); return false; } if (!(cardNo.length > 5 && cardNo.length < 30)) { _this.util.alert("\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u5361\u53f7"); return false; } if (!/^\d{11}$/.test(phone)) { _this.util.alert("\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u624b\u673a\u53f7\u7801"); return false; } _this.util.waitAlert("\u6b63\u5728\u9a8c\u8bc1\u4fe1\u606f\u662f\u5426\u5339\u914d..."); var self = _this; VModule.render({ init: function init(phone, cardType, cardNo, unionId, patientId, corpId) { this.get("/user-web/restapi/card/validate", { mobile: phone, cardType: cardType, cardNo: cardNo, unionId: unionId, patientId: patientId, corpId: corpId }); }, onSuccess: function onSuccess(result) { self.util.alert("\u53d1\u9001\u6210\u529f"); self.setState({ sendCodeMsgTime: 60 }); self.sendCodeCountDown(); }, onError: function onError(result) { self.util.alert(result.msg || "\u9a8c\u8bc1\u7801\u53d1\u9001\u5931\u8d25\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5"); } }).init(phone, cardType, cardNo, _this.unionId, _this.patientId, _this.corpId); }); }, sendCodeCountDown: function sendCodeCountDown() { var _this2 = this; var a = setInterval(function () { var sendCodeMsgTime = _this2.state.sendCodeMsgTime - 1; if (sendCodeMsgTime <= 0) { _this2.setState({ sendCodeMsgTime: 0 }); clearInterval(a); } else { _this2.setState({ sendCodeMsgTime: sendCodeMsgTime }); } }, 1000); }, getFormData: function getFormData() { var cardType = $('#J_Page .cardType').val(); var cardNo = $('#J_Page .cardNo').val(); var phone = $('#J_Page .phone').val(); var validCode = $('#J_Page .J_Code').val(); this.setState({ cardType: cardType, cardNo: cardNo, phone: phone, validCode: validCode }); }, loadCards: function loadCards() { //\u83b7\u53d6\u53ef\u7ed1\u5b9a\u7684\u5361\u7247\u5217\u8868 var self = this; VModule.render({ init: function init(unionId, corpId) { this.get("/user-web/restapi/card/types", { unionId: unionId, corpId: corpId }); }, onSuccess: function onSuccess(result) { if (result.data && result.data.cardType) { self.setState({ cards: [result.data] }); } else { //\u6ca1\u6709\u53ef\u4f7f\u7528\u7684\u5361\u7247 self.setState({ cards: [] }); } }, onError: function onError(result) { self.setState({ cards: [] }); } }).init(this.unionId, this.corpId); }, getMsg: function getMsg() { //\u4ece\u540e\u53f0\u83b7\u53d6\u63d0\u793a\u4fe1\u606f var self = this; VModule.render({ init: function init(unionId, corpId) { this.get("/user-web/restapi/card/getRemind", { unionId: unionId, corpId: corpId }); }, onSuccess: function onSuccess(result) { if (result.data) { self.setState({ msg: result.data }); } else { //\u6ca1\u6709\u4fe1\u606f self.setState({ msg: "" }); } }, onError: function onError(result) { self.setState({ msg: "" }); } }).init(this.unionId, this.corpId); }, //\u53d1\u9001\u9a8c\u8bc1\u7801 sendMsgCode: function sendMsgCode() {}, onChangeCard: function onChangeCard() { this.getFormData(); }, render: function render(state) { var util = this.util; var cardName = state.cardName, cards = state.cards, unionId = state.unionId, cardType = state.cardType, sendCodeMsgTime = state.sendCodeMsgTime, msg = state.msg; /** cardName:"\u5357\u9633\u5c31\u8bca\u5361" cardType:"5" description:"" isTiedCard:true */ var isSendMsg = true; var card = null; if (cards.length) { card = cards.filter(function (item) { return item.cardType == cardType; })[0]; card = card ? card : cards[0]; if (card && card.isSendMsg == false) { isSendMsg = false; } } this.isSendMsg = isSendMsg; return "\n <div class=\"ui-tips center\">\n \u7ED1\u5B9A<em>" + cardName + "</em>\u5C31\u8BCA\u5361\uFF0C\u53EF\u5728\u6302\u53F7\u3001\u7F34\u8D39\u7B49\u73AF\u8282\u76F4\u63A5\u652F\u4ED8\n </div>\n <div class=\"ui-form\">\n <div class=\"ui-form-item ui-form-item-show ui-border-tb\">\n <label>\u5C31\u8BCA\u5361:</label>\n <div class=\"ui-select\">\n <select class=\"cardType\" onChange=\"" + this.bind(this.onChangeCard) + "\">\n " + util.is(cards == null, "<option>\u6B63\u5728\u83B7\u53D6...</option>") + "\n " + ((typeof cards === "undefined" ? "undefined" : _typeof(cards)) == 'object' ? cards.map(function (item) { return "<option value=\"" + item.cardType + "\" >" + item.cardName + "</option>"; }).join("") : "") + "\n </select>\n </div>\n </div>\n <div class=\"ui-form-item ui-form-item-show ui-border-b\">\n <label for=\"cardNumber\">\u5361\u53F7:</label>\n <input type=\"text\" class=\"cardNo\" maxlength=\"20\" placeholder=\"\u8BF7\u8F93\u5165\u5C31\u8BCA\u5361\u5361\u53F7\" >\n </div>\n <div class=\"ui-form-item ui-form-item-show ui-border-b\">\n <label for=\"phone\">\u624B\u673A\u53F7\u7801:</label>\n <input type=\"number\" name=\"phone\" class=\"phone\" placeholder=\"\u8BF7\u8F93\u5165\u529E\u5361\u65F6\u9884\u7559\u7684\u624B\u673A\u53F7\u7801\" >\n </div>\n " + util.is(isSendMsg, "\n <div class=\"ui-form-item ui-form-item-show ui-form-item-r ui-border-b\">\n <label for=\"J_Code\">\u9A8C\u8BC1\u7801:</label>\n <input type=\"text\" maxlength=\"6\" class=\"J_Code\" style=\"margin-left:95px;width:50%;padding-right:0;\" placeholder=\"\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801\">\n <button type=\"button\" class=\"ui-border-l J_SendCode\" >\n " + (sendCodeMsgTime == 0 ? "\u53d1\u9001\u9a8c\u8bc1\u7801" : sendCodeMsgTime + "s") + "\n </button>\n </div>\n ") + "\n </div>\n <div class=\"hide\" style=\"margin: 10px 15px 0 15px; font-size: 13px; color: #999\" id=\"errTips\">\n \u7ED1\u5B9A\u4FE1\u606F\u548C\u9886\u5361\u9884\u7559\u4FE1\u606F\u4E0D\u4E00\u81F4\uFF0C\u8BF7\u524D\u5F80\u4EBA\u5DE5\u7A97\u53E3\u6838\u5B9E\u5361\u53F7\u3001\u624B\u673A\u53F7\u3001\u8EAB\u4EFD\u8BC1\u53F7\n </div>\n <div class=\"ui-btn-wrap\">\n <button class=\"ui-btn-lg ui-btn-primary J_Submit\">\n \u7ED1\u5B9A\n </button>\n </div>\n " + util.is(msg, msg) // util.is( unionId == 60, // ` // <div class="about-faq"> // <h2>\u756a\u79ba\u6c11\u751f\u5361\u6709\u4ec0\u4e48\u597d\u5904?</h2> // <p> // \u6c11\u751f\u5361\u4f5c\u4e3a\u756a\u79ba\u533a\u653f\u5e9c\u4e3a\u5e7f\u4e1c\u7701\u5168\u5458\u4fe1\u606f\u5e93\u7684\u756a\u79ba\u533a\u6c11\u751f\u6863 // \u6848\u4eba\u5458\u514d\u8d39\u53d1\u884c\u7684\u653f\u5e9c\u670d\u52a1\u5361\uff0c\u5728\u536b\u751f\u533b\u7597\u9886\u57df\uff0c\u6301\u5361\u4eba\u53ef // \u901a\u8fc7\u756a\u79ba\u533a\u536b\u751f\u533b\u7597\u673a\u6784\u7684\u94f6\u533b\u901a\u81ea\u52a9\u7ec8\u7aef\uff0c\u5b9e\u73b0\u81ea\u52a9\u53d1\u5361 // \u81ea\u52a9\u6302\u53f7\u3001\u81ea\u52a9\u7f34\u8d39\uff08\u542b\u533b\u4fdd\u81ea\u52a9\u7ed3\u7b97\uff09\u3001\u81ea\u52a9\u6253\u5370\u68c0\u9a8c\u62a5\u544a // \u7b49\u529f\u80fd\uff0c\u5728\u6c11\u751f\u5361\u7684\u8eab\u4efd\u8ba4\u8bc1\u548c\u8d44\u91d1\u7ed3\u7b97\u4e2d\u5b8c\u6210\u6574\u4e2a\u5c31\u533b\u6d41 // \u7a0b\uff0c\u5e76\u80fd\u591f\u5728\u533a\u5185\u6240\u6709\u536b\u751f\u533b\u7597\u673a\u6784\u5b9e\u73b0\u4e00\u5361\u901a\u3002 // </p> // <h2>\u5982\u4f55\u7533\u8bf7\u6c11\u751f\u5361\uff1f</h2> // <p>\u8bf7\u62e8\u6253\u6c11\u751f\u5361\u5ba2\u670d\u70ed\u7ebf:400-834-116\u6216\u8005\u8bbf\u95ee\u6c11\u751f\u5361\u7f51\u7ad9 http://www.xhjk.com.cn \u4e86\u89e3\u8be6\u60c5</p> // </div> // ` // ) + "\n "; }, submit: function submit() { var cardNumber = this.state.cardNo; //.cardNumber; //$.trim( $('#cardNumber').val() ); var phone = this.state.phone; // $.trim( $('#J_Phone').val() ); var cardType = this.state.cardType; // $.trim( $('#J_CardTypesList').val() ); var validCode = this.state.validCode; // if (!cardType) { this.util.alert("\u65e0\u53ef\u7528\u7684\u5c31\u8bca\u5361\u7c7b\u578b"); return; } if (!(cardNumber.length > 5 && cardNumber.length < 30)) { this.util.alert("\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u5361\u53f7"); return; } if (!/^\d{11}$/.test(phone)) { this.util.alert("\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u624b\u673a\u53f7\u7801"); return; } if (this.isSendMsg) { if (validCode.length == 0) { this.util.alert("\u8bf7\u8f93\u5165\u9a8c\u8bc1\u7801"); return; } } //\u7ed1\u5b9a\u5361\u7247 this.get("/user-web/restapi/card/add", { unionId: this.state.unionId, corpId: this.state.corpId, cardNo: cardNumber, cardType: cardType, mobile: phone, patientId: this.patientId, validCode: validCode }); }, onSuccess: function onSuccess(result) { var self = this; var redirect = this.redirect; if (result.success) { this.util.alert("\u5361\u7247\u7ed1\u5b9a\u6210\u529f", function () { if (redirect) { window.location.href = redirect; } else { // self.util.goBack(true); window.location.href = "../add-patient.html?id=" + self.patientId + "&unionId=" + self.unionId + "&corpId=" + self.corpId + "&target=_blank&t=ddsduh"; } }); } else { this.util.alert(result.msg); } }, onError: function onError(result) { this.util.alert(result.msg); var dom = document.getElementById("errTips"); if (this.unionId == 1029) { dom.classList.remove("hide"); } } }); page.init(); module.exports = page; });