index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <form @submit="formSubmit">
  5. <view class="value icon">
  6. <view class="title">头像</view>
  7. <view class="label">
  8. <image class="image" mode="aspectFill" :src="form.icon||config.logoUrl"></image>
  9. </view>
  10. </view>
  11. <view class="remark">
  12. 实名信息(仅用于赛事报名、参赛证功能)
  13. </view>
  14. <view class="value other">
  15. <view class="title">姓名</view>
  16. <view class="label">
  17. <input class="input" :value="form.name" placeholder="点击登录" />
  18. </view>
  19. </view>
  20. <view class="value other margin">
  21. <view class="title">昵称</view>
  22. <view class="label">
  23. <input class="input" :value="form.nickname" placeholder="请输入昵称" />
  24. </view>
  25. </view>
  26. <view class="value other">
  27. <view class="title">性别</view>
  28. <view class="label">
  29. <picker @change="sexChange" :value="index" :range="sexList" range-key="dictLabel">
  30. <view class="picker">{{form.sex||'请选择性别'}}</view>
  31. </picker>
  32. </view>
  33. </view>
  34. <view class="value other">
  35. <view class="title">手机号</view>
  36. <view class="label">
  37. <input class="input" :value="form.phone" placeholder="请输入手机号" />
  38. </view>
  39. </view>
  40. <view class="value other">
  41. <view class="title">城市</view>
  42. <view class="label">
  43. <cityPicker :showSheetView="showSheetView" :defaultIndexs="[0,0,0]" @onSelected="onSelected">
  44. </cityPicker>
  45. </view>
  46. </view>
  47. <view class="value other">
  48. <view class="title">身高</view>
  49. <view class="label">
  50. <input class="input" :value="form.height" placeholder="请输入身高" />
  51. </view>
  52. </view>
  53. <view class="value other">
  54. <view class="title">体重</view>
  55. <view class="label">
  56. <input class="input" :value="form.weight" placeholder="请输入体重" />
  57. </view>
  58. </view>
  59. <view class="value other margin">
  60. <view class="title">主要项目</view>
  61. <view class="label">
  62. <picker @change="typeChange" :value="index" :range="typeList" range-key="dictLabel">
  63. <view class="picker">{{form.type||'请选择主要项目'}}</view>
  64. </picker>
  65. </view>
  66. </view>
  67. <view class="value other">
  68. <view class="title">球龄</view>
  69. <view class="label">
  70. <input class="input" :value="form.ballYears" placeholder="请输入球龄" />
  71. </view>
  72. </view>
  73. <view class="value other">
  74. <view class="title">队内位置</view>
  75. <view class="label">
  76. <picker @change="placeChange" :value="index" :range="placeList" range-key="dictLabel">
  77. <view class="picker">{{form.place||'请选择队内位置'}}</view>
  78. </picker>
  79. </view>
  80. </view>
  81. <view class="button">
  82. <button type="primary" size="mini" form-type="submit">保存</button>
  83. </view>
  84. </form>
  85. </view>
  86. </view>
  87. </template>
  88. <script setup lang="ts">
  89. import { getCurrentInstance, computed, ref } from 'vue';
  90. import cityPicker from '../../components/cityPicker.vue';
  91. //该依赖已内置不需要单独安装
  92. import { onLoad } from "@dcloudio/uni-app";
  93. // 请求接口
  94. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  95. // openid
  96. const openid = computed(() => {
  97. return uni.getStorageSync('openid');
  98. })
  99. // 基本信息
  100. const config = ref({ logoUrl: '' });
  101. // 用户信息
  102. const form = ref({ icon: '' });
  103. // 城市选择器
  104. const showSheetView = ref(true);
  105. // 字典表
  106. const sexList = ref([]);
  107. const typeList = ref([]);
  108. const placeList = ref([]);
  109. onLoad(async () => {
  110. await searchOther();
  111. await searchConfig();
  112. await search()
  113. })
  114. // 查询其他信息
  115. const searchOther = async () => {
  116. let res;
  117. // 性别
  118. res = await $api(`dict/data/list`, 'GET', { dictType: 'sys_user_sex' });
  119. if (res.code === 200 && res.total > 0) sexList.value = res.rows
  120. // 主要项目
  121. res = await $api(`dict/data/list`, 'GET', { dictType: 'sys_user_type' });
  122. if (res.code === 200 && res.total > 0) typeList.value = res.rows
  123. // 队内位置
  124. res = await $api(`dict/data/list`, 'GET', { dictType: 'sys_user_place' });
  125. if (res.code === 200 && res.total > 0) placeList.value = res.rows
  126. };
  127. // config信息
  128. const searchConfig = async () => {
  129. config.value = uni.getStorageSync('config');
  130. };
  131. // 查询
  132. const search = async () => {
  133. const res = await $api(`matchUser/find`, 'GET', {
  134. openid: openid.value
  135. });
  136. if (res.code === 200) {
  137. if (res.data) console.log(res.data);
  138. else {
  139. uni.navigateTo({
  140. url: `/pages/login/index`,
  141. })
  142. }
  143. } else {
  144. uni.showToast({
  145. title: res.msg || '',
  146. icon: 'error',
  147. });
  148. }
  149. };
  150. // 选择市
  151. const onSelected = (row) => {
  152. console.log(row, '1');
  153. showSheetView.value = false
  154. };
  155. // 性别选择
  156. const sexChange = (e) => {
  157. const data = sexList.value[e.detail.value]
  158. if (data) form.value.sex = data.dictLabel
  159. };
  160. // 主要项目选择
  161. const typeChange = (e) => {
  162. const data = typeList.value[e.detail.value]
  163. if (data) form.value.type = data.dictLabel
  164. };
  165. // 队内位置别选择
  166. const placeChange = (e) => {
  167. const data = placeList.value[e.detail.value]
  168. if (data) form.value.place = data.dictLabel
  169. };
  170. </script>
  171. <style lang="scss" scoped>
  172. .content {
  173. display: flex;
  174. flex-direction: column;
  175. background-color: var(--footColor);
  176. .one {
  177. .icon {
  178. padding: 2vw;
  179. }
  180. .margin {
  181. margin: 3vw 0 0 0;
  182. }
  183. .other {
  184. padding: 3vw 2vw;
  185. border-bottom: 1px solid var(--footColor);
  186. }
  187. .value {
  188. display: flex;
  189. justify-content: space-between;
  190. align-items: center;
  191. background-color: var(--mainColor);
  192. .label {
  193. .input {
  194. text-align: right;
  195. }
  196. .image {
  197. width: 15vw;
  198. height: 15vw;
  199. border-radius: 20vw;
  200. }
  201. }
  202. }
  203. .remark {
  204. padding: 4vw 2vw;
  205. text-align: center;
  206. color: var(--f99Color);
  207. font-size: var(--font18Size);
  208. }
  209. .button {
  210. margin: 2vw 0 0 0;
  211. text-align: center;
  212. button {
  213. font-size: var(--font14Size);
  214. border-radius: 2vw;
  215. background: linear-gradient(to right, #00BFFF, #3F94F1, #7B68EE);
  216. }
  217. }
  218. }
  219. }
  220. </style>