index.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const config = require("../../config.js");
  4. if (!Array) {
  5. const _easycom_up_icon2 = common_vendor.resolveComponent("up-icon");
  6. const _easycom_uni_badge2 = common_vendor.resolveComponent("uni-badge");
  7. const _easycom_up_overlay2 = common_vendor.resolveComponent("up-overlay");
  8. (_easycom_up_icon2 + _easycom_uni_badge2 + _easycom_up_overlay2)();
  9. }
  10. const _easycom_up_icon = () => "../../node-modules/uview-plus/components/u-icon/u-icon.js";
  11. const _easycom_uni_badge = () => "../../uni_modules/uni-badge/components/uni-badge/uni-badge.js";
  12. const _easycom_up_overlay = () => "../../node-modules/uview-plus/components/u-overlay/u-overlay.js";
  13. if (!Math) {
  14. (_easycom_up_icon + _easycom_uni_badge + login + _easycom_up_overlay)();
  15. }
  16. const login = () => "../../components/login.js";
  17. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  18. __name: "index",
  19. setup(__props) {
  20. const $api = common_vendor.inject("$api");
  21. const $config = common_vendor.inject("$config");
  22. const config$1 = common_vendor.ref({ logo: [], icon: [], file: [] });
  23. const show = common_vendor.ref(false);
  24. const user = common_vendor.ref({ icon: [] });
  25. const genderList = common_vendor.ref([]);
  26. const menuList = common_vendor.ref([]);
  27. common_vendor.onShow(async () => {
  28. await searchConfig();
  29. await searchUser();
  30. await searchOther();
  31. await search();
  32. if (!user.value)
  33. show.value = true;
  34. });
  35. const searchUser = async () => {
  36. user.value = common_vendor.index.getStorageSync("user");
  37. };
  38. const searchConfig = async () => {
  39. config$1.value = common_vendor.index.getStorageSync("config");
  40. };
  41. const searchOther = async () => {
  42. let res;
  43. res = await $api(`dictData`, "GET", { code: "gender", is_use: "0" });
  44. if (res.errcode === 0)
  45. genderList.value = res.data;
  46. let menu = [];
  47. for (let val of $config.menuList) {
  48. const role = val.role.find((i) => i == user.value.role_type);
  49. if (role)
  50. menu.push(val);
  51. }
  52. menuList.value = menu;
  53. };
  54. const search = async () => {
  55. };
  56. const showChange = () => {
  57. show.value = false;
  58. };
  59. const getGender = (i) => {
  60. if (i) {
  61. const r = genderList.value.find((f) => f.value === i);
  62. if (r)
  63. return r.label;
  64. else
  65. return "暂无";
  66. } else
  67. return "暂无";
  68. };
  69. const toRoute = (item) => {
  70. if (user.value && user.value._id) {
  71. common_vendor.index.navigateTo({
  72. url: `/${item.route}?status=${item.status}`
  73. });
  74. } else
  75. show.value = true;
  76. };
  77. const toCommon = (e) => {
  78. if (user.value && user.value._id) {
  79. common_vendor.index.navigateTo({
  80. url: `/${e}`
  81. });
  82. } else
  83. show.value = true;
  84. };
  85. return (_ctx, _cache) => {
  86. return common_vendor.e({
  87. a: user.value && user.value._id
  88. }, user.value && user.value._id ? common_vendor.e({
  89. b: user.value && user.value.icon && user.value.icon.length > 0
  90. }, user.value && user.value.icon && user.value.icon.length > 0 ? {
  91. c: user.value.icon[0].url
  92. } : {
  93. d: config$1.value.icon[0].url
  94. }, {
  95. e: common_vendor.t(user.value.nick_name || "暂无昵称"),
  96. f: common_vendor.t(getGender(user.value.gender))
  97. }) : {
  98. g: config$1.value.icon[0].url,
  99. h: common_vendor.o(($event) => show.value = true)
  100. }, {
  101. i: common_vendor.p({
  102. name: "arrow-right",
  103. size: "16"
  104. }),
  105. j: common_vendor.o(($event) => toCommon(`pagesMy/order/index?status=${"-1"}`)),
  106. k: common_vendor.f(common_vendor.unref(config.configInfo).orderList, (item, index, i0) => {
  107. return {
  108. a: common_vendor.n(item.icon),
  109. b: common_vendor.t(item.title),
  110. c: "f97bc692-1-" + i0,
  111. d: common_vendor.p({
  112. text: item.num,
  113. absolute: "rightTop",
  114. size: "normal"
  115. }),
  116. e: index,
  117. f: common_vendor.o(($event) => toRoute(item), index)
  118. };
  119. }),
  120. l: common_vendor.f(menuList.value, (item, index, i0) => {
  121. return {
  122. a: common_vendor.n(item.icon),
  123. b: common_vendor.t(item.title),
  124. c: "f97bc692-2-" + i0,
  125. d: index,
  126. e: common_vendor.o(($event) => toCommon(item.route), index)
  127. };
  128. }),
  129. m: common_vendor.p({
  130. name: "arrow-right",
  131. size: "16"
  132. }),
  133. n: common_vendor.o(showChange),
  134. o: common_vendor.p({
  135. show: show.value
  136. })
  137. });
  138. };
  139. }
  140. });
  141. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-f97bc692"], ["__file", "D:/project/学吧/learn_applet/pages/my/index.vue"]]);
  142. wx.createPage(MiniProgramPage);