create.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="create-team-page">
  3. <u-navbar title="创建队伍" :autoBack="true" bgColor="#fff" leftIconColor="#333"
  4. titleStyle="font-weight:bold;"></u-navbar>
  5. <view class="form-box">
  6. <u-form :model="form" ref="uForm" labelPosition="top">
  7. <u-form-item label="所在城市" prop="city" borderBottom @tap="getCityFun()">
  8. <u-input v-model="form.city" @tap="getCityFun()" disabledColor="#f8f8f8" placeholder="请选择所在城市" border="none">
  9. <template #suffix>
  10. <u-icon name="arrow-right" color="#999" size="16"></u-icon>
  11. </template>
  12. </u-input>
  13. </u-form-item>
  14. <u-form-item label="团队名称" prop="teamName" borderBottom>
  15. <u-input v-model="form.teamName" placeholder="请输入团队名称" border="none" clearable></u-input>
  16. </u-form-item>
  17. <u-form-item label="领队姓名" prop="leaderName" borderBottom>
  18. <u-input v-model="form.leaderName" placeholder="请输入领队姓名" border="none" clearable></u-input>
  19. </u-form-item>
  20. <u-form-item label="领队电话" prop="leaderPhone" borderBottom>
  21. <u-input v-model="form.leaderPhone" type="number" placeholder="请输入领队电话" maxlength="11" border="none"
  22. clearable></u-input>
  23. </u-form-item>
  24. </u-form>
  25. <view class="submit-btn" @click="handleSubmit">
  26. 创建队伍
  27. </view>
  28. </view>
  29. <u-picker :show="showCityPicker" :columns="cityColumns" @confirm="confirmCity"
  30. @cancel="showCityPicker = false"></u-picker>
  31. </view>
  32. </template>
  33. <script>
  34. import {getCitys} from '@/api/common.js'
  35. import {
  36. signUpLeader
  37. } from '@/api/activity.js';
  38. export default {
  39. data() {
  40. return {
  41. form: {
  42. city: '',
  43. teamName: '',
  44. leaderName: '',
  45. leaderPhone: '',
  46. activityId: getApp().globalData.activityId
  47. },
  48. showCityPicker: false,
  49. cityColumns: [
  50. []
  51. ],
  52. rules: {
  53. city: {
  54. type: 'string',
  55. required: true,
  56. message: '请选择城市',
  57. trigger: ['blur', 'change']
  58. },
  59. teamName: {
  60. type: 'string',
  61. required: true,
  62. message: '请输入团队名称',
  63. trigger: ['blur', 'change']
  64. },
  65. leaderName: {
  66. type: 'string',
  67. required: true,
  68. message: '请输入领队姓名',
  69. trigger: ['blur', 'change']
  70. },
  71. leaderPhone: {
  72. type: 'string',
  73. required: true,
  74. pattern: /^1[3-9]\d{9}$/,
  75. message: '请输入正确的手机号',
  76. trigger: ['blur', 'change']
  77. }
  78. }
  79. }
  80. },
  81. onReady() {
  82. this.$refs.uForm.setRules(this.rules);
  83. },
  84. methods: {
  85. getCityFun(){
  86. getCitys().then(
  87. res => {
  88. if(res.code==200){
  89. this.cityColumns = [res.data.map(item=>item.n)]
  90. this.showCityPicker = true
  91. }else{
  92. uni.showToast({
  93. icon:'none',
  94. title: "请求失败",
  95. });
  96. }
  97. },
  98. rej => {}
  99. );
  100. },
  101. confirmCity(e) {
  102. this.form.city = e.value[0];
  103. this.showCityPicker = false;
  104. },
  105. handleSubmit() {
  106. this.$refs.uForm.validate().then(res => {
  107. signUpLeader(this.form).then(res => {
  108. if (res.code === 200) {
  109. uni.redirectTo({
  110. url: '/pages_enter/activity/success?teamCode=' + res.data.teamCode
  111. });
  112. } else {
  113. uni.showToast({
  114. title: res.msg || '创建失败',
  115. icon: 'none'
  116. });
  117. }
  118. }).catch(() => {
  119. uni.redirectTo({
  120. url: '/pages_enter/activity/success?teamCode=zkzh202604021235'
  121. });
  122. });
  123. }).catch(errors => {
  124. uni.showToast({
  125. title: '请完善信息',
  126. icon: 'none'
  127. });
  128. });
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="scss" scoped>
  134. .create-team-page {
  135. min-height: 100vh;
  136. height: 100%;
  137. width: 100vw;
  138. background-color: #fff;
  139. padding: 40rpx;
  140. }
  141. .form-box {
  142. margin-top: 40rpx;
  143. width: 100%;
  144. ::v-deep .u-line {
  145. display: none !important;
  146. }
  147. ::v-deep .u-form-item__body__left {
  148. width: 100% !important;
  149. }
  150. ::v-deep .u-form-item__body__right {
  151. padding: 20rpx 40rpx !important;
  152. height: 88rpx !important;
  153. background: #F5F7FA !important;
  154. border-radius: 48rpx !important;
  155. margin-top: 20rpx;
  156. }
  157. .cityBox {
  158. width: calc(100vw - 180rpx);
  159. }
  160. }
  161. .submit-btn {
  162. margin-top: 80rpx;
  163. height: 100rpx;
  164. background: linear-gradient(90deg, #2583EB, #4DA1FF);
  165. border-radius: 50rpx;
  166. color: #fff;
  167. font-size: 32rpx;
  168. display: flex;
  169. align-items: center;
  170. justify-content: center;
  171. box-shadow: 0 4rpx 16rpx rgba(37, 131, 235, 0.3);
  172. &:active {
  173. opacity: 0.8;
  174. }
  175. }
  176. .arrow {
  177. width: 13rpx;
  178. height: 23rpx;
  179. margin-left: 15rpx;
  180. }
  181. </style>