activity.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view class="form">
  3. <form @submit="formSubmit">
  4. <view class="value other">
  5. <view class="title">名称</view>
  6. <view class="label">
  7. <input name="name" class="input" :value="form.name" placeholder="请输入名称" />
  8. </view>
  9. </view>
  10. <view class="value other">
  11. <view class="title">类型</view>
  12. <view class="label">
  13. <picker name="type" @change="typeChange" :value="index" :range="typeList" range-key="dictLabel">
  14. <view class="picker">{{form.type||'请选择类型'}}</view>
  15. </picker>
  16. </view>
  17. </view>
  18. <view class="value other">
  19. <view class="title">成立时间</view>
  20. <view class="label">
  21. <picker name="date" mode="date" @change="dateChange" :value="index" fields="month">
  22. <view class="picker">{{form.date||'请选择成立时间'}}</view>
  23. </picker>
  24. </view>
  25. </view>
  26. <view class="value other">
  27. <view class="title">成立时间</view>
  28. <view class="label">
  29. <picker name="date" mode="date" @change="dateChange" :value="index" fields="month">
  30. <view class="picker">{{form.date||'请选择成立时间'}}</view>
  31. </picker>
  32. </view>
  33. </view>
  34. <view class="value other">
  35. <view class="title">成立时间</view>
  36. <view class="label">
  37. <picker name="date" mode="date" @change="dateChange" :value="index" fields="month">
  38. <view class="picker">{{form.date||'请选择成立时间'}}</view>
  39. </picker>
  40. </view>
  41. </view>
  42. <view class="value other">
  43. <view class="title">成立时间</view>
  44. <view class="label">
  45. <picker name="date" mode="date" @change="dateChange" :value="index" fields="month">
  46. <view class="picker">{{form.date||'请选择成立时间'}}</view>
  47. </picker>
  48. </view>
  49. </view>
  50. <view class="value other">
  51. <view class="title">队服颜色</view>
  52. <view class="label">
  53. <input name="color" class="input" :value="form.color" placeholder="请输入队服颜色" />
  54. </view>
  55. </view>
  56. <view class="remark">
  57. <view class="title">简介</view>
  58. <view class="label">
  59. <textarea name="brief" :value="form.brief" placeholder="请简单描述球队" />
  60. </view>
  61. </view>
  62. </form>
  63. </view>
  64. </template>
  65. <script setup lang="ts">
  66. import { getCurrentInstance, computed, ref } from 'vue';
  67. //该依赖已内置不需要单独安装
  68. import { onShow } from "@dcloudio/uni-app";
  69. // 请求接口
  70. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  71. const $config = getCurrentInstance()?.appContext.config.globalProperties.$config;
  72. const $apifile = getCurrentInstance()?.appContext.config.globalProperties.$apifile;
  73. // openid
  74. const openid = computed(() => {
  75. return uni.getStorageSync('openid');
  76. })
  77. // 信息
  78. const form = ref({});
  79. // 字典表
  80. const typeList = ref([]);
  81. onShow(async () => {
  82. await searchOther();
  83. await search();
  84. })
  85. // 查询其他信息
  86. const searchOther = async () => {
  87. let res;
  88. // 类型
  89. res = await $api(`dict/data/list`, 'GET', { dictType: 'sys_user_type' });
  90. if (res.code === 200 && res.total > 0) typeList.value = res.rows
  91. };
  92. // 查询
  93. const search = async () => { };
  94. // 类型选择
  95. const typeChange = (e) => {
  96. const data = typeList.value[e.detail.value]
  97. if (data) form.value.type = data.dictLabel
  98. };
  99. // 时间选择器
  100. const dateChange = (e) => {
  101. form.value.date = e.detail.value
  102. };
  103. // 上传图片
  104. const Preview = () => {
  105. uni.chooseImage({
  106. count: 1,
  107. sizeType: ['original', 'compressed'],
  108. sourceType: ['album', 'camera'],
  109. success: async function (res) {
  110. let tempFile = JSON.parse(JSON.stringify(res.tempFilePaths));
  111. const arr = await $apifile(`/common/upload`, 'file', tempFile[0],
  112. 'file');
  113. if (arr.code == 200) {
  114. form.value.logo = arr.url
  115. } else {
  116. uni.showToast({
  117. title: arr.msg,
  118. icon: 'none'
  119. });
  120. }
  121. }
  122. });
  123. };
  124. // 创建
  125. const formSubmit = (e) => {
  126. console.log(e.deatil.value);
  127. };
  128. </script>
  129. <style lang="scss" scoped>
  130. .form {
  131. display: flex;
  132. flex-direction: column;
  133. .other {
  134. padding: 3vw 2vw;
  135. border-bottom: 1px solid var(--footColor);
  136. }
  137. .remark {
  138. padding: 3vw 2vw 0 2vw;
  139. .title {
  140. padding: 0 0 3vw 0;
  141. }
  142. }
  143. .value {
  144. display: flex;
  145. justify-content: space-between;
  146. align-items: center;
  147. background-color: var(--mainColor);
  148. .label {
  149. .input {
  150. text-align: right;
  151. }
  152. }
  153. }
  154. }
  155. </style>