index.vue 5.3 KB

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