repayment.js 10 KB

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