index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. </view>
  5. <view class="two">
  6. <text>设置队徽</text>
  7. </view>
  8. <view class="thr">
  9. <form @submit="formSubmit">
  10. <view class="logo">
  11. <image class="image" mode="aspectFill" :src="form.logo||'/static/qiudui.png'" @tap="Preview">
  12. </image>
  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">
  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="typeChange" :value="index" :range="typeList" range-key="dictLabel">
  30. <view class="picker">{{form.type||'请选择类型'}}</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="remark">
  48. <view class="title">简介</view>
  49. <view class="label">
  50. <textarea :value="form.brief" placeholder="请简单描述球队" />
  51. </view>
  52. </view>
  53. <view class="button">
  54. <button type="warn" size="mini" form-type="submit">创建</button>
  55. </view>
  56. </form>
  57. </view>
  58. </view>
  59. </template>
  60. <script setup lang="ts">
  61. import { getCurrentInstance, computed, ref } from 'vue';
  62. //该依赖已内置不需要单独安装
  63. import { onShow } from "@dcloudio/uni-app";
  64. import cityPicker from '../../components/cityPicker.vue';
  65. // 请求接口
  66. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  67. const $config = getCurrentInstance()?.appContext.config.globalProperties.$config;
  68. const $apifile = getCurrentInstance()?.appContext.config.globalProperties.$apifile;
  69. // 基本信息
  70. const config = ref({ logoUrl: '' });
  71. // openid
  72. const openid = computed(() => {
  73. return uni.getStorageSync('openid');
  74. })
  75. // 用户信息
  76. const form = ref({ icon: '' });
  77. // 城市选择器
  78. const showSheetView = ref(true);
  79. // 字典表
  80. const typeList = ref([]);
  81. onShow(async () => {
  82. await searchConfig();
  83. await searchOther();
  84. await search()
  85. })
  86. // config信息
  87. const searchConfig = async () => {
  88. config.value = uni.getStorageSync('config');
  89. };
  90. // 查询其他信息
  91. const searchOther = async () => {
  92. let res;
  93. // 类型
  94. res = await $api(`dict/data/list`, 'GET', { dictType: 'sys_team_type' });
  95. if (res.code === 200 && res.total > 0) typeList.value = res.rows
  96. };
  97. // 查询
  98. const search = async () => {
  99. };
  100. // 选择市
  101. const onSelected = (row) => {
  102. console.log(row, '1');
  103. showSheetView.value = false
  104. };
  105. // 类型选择
  106. const typeChange = (e) => {
  107. const data = typeList.value[e.detail.value]
  108. if (data) form.value.type = data.dictLabel
  109. };
  110. // 上传图片
  111. const Preview = () => {
  112. uni.chooseImage({
  113. count: 1,
  114. sizeType: ['original', 'compressed'],
  115. sourceType: ['album', 'camera'],
  116. success: async function (res) {
  117. let tempFile = JSON.parse(JSON.stringify(res.tempFilePaths));
  118. const arr = await $apifile(`/common/upload`, 'file', tempFile[0],
  119. 'file');
  120. if (arr.code == 200) {
  121. form.value.logo = arr.url
  122. } else {
  123. uni.showToast({
  124. title: arr.msg,
  125. icon: 'none'
  126. });
  127. }
  128. }
  129. });
  130. };
  131. </script>
  132. <style lang="scss" scoped>
  133. .content {
  134. display: flex;
  135. flex-direction: column;
  136. width: 100vw;
  137. height: 100vh;
  138. .one {
  139. height: 25vw;
  140. background-color: var(--f00Color);
  141. }
  142. .two {
  143. margin: 10vw 0 0 0;
  144. text-align: center;
  145. font-size: var(--font16Size);
  146. font-weight: bold;
  147. }
  148. .thr {
  149. .logo {
  150. position: fixed;
  151. top: 12vw;
  152. right: 40vw;
  153. .image {
  154. width: 20vw;
  155. height: 20vw;
  156. border-radius: 20vw;
  157. background-color: var(--mainColor);
  158. }
  159. }
  160. .other {
  161. padding: 3vw 2vw;
  162. border-bottom: 1px solid var(--footColor);
  163. }
  164. .remark {
  165. padding: 3vw 2vw 0 2vw;
  166. .title {
  167. padding: 0 0 3vw 0;
  168. }
  169. }
  170. .value {
  171. display: flex;
  172. justify-content: space-between;
  173. align-items: center;
  174. background-color: var(--mainColor);
  175. .label {
  176. .input {
  177. text-align: right;
  178. }
  179. }
  180. }
  181. .button {
  182. text-align: center;
  183. button {
  184. width: 80vw;
  185. font-size: var(--font16Size);
  186. }
  187. }
  188. }
  189. }
  190. </style>