mine.ts 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. import { getPatients, getPatientPhone } from "../home/request";
  2. import { toCertificationPage } from "../home/router";
  3. import { getOrderList, getRecordCountMethod } from "../home/request";
  4. Page({
  5. data: {
  6. patients: [] as (App.Patient.Model & { isDefault: "Y" | "N" })[],
  7. patient: null as App.Patient.Model | null,
  8. patientDescription: "",
  9. userInfo: null,
  10. tabbarValue: "/pages/mine/mine",
  11. phone: "",
  12. mineOrderList: [
  13. {
  14. url: "../../assets/icon/obligation@3x.png",
  15. name: "待付款",
  16. count: 0,
  17. type: 1,
  18. tab: "pending",
  19. },
  20. {
  21. url: "../../assets/icon/delivery@3x.png",
  22. name: "待收货",
  23. count: 0,
  24. type: 2,
  25. tab: "received",
  26. },
  27. {
  28. url: "../../assets/icon/deal@3x.png",
  29. name: "交易成功",
  30. count: 0,
  31. type: 3,
  32. tab: "completed",
  33. },
  34. {
  35. url: "../../assets/icon/all@3x.png",
  36. name: "全部",
  37. count: 0,
  38. type: 4,
  39. tab: "all",
  40. },
  41. ],
  42. },
  43. // 获取各状态调理记录数量
  44. async getRecordCount() {
  45. console.log("获取各状态调理记录数量");
  46. try {
  47. const res = await getRecordCountMethod();
  48. console.log(res.data, "获取各状态调理记录数量");
  49. if (res && res.data) {
  50. this.setData({
  51. "mineOrderList[0].count": res.data.pendingPayment,
  52. "mineOrderList[1].count": res.data.pendingReceiptGoods,
  53. // "mineOrderList[2].count": res.data.successTrade,
  54. // "mineOrderList[3].count": res.data.total,
  55. });
  56. }
  57. console.log(this.data.mineOrderList, "mineOrderList");
  58. } catch (error: any) {
  59. console.error("获取各状态调理记录数量失败:", error);
  60. wx.showToast({
  61. title: error.message,
  62. icon: "none",
  63. duration: 2000,
  64. });
  65. }
  66. },
  67. async load(retry = false) {
  68. if (retry) {
  69. await wx
  70. .showModal({
  71. title: "提示",
  72. content: "数据加载失败,是否重试?",
  73. showCancel: true,
  74. })
  75. .then((res) => {
  76. if (res.confirm) {
  77. this.load();
  78. }
  79. });
  80. return;
  81. }
  82. this.getRecordCount();
  83. try {
  84. wx.showLoading({ title: "加载中" });
  85. const { patient } = await getPatients();
  86. const res = await getPatientPhone();
  87. console.log(res, "获取手机号");
  88. if (res && res.phone) {
  89. this.setData({
  90. phone: res.phone,
  91. });
  92. }
  93. wx.setStorageSync("patientName", patient?.name);
  94. this.setData({
  95. patient: patient || null,
  96. });
  97. } catch (error) {
  98. console.error("加载失败:", error);
  99. wx.showToast({
  100. title: "加载失败",
  101. icon: "none",
  102. duration: 2000,
  103. });
  104. } finally {
  105. wx.hideLoading();
  106. }
  107. },
  108. // 健康档案
  109. toHealthPage() {
  110. if (!this.data.patient?.patientId) {
  111. wx.showToast({
  112. title: "请先登录",
  113. icon: "none",
  114. });
  115. toCertificationPage();
  116. } else {
  117. wx.navigateTo({ url: `/module/health/pages/home/home` });
  118. }
  119. },
  120. // 药膳
  121. toDietTonicPage() {
  122. wx.navigateTo({
  123. url: `/module/article/pages/diet-list/diet-list?classify=tonic`,
  124. });
  125. },
  126. // 茶饮
  127. toDietTeaPage() {
  128. wx.navigateTo({
  129. url: `/module/article/pages/diet-list/diet-list?classify=tea`,
  130. });
  131. },
  132. // 订单列表
  133. toOrderListPage(e: any) {
  134. console.log("tab", e);
  135. const tab = e.currentTarget.dataset.tab;
  136. wx.navigateTo({
  137. url: `/module/article/pages/order-list/order-list?tab=${tab}`,
  138. });
  139. },
  140. // 获取全部订单列表
  141. async getOrderList() {
  142. const patientId = wx.getStorageSync("patientId");
  143. console.log(patientId, "patientId");
  144. const res = await getOrderList(patientId, "");
  145. console.log(res, "获取订单列表");
  146. },
  147. onShow() {
  148. // 如果需要每次显示页面时刷新数据,可以在这里调用 load
  149. this.load();
  150. },
  151. // 足迹
  152. toFootPrintPage() {
  153. wx.navigateTo({
  154. url: "/module/article/pages/foot-print/foot-print",
  155. });
  156. },
  157. // 健康宣教
  158. toHealthEducationPage() {
  159. wx.showToast({
  160. title: "敬请期待",
  161. icon: "none",
  162. });
  163. // wx.navigateTo({
  164. // url: '/module/article/pages/evangelism-notice/evangelism-notice'
  165. // });
  166. },
  167. onAddressTap() {
  168. console.log("onAddressTap");
  169. // 跳转到收货地址页面
  170. wx.navigateTo({
  171. url: "/module/article/pages/manage-address/manage-address",
  172. });
  173. },
  174. onConsultationTap() {
  175. // 跳转到咨询记录页面
  176. wx.showToast({
  177. title: "敬请期待",
  178. icon: "none",
  179. });
  180. // wx.navigateTo({
  181. // url: '/module/article/pages/consultation-record/consultation-record'
  182. // });
  183. },
  184. onTreatmentTap() {
  185. // 跳转到线下非药物治疗页面
  186. wx.navigateTo({
  187. url: "/module/care/pages/offlineTreatment/offlineTreatment",
  188. });
  189. },
  190. });