repayment.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. var Request = GetRequest();
  2. var checktype = false;
  3. var loading = dialog({
  4. contentType: 'load',
  5. skin: 'bk-popup',
  6. });
  7. var iscrollState = ''; //判断滑动方向
  8. (function() {
  9. var myVue = new Vue({
  10. el: "#app",
  11. data: {
  12. data: {},
  13. waitPayList: [],
  14. waitPayDetailList: [],
  15. waitPayTotal: "",
  16. paidList: [],
  17. paidDetailList: [],
  18. length: 1,
  19. cardlenght: 0,
  20. cardId: "",
  21. hisId: "",
  22. tabType: "1",
  23. code: "",
  24. tabTypeTxt: ["", "待缴费帐单", "已缴费帐单"],
  25. },
  26. mounted: function() {
  27. var vm = this
  28. checkUserAgent();
  29. vm.checkType()
  30. vm.code = JSON.parse(localStorage.getItem("wlyyAgent")).uid
  31. },
  32. methods: {
  33. //获取就诊卡
  34. getData: function() {
  35. var vm = this
  36. loading.showModal();
  37. sendPost("patient/card/getCardList", {
  38. patient: vm.code
  39. }, "json", "get", function() {
  40. loading.close();
  41. dialog({
  42. contentType: 'tipsbox',
  43. bottom: true,
  44. skin: 'bk-popup',
  45. content: '请求失败'
  46. }).show();
  47. }, function(res) {
  48. if(res.status == 200) {
  49. if(res.data.length > 0) {
  50. vm.cardlenght = res.data.length
  51. if(Request.id) {
  52. vm.data = res.data.filter(function(item) {
  53. return item.id == Request.id
  54. })[0]
  55. if(!vm.data) {
  56. vm.data = res.data.filter(function(item) {
  57. return item.isDefault == 1
  58. })[0]
  59. }
  60. } else {
  61. vm.data = res.data.filter(function(item) {
  62. return item.isDefault == 1
  63. })[0]
  64. }
  65. if(!vm.data) {
  66. vm.data = res.data[0]
  67. }
  68. if(vm.data.type=="2"){
  69. vm.data.cardNo=vm.data.cardNo.substr(0,1)+"*******"+vm.data.cardNo.substr(vm.data.cardNo.length-4,4)
  70. }
  71. vm.cardId = vm.data.id
  72. vm.hisId = vm.data.hisId
  73. if(Request.tabType=="2"){
  74. vm.paid()
  75. }else{
  76. vm.getrepayList()
  77. }
  78. } else {
  79. dialog({
  80. content: "请先绑定就诊卡,再查看就诊缴费帐单!",
  81. okValue: '确定',
  82. ok: function() {
  83. if(Request.origin){
  84. if(Request.origin == "hesuanYuyue"){
  85. window.location.href = '../../hesuanYuyue/html/selPatient.html';
  86. }
  87. }else{
  88. window.location.href = '../../payment/html/patientIDCards.html';
  89. }
  90. },
  91. // cancelValue: '我再看看',
  92. // cancel: function(){}
  93. }).showModal()
  94. }
  95. } else {
  96. loading.close();
  97. dialog({
  98. contentType: 'tipsbox',
  99. bottom: true,
  100. skin: 'bk-popup',
  101. content: '数据获取失败'
  102. }).show();
  103. }
  104. })
  105. },
  106. //获取待缴费帐单
  107. getrepayList: function() {
  108. var vm = this
  109. vm.tabType = 1
  110. vm.waitPay()
  111. vm.waitPayDetail()
  112. },
  113. waitPay: function() {
  114. var vm = this
  115. sendPost("/third/hy/paySettle/waitPay", {
  116. hisId: this.hisId // "3c83266e-3fd4-4032-83f9-169d07145947"
  117. }, "json", "get", function() {
  118. loading.close();
  119. dialog({
  120. contentType: 'tipsbox',
  121. bottom: true,
  122. skin: 'bk-popup',
  123. content: '请求失败'
  124. }).show();
  125. }, function(res) {
  126. loading.close();
  127. if(res.status == 200) {
  128. if(res.data.code == 0) {
  129. vm.waitPayList = res.data.data
  130. vm.waitPayTotal = parseFloat(res.data.total).toFixed(2)
  131. vm.$nextTick(function() {
  132. vm.eventClick()
  133. })
  134. } else {
  135. dialog({
  136. contentType: 'tipsbox',
  137. bottom: true,
  138. skin: 'bk-popup',
  139. content: res.data.message || '数据查询失败'
  140. }).show();
  141. }
  142. } else {
  143. dialog({
  144. contentType: 'tipsbox',
  145. bottom: true,
  146. skin: 'bk-popup',
  147. content: res.msg || '数据查询失败'
  148. }).show();
  149. }
  150. })
  151. },
  152. waitPayDetail: function() {
  153. var vm = this
  154. sendPost("/third/hy/paySettle/waitPayDetail", {
  155. hisId: this.hisId
  156. }, "json", "get", function() {
  157. loading.close();
  158. dialog({
  159. contentType: 'tipsbox',
  160. bottom: true,
  161. skin: 'bk-popup',
  162. content: '请求失败'
  163. }).show();
  164. }, function(res) {
  165. loading.close();
  166. if(res.status == 200) {
  167. if(res.data.code == 0) {
  168. vm.waitPayDetailList = res.data.data
  169. } else {
  170. dialog({
  171. contentType: 'tipsbox',
  172. bottom: true,
  173. skin: 'bk-popup',
  174. content: res.data.message || '数据查询失败'
  175. }).show();
  176. }
  177. } else {
  178. dialog({
  179. contentType: 'tipsbox',
  180. bottom: true,
  181. skin: 'bk-popup',
  182. content: res.msg || '数据查询失败'
  183. }).show();
  184. }
  185. })
  186. },
  187. //获取已缴费帐单
  188. paid: function() {
  189. var vm = this
  190. vm.tabType = 2
  191. vm.getpaidList()
  192. // vm.getpaidDetailList()
  193. },
  194. getpaidList: function() {
  195. var vm = this
  196. sendPost("/third/hy/paySettle/paid", {
  197. hisId: vm.hisId
  198. }, "json", "get", function() {
  199. loading.close();
  200. dialog({
  201. contentType: 'tipsbox',
  202. bottom: true,
  203. skin: 'bk-popup',
  204. content: '请求失败'
  205. }).show();
  206. }, function(res) {
  207. loading.close();
  208. if(res.status == 200) {
  209. if(res.data.code == 0) {
  210. vm.paidList = _.each(res.data.data, function(item, index) {
  211. item.child = vm.getpaidDetailList(item.JsCode, item.JieSuanRiqi.replace(/-/g, ""), index)
  212. })
  213. vm.$nextTick(function() {
  214. vm.eventClick()
  215. })
  216. } else {
  217. dialog({
  218. contentType: 'tipsbox',
  219. bottom: true,
  220. skin: 'bk-popup',
  221. content: res.data.message || '数据查询失败'
  222. }).show();
  223. }
  224. } else {
  225. dialog({
  226. contentType: 'tipsbox',
  227. bottom: true,
  228. skin: 'bk-popup',
  229. content: res.msg || '数据查询失败'
  230. }).show();
  231. }
  232. })
  233. },
  234. //获取已缴费帐单
  235. getpaidDetailList: function(JsCode, JieSuanRiqi, index) {
  236. var vm = this
  237. var params = {
  238. hisId: vm.hisId,
  239. jsCode: JsCode,
  240. jsDate: JieSuanRiqi
  241. }
  242. sendPost("/third/hy/paySettle/paidDetail", params, "json", "get", function() {
  243. loading.close();
  244. dialog({
  245. contentType: 'tipsbox',
  246. bottom: true,
  247. skin: 'bk-popup',
  248. content: '请求失败'
  249. }).show();
  250. }, function(res) {
  251. loading.close();
  252. if(res.status == 200) {
  253. if(res.data.code == 0) {
  254. vm.paidList[index].child = res.data.data
  255. } else {
  256. dialog({
  257. contentType: 'tipsbox',
  258. bottom: true,
  259. skin: 'bk-popup',
  260. content: res.data.message || '数据查询失败'
  261. }).show();
  262. }
  263. } else {
  264. dialog({
  265. contentType: 'tipsbox',
  266. bottom: true,
  267. skin: 'bk-popup',
  268. content: res.msg || '数据查询失败'
  269. }).show();
  270. }
  271. })
  272. },
  273. //门诊结算
  274. preToPay: function() {
  275. var vm = this
  276. if(vm.hisId){
  277. dialog({
  278. content: "您的缴费金额为"+vm.waitPayTotal+"元,从就诊卡余额中扣除,是否继续?",
  279. okValue: '继续缴费',
  280. ok: function() {
  281. vm.toPay()
  282. },
  283. cancelValue: '再等一下',
  284. cancel: function() {}
  285. }).showModal()
  286. }else{
  287. dialog({
  288. contentType: 'tipsbox',
  289. bottom: true,
  290. skin: 'bk-popup',
  291. content: '医院码不存在'
  292. }).show();
  293. }
  294. },
  295. toPay: function() {
  296. var vm = this
  297. sendPost("/third/hy/paySettle/outpSettle", {
  298. hisId: vm.hisId
  299. }, "json", "get", function() {
  300. loading.close();
  301. dialog({
  302. contentType: 'tipsbox',
  303. bottom: true,
  304. skin: 'bk-popup',
  305. content: '请求失败'
  306. }).show();
  307. }, function(res) {
  308. loading.close();
  309. if(res.status == 200) {
  310. if(res.data.code == 0) {
  311. window.location.href = "../../payment/html/repaymentResult.html?patientName=" + vm.data.name + "&healthNo=" + vm.data.cardNo + "&payAmount=" + vm.waitPayTotal + "&createDate=" + getNowFormatDate() + "&cardId=" + vm.cardId + "&origin=" + Request.origin;
  312. } else {
  313. dialog({
  314. content:"您的就诊卡余额不足,请充值。充值后自动完成未结账单缴费~",
  315. okValue: '去充值',
  316. ok: function() {
  317. window.location.href = '../../payment/html/payment.html?id=' + vm.cardId + '&paytype=1&repayAmout=' + vm.waitPayTotal+'&origin='+Request.origin;
  318. },
  319. cancelValue: '再等一下',
  320. cancel: function() {}
  321. }).showModal()
  322. }
  323. } else {
  324. dialog({
  325. contentType: 'tipsbox',
  326. bottom: true,
  327. skin: 'bk-popup',
  328. content: res.msg || '数据查询失败'
  329. }).show();
  330. }
  331. })
  332. },
  333. //跳转切换就诊卡
  334. changeCards: function() {
  335. window.location.href = '../../payment/html/changeCards.html?pre=repayment&origin='+Request.origin;
  336. },
  337. //跳转我的就诊卡页面
  338. gotoCards: function() {
  339. window.location.href = '../../payment/html/patientIDCards.html';
  340. },
  341. eventClick: function() {
  342. $(".c-list-link").unbind("click")
  343. $(".c-list-link").click(function() {
  344. $(this).parent().siblings().toggle();
  345. if($(this).hasClass("list-arrow-u")) {
  346. $(this).addClass("list-arrow-d").removeClass("list-arrow-u");
  347. } else {
  348. $(this).addClass("list-arrow-u").removeClass("list-arrow-d");
  349. }
  350. })
  351. },
  352. //判断是否验证登录通过
  353. checkType: function() {
  354. var vm = this
  355. var timer = setInterval(function() {
  356. if(checktype) {
  357. clearInterval(timer);
  358. vm.getData()
  359. }
  360. }, 10);
  361. },
  362. },
  363. })
  364. })()
  365. function queryInit() {
  366. checktype = true
  367. }
  368. function getNowFormatDate() {
  369. var date = new Date();
  370. var seperator1 = "-";
  371. var year = date.getFullYear();
  372. var month = date.getMonth() + 1;
  373. var strDate = date.getDate();
  374. if(month >= 1 && month <= 9) {
  375. month = "0" + month;
  376. }
  377. if(strDate >= 0 && strDate <= 9) {
  378. strDate = "0" + strDate;
  379. }
  380. var hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
  381. var minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
  382. var second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
  383. var currentdate = year + seperator1 + month + seperator1 + strDate + " " + hour + ":" + minute + ":" + second;
  384. return currentdate;
  385. }