activity.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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. <picker name="type" @change="typeChange" :value="index" :range="typeList" range-key="dictLabel">
  8. <view class="picker">{{form.type||'请选择类型'}}</view>
  9. </picker>
  10. </view>
  11. </view>
  12. <view class="value other margin">
  13. <view class="title">人数</view>
  14. <view class="label">
  15. <picker name="number" @change="numberChange" :value="index" :range="numberList"
  16. range-key="dictLabel">
  17. <view class="picker">{{form.number||'请选择人数'}}</view>
  18. </picker>
  19. </view>
  20. </view>
  21. <view class="value other">
  22. <view class="title">对手</view>
  23. <view class="label">
  24. <input name="name" class="input" :value="form.name" placeholder="请选择" />
  25. </view>
  26. </view>
  27. <view class="value other">
  28. <view class="title">日期</view>
  29. <view class="label">
  30. <picker name="date" mode="date" @change="dateChange" :value="index">
  31. <view class="picker">{{form.date||'请选择日期'}}</view>
  32. </picker>
  33. </view>
  34. </view>
  35. <view class="value other">
  36. <view class="title">时间</view>
  37. <view class="label">
  38. <picker name="time" mode="time" @change="timeChange" :value="index">
  39. <view class="picker">{{form.time||'请选择时间'}}</view>
  40. </picker>
  41. </view>
  42. </view>
  43. <view class="value other">
  44. <view class="title">时长</view>
  45. <view class="label">
  46. <picker name="duration" @change="durationChange" :value="index" :range="durationList"
  47. range-key="dictLabel">
  48. <view class="picker">{{form.duration||'请选择时长'}}</view>
  49. </picker>
  50. </view>
  51. </view>
  52. <view class="value other">
  53. <view class="title">地点</view>
  54. <view class="label">
  55. <input name="name" class="input" :value="form.address" placeholder="请选择" />
  56. </view>
  57. </view>
  58. <view class="value other margin">
  59. <view class="title">队服颜色</view>
  60. <view class="label">
  61. <input name="color" class="input" :value="form.color" placeholder="请输入队服颜色" />
  62. </view>
  63. </view>
  64. <view class="value other">
  65. <view class="title">费用</view>
  66. <view class="label">
  67. <input name="money" class="input" :value="form.money" placeholder="请输入费用" />
  68. </view>
  69. </view>
  70. <view class="value other">
  71. <view class="title">人数上限</view>
  72. <view class="label">
  73. <input name="name" class="input" :value="form.address" placeholder="请选择" />
  74. </view>
  75. </view>
  76. <view class="value other">
  77. <view class="title">公开报名</view>
  78. <view class="label">
  79. <input name="name" class="input" :value="form.address" placeholder="请选择" />
  80. </view>
  81. </view>
  82. <view class="value other">
  83. <view class="title">定时开启报名</view>
  84. <view class="label">
  85. <input name="name" class="input" :value="form.address" placeholder="请选择" />
  86. </view>
  87. </view>
  88. <view class="value other">
  89. <view class="title">报名截止时间</view>
  90. <view class="label">
  91. <input name="name" class="input" :value="form.address" placeholder="请选择" />
  92. </view>
  93. </view>
  94. <view class="value other">
  95. <view class="title">限定人员标签</view>
  96. <view class="label">
  97. <input name="name" class="input" :value="form.address" placeholder="请选择" />
  98. </view>
  99. </view>
  100. <view class="value other margin">
  101. <view class="title">允许待定</view>
  102. <view class="label">
  103. <input name="name" class="input" :value="form.address" placeholder="请选择" />
  104. </view>
  105. </view>
  106. <view class="value other">
  107. <view class="title">活动标题</view>
  108. <view class="label">
  109. <input name="title" class="input" :value="form.title" placeholder="请输入活动标题" />
  110. </view>
  111. </view>
  112. <view class="remark">
  113. <view class="label">
  114. <textarea name="brief" :value="form.brief" placeholder="请输入简介" />
  115. </view>
  116. </view>
  117. <view class="value other">
  118. <view class="title">上传图片</view>
  119. <view class="label">
  120. </view>
  121. </view>
  122. </form>
  123. </view>
  124. </template>
  125. <script setup lang="ts">
  126. import { getCurrentInstance, computed, ref } from 'vue';
  127. //该依赖已内置不需要单独安装
  128. import { onShow } from "@dcloudio/uni-app";
  129. // 请求接口
  130. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  131. const $config = getCurrentInstance()?.appContext.config.globalProperties.$config;
  132. const $apifile = getCurrentInstance()?.appContext.config.globalProperties.$apifile;
  133. // openid
  134. const openid = computed(() => {
  135. return uni.getStorageSync('openid');
  136. })
  137. // 信息
  138. const form = ref({});
  139. // 字典表
  140. const typeList = ref([]);
  141. const numberList = ref([]);
  142. const durationList = ref([]);
  143. onShow(async () => {
  144. await searchOther();
  145. await search();
  146. })
  147. // 查询其他信息
  148. const searchOther = async () => {
  149. let res;
  150. // 类型
  151. res = await $api(`dict/data/list`, 'GET', { dictType: 'sys_user_type' });
  152. if (res.code === 200 && res.total > 0) typeList.value = res.rows
  153. // 人数
  154. res = await $api(`dict/data/list`, 'GET', { dictType: 'sys_match_number' });
  155. if (res.code === 200 && res.total > 0) numberList.value = res.rows
  156. // 时长
  157. res = await $api(`dict/data/list`, 'GET', { dictType: 'sys_match_duration' });
  158. if (res.code === 200 && res.total > 0) durationList.value = res.rows
  159. };
  160. // 查询
  161. const search = async () => { };
  162. // 类型选择
  163. const typeChange = (e) => {
  164. const data = typeList.value[e.detail.value]
  165. if (data) form.value.type = data.dictLabel
  166. };
  167. // 人数选择
  168. const numberChange = (e) => {
  169. const data = numberList.value[e.detail.value]
  170. if (data) form.value.number = data.dictLabel
  171. };
  172. // 时长选择选择
  173. const durationChange = (e) => {
  174. const data = durationList.value[e.detail.value]
  175. if (data) form.value.duration = data.dictLabel
  176. };
  177. // 日期选择器
  178. const dateChange = (e) => {
  179. form.value.date = e.detail.value
  180. };
  181. // 时间选择器
  182. const timeChange = (e) => {
  183. form.value.time = e.detail.value
  184. };
  185. // 上传图片
  186. const Preview = () => {
  187. uni.chooseImage({
  188. count: 1,
  189. sizeType: ['original', 'compressed'],
  190. sourceType: ['album', 'camera'],
  191. success: async function (res) {
  192. let tempFile = JSON.parse(JSON.stringify(res.tempFilePaths));
  193. const arr = await $apifile(`/common/upload`, 'file', tempFile[0],
  194. 'file');
  195. if (arr.code == 200) {
  196. form.value.logo = arr.url
  197. } else {
  198. uni.showToast({
  199. title: arr.msg,
  200. icon: 'none'
  201. });
  202. }
  203. }
  204. });
  205. };
  206. // 创建
  207. const formSubmit = (e) => {
  208. console.log(e.deatil.value);
  209. };
  210. </script>
  211. <style lang="scss" scoped>
  212. .form {
  213. display: flex;
  214. flex-direction: column;
  215. background-color: var(--f9Color);
  216. .other {
  217. padding: 4vw 2vw;
  218. border-bottom: 1px solid var(--footColor);
  219. }
  220. .margin {
  221. margin: 0 0 3vw 0;
  222. }
  223. .remark {
  224. background-color: var(--mainColor);
  225. padding: 3vw 2vw 0 2vw;
  226. .title {
  227. padding: 0 0 3vw 0;
  228. }
  229. }
  230. .value {
  231. display: flex;
  232. justify-content: space-between;
  233. align-items: center;
  234. background-color: var(--mainColor);
  235. .label {
  236. .input {
  237. text-align: right;
  238. }
  239. }
  240. }
  241. }
  242. </style>