index.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  4. __name: "index",
  5. setup(__props) {
  6. var _a, _b, _c;
  7. const $api = (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api;
  8. (_b = common_vendor.getCurrentInstance()) == null ? void 0 : _b.appContext.config.globalProperties.$config;
  9. const $apifile = (_c = common_vendor.getCurrentInstance()) == null ? void 0 : _c.appContext.config.globalProperties.$apifile;
  10. const openid = common_vendor.computed(() => {
  11. return common_vendor.index.getStorageSync("openid");
  12. });
  13. const config = common_vendor.ref({ logoUrl: "" });
  14. const form = common_vendor.ref({ icon: "" });
  15. const sexList = common_vendor.ref([]);
  16. const typeList = common_vendor.ref([]);
  17. const placeList = common_vendor.ref([]);
  18. common_vendor.onLoad(async () => {
  19. await searchOther();
  20. await searchConfig();
  21. await search();
  22. common_vendor.index.$on("setCity", function(city) {
  23. form.value.city = city;
  24. });
  25. });
  26. const searchOther = async () => {
  27. let res;
  28. res = await $api(`dict/data/list`, "GET", { dictType: "sys_user_sex" });
  29. if (res.code === 200 && res.total > 0)
  30. sexList.value = res.rows;
  31. res = await $api(`dict/data/list`, "GET", { dictType: "sys_user_type" });
  32. if (res.code === 200 && res.total > 0)
  33. typeList.value = res.rows;
  34. res = await $api(`dict/data/list`, "GET", { dictType: "sys_user_place" });
  35. if (res.code === 200 && res.total > 0)
  36. placeList.value = res.rows;
  37. };
  38. const searchConfig = async () => {
  39. config.value = common_vendor.index.getStorageSync("config");
  40. };
  41. const search = async () => {
  42. const res = await $api(`matchUser/find`, "GET", {
  43. openid: openid.value
  44. });
  45. if (res.code === 200) {
  46. if (res.data)
  47. console.log(res.data);
  48. else {
  49. common_vendor.index.navigateTo({
  50. url: `/pages/login/index`
  51. });
  52. }
  53. } else {
  54. common_vendor.index.showToast({
  55. title: res.msg || "",
  56. icon: "error"
  57. });
  58. }
  59. };
  60. const toCity = () => {
  61. if (form.value.city) {
  62. common_vendor.index.navigateTo({
  63. url: `/pagesHome/city/index?city=${form.value.city}`
  64. });
  65. } else {
  66. common_vendor.index.navigateTo({
  67. url: `/pagesHome/city/index`
  68. });
  69. }
  70. };
  71. const sexChange = (e) => {
  72. const data = sexList.value[e.detail.value];
  73. if (data)
  74. form.value.sex = data.dictLabel;
  75. };
  76. const typeChange = (e) => {
  77. const data = typeList.value[e.detail.value];
  78. if (data)
  79. form.value.type = data.dictLabel;
  80. };
  81. const placeChange = (e) => {
  82. const data = placeList.value[e.detail.value];
  83. if (data)
  84. form.value.place = data.dictLabel;
  85. };
  86. const Preview = () => {
  87. common_vendor.index.chooseImage({
  88. count: 1,
  89. sizeType: ["original", "compressed"],
  90. sourceType: ["album", "camera"],
  91. success: async function(res) {
  92. let tempFile = JSON.parse(JSON.stringify(res.tempFilePaths));
  93. const arr = await $apifile(
  94. `/common/upload`,
  95. "file",
  96. tempFile[0],
  97. "file"
  98. );
  99. if (arr.code == 200) {
  100. form.value.icon = arr.url;
  101. } else {
  102. common_vendor.index.showToast({
  103. title: arr.msg,
  104. icon: "none"
  105. });
  106. }
  107. }
  108. });
  109. };
  110. return (_ctx, _cache) => {
  111. return common_vendor.e({
  112. a: form.value.icon || config.value.logoUrl,
  113. b: common_vendor.o(Preview),
  114. c: form.value.name,
  115. d: form.value.nickname,
  116. e: common_vendor.t(form.value.sex || "请选择性别"),
  117. f: common_vendor.o(sexChange),
  118. g: _ctx.index,
  119. h: sexList.value,
  120. i: form.value.phone,
  121. j: form.value.city
  122. }, form.value.city ? {
  123. k: common_vendor.t(form.value.city)
  124. } : {}, {
  125. l: common_vendor.o(toCity),
  126. m: form.value.height,
  127. n: form.value.weight,
  128. o: common_vendor.t(form.value.type || "请选择主要项目"),
  129. p: common_vendor.o(typeChange),
  130. q: _ctx.index,
  131. r: typeList.value,
  132. s: form.value.ballYears,
  133. t: common_vendor.t(form.value.place || "请选择队内位置"),
  134. v: common_vendor.o(placeChange),
  135. w: _ctx.index,
  136. x: placeList.value,
  137. y: common_vendor.o(
  138. //@ts-ignore
  139. (...args) => _ctx.formSubmit && _ctx.formSubmit(...args)
  140. )
  141. });
  142. };
  143. }
  144. });
  145. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-bf1a7b85"], ["__file", "D:/project/足球比赛/match_applet/pagesMy/basic/index.vue"]]);
  146. wx.createPage(MiniProgramPage);