test.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. "use strict";
  2. var common_vendor = require("../common/vendor.js");
  3. var api_test = require("../api/test.js");
  4. require("../common/request.js");
  5. const _sfc_main = {
  6. data() {
  7. return {
  8. scrollTop: 0,
  9. formJson: null,
  10. tempId: null,
  11. patient: null,
  12. items: {},
  13. msgs: [],
  14. index: 0,
  15. item: null
  16. };
  17. },
  18. onLoad(option) {
  19. this.tempId = option.tempId;
  20. var that = this;
  21. common_vendor.index.$on("refreshOrderPatient", (res) => {
  22. that.patient = res;
  23. });
  24. },
  25. onShow() {
  26. this.getTestTempDetails();
  27. this.getTestDetails();
  28. },
  29. onShareAppMessage(res) {
  30. if (this.$isLogin()) {
  31. return {
  32. title: "\u5065\u5EB7\u4F53\u8D28\u68C0\u6D4B",
  33. path: "/pages_index/test?tempId=" + this.tempId,
  34. imageUrl: "https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.png"
  35. };
  36. }
  37. },
  38. onShareTimeline(res) {
  39. if (this.utils.isLogin()) {
  40. return {
  41. title: "\u5065\u5EB7\u4F53\u8D28\u68C0\u6D4B",
  42. imageUrl: "https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.png"
  43. };
  44. }
  45. },
  46. methods: {
  47. getTestDetails() {
  48. let data = { tempId: this.tempId };
  49. api_test.getTestDetails(data).then((res) => {
  50. if (res.code == 200) {
  51. common_vendor.index.setNavigationBarTitle({
  52. title: res.data.name + "\u81EA\u6D4B"
  53. });
  54. } else {
  55. common_vendor.index.showToast({
  56. icon: "none",
  57. title: "\u8BF7\u6C42\u5931\u8D25"
  58. });
  59. }
  60. }, (rej) => {
  61. });
  62. },
  63. addMsg(type, content) {
  64. var msg = { type, content };
  65. this.msgs.push(msg);
  66. var that = this;
  67. common_vendor.index.createSelectorQuery().select(".msgs").boundingClientRect((res) => {
  68. const scrollH = res.height;
  69. that.scrollTop = scrollH;
  70. console.log(that.scrollTop);
  71. }).exec();
  72. },
  73. optionClick(item, option) {
  74. if (this.patient == null) {
  75. common_vendor.index.showToast({
  76. icon: "none",
  77. title: "\u8BF7\u9009\u62E9\u4F53\u9A8C\u8005"
  78. });
  79. return;
  80. }
  81. item.option = option.name;
  82. console.log(item.option);
  83. this.addMsg(2, option.name);
  84. this.index++;
  85. if (this.index <= this.items.length - 1) {
  86. this.item = this.items[this.index];
  87. this.addMsg(1, this.item.title);
  88. } else {
  89. this.submit();
  90. }
  91. },
  92. getTestTempDetails() {
  93. var data = { tempId: this.tempId };
  94. api_test.getTestTempDetails(data).then((res) => {
  95. if (res.code == 200) {
  96. this.items = res.items;
  97. if (this.items.length > 0) {
  98. this.item = this.items[0];
  99. this.addMsg(1, this.item.title);
  100. }
  101. }
  102. }, (err) => {
  103. });
  104. },
  105. addPatient() {
  106. common_vendor.index.navigateTo({
  107. url: "/pages_user/patient"
  108. });
  109. },
  110. submit() {
  111. var data = {
  112. tempId: this.tempId,
  113. patientId: this.patient.patientId,
  114. formJson: JSON.stringify(this.items)
  115. };
  116. api_test.doReport(data).then((res) => {
  117. if (res.code == 200) {
  118. common_vendor.index.redirectTo({
  119. url: "/pages_index/testResult?reportId=" + res.reportId
  120. });
  121. } else {
  122. common_vendor.index.showToast({
  123. icon: "none",
  124. title: res.msg
  125. });
  126. }
  127. });
  128. }
  129. }
  130. };
  131. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  132. return common_vendor.e({
  133. a: $data.patient == null
  134. }, $data.patient == null ? {
  135. b: common_vendor.o(($event) => $options.addPatient())
  136. } : {}, {
  137. c: $data.patient != null
  138. }, $data.patient != null ? common_vendor.e({
  139. d: common_vendor.t($data.patient.patientName),
  140. e: $data.patient.sex == 1
  141. }, $data.patient.sex == 1 ? {} : {}, {
  142. f: $data.patient.sex == 2
  143. }, $data.patient.sex == 2 ? {} : {}, {
  144. g: common_vendor.t(_ctx.$getAge($data.patient.birthday)),
  145. h: common_vendor.t(_ctx.$parseIdCard($data.patient.idCard)),
  146. i: common_vendor.o(($event) => $options.addPatient())
  147. }) : {}, {
  148. j: common_vendor.f($data.msgs, (item, index, i0) => {
  149. return common_vendor.e({
  150. a: item.type == 1
  151. }, item.type == 1 ? {
  152. b: common_vendor.t(item.content)
  153. } : {}, {
  154. c: item.type == 2
  155. }, item.type == 2 ? {
  156. d: common_vendor.t(item.content)
  157. } : {});
  158. }),
  159. k: $data.scrollTop,
  160. l: $data.item != null
  161. }, $data.item != null ? {
  162. m: common_vendor.t($data.item.title),
  163. n: common_vendor.f(JSON.parse($data.item.scoreJson), (option, k0, i0) => {
  164. return {
  165. a: common_vendor.t(option.name),
  166. b: common_vendor.o(($event) => $options.optionClick($data.item, option))
  167. };
  168. })
  169. } : {});
  170. }
  171. var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "E:/Project/2023/\u95EE\u8BCA\u5E73\u53F0/his_user_miniapp/pages_index/test.vue"]]);
  172. _sfc_main.__runtimeHooks = 6;
  173. wx.createPage(MiniProgramPage);