applic.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <view class="content">
  3. <view class="bgi-box">
  4. <image src="../../static/images/bgitop.png" mode="widthFix" class="bgi-img"></image>
  5. </view>
  6. <view class="center-box">
  7. 报名参与
  8. </view>
  9. <view class="list-box">
  10. <view class="list">
  11. <view class="list-left">
  12. 姓名:
  13. </view>
  14. <input type="text" value="" class="list-input" placeholder="请填写您的姓名" v-model="name" />
  15. </view>
  16. <view class="list">
  17. <view class="list-left">
  18. 性别:
  19. </view>
  20. <picker @change="bindPickerSex" :value="index" :range="array" class="list-input">
  21. <text>{{ sex ||'请选择您的性别'}}</text>
  22. </picker>
  23. </view>
  24. <view class="list">
  25. <view class="list-left">
  26. 出生年月:
  27. </view>
  28. <picker mode="date" :value="birthday" :start="startDate" :end="endDate" @change="bindDateChange">
  29. <view class="uni-input">{{ birthday ||'请选择您的出生日期'}}</view>
  30. </picker>
  31. </view>
  32. <view class="list">
  33. <view class="list-left">
  34. 联系方式:
  35. </view>
  36. <input type="text" value="" class="list-input" placeholder="请填写您的联系方式" v-model="phone" />
  37. </view>
  38. </view>
  39. <view class="sub" :class="{ action: loding }" @click="!loding?join():''">
  40. 马上报名
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import {
  46. getList
  47. } from '@/api/index.js';
  48. export default {
  49. data() {
  50. const currentDate = this.getDate({
  51. format: true
  52. })
  53. return {
  54. loding:false,
  55. index: 0,
  56. name: '',
  57. sex: '',
  58. birthday: '',
  59. phone: '',
  60. // date: '',
  61. // currentDate
  62. getList: [],
  63. array:['男','女']
  64. }
  65. },
  66. computed: {
  67. startDate() {
  68. return this.getDate('start');
  69. },
  70. endDate() {
  71. return this.getDate('end');
  72. }
  73. },
  74. methods: {
  75. bindPickerSex: function(e) {
  76. this.sex = this.array[e.target.value];
  77. // this.index = e.target.value + 1;
  78. },
  79. async join() {
  80. let obj = this;
  81. if (obj.name == '') {
  82. obj.$api.msg('请输入您的姓名');
  83. return;
  84. }
  85. if (obj.sex == '') {
  86. obj.$api.msg('请填写您的性别');
  87. return;
  88. }
  89. if (obj.birthday == '') {
  90. obj.$api.msg('请填写您的年月日');
  91. return;
  92. }
  93. const reg = /^(\+?0?86-?)?1[\d]\d{9}$/;
  94. if (obj.phone == !reg.test(obj.phone)) {
  95. obj.$api.msg('请填写正确的手机号码');
  96. return;
  97. }
  98. obj.loding = true;
  99. getList({
  100. name: obj.name,
  101. sex: obj.sex,
  102. birthday: obj.birthday,
  103. phone: obj.phone,
  104. }).then(e => {
  105. console.log(e)
  106. uni.navigateTo({
  107. url: '../joinSuc/joinSuc'
  108. });
  109. })
  110. },
  111. // 选择日期
  112. bindDateChange: function(e) {
  113. let obj = this;
  114. let time1 = new Date(e.target.value).getTime();
  115. let time2 = new Date().getTime();
  116. let time3 = time2 - time1;
  117. let time4 = 1000*60*60*24*365*18;
  118. let time5 = 1000*60*60*24*365*45;
  119. if(time3<time4||time3>time5){
  120. uni.showModal({
  121. content: '捐献年龄必须在18至45周岁!',
  122. success: res => {
  123. if (res.confirm) {
  124. return
  125. }
  126. }
  127. });
  128. }else{
  129. obj.birthday = e.target.value;
  130. }
  131. },
  132. getDate(type) {
  133. const date = new Date();
  134. let year = date.getFullYear();
  135. let month = date.getMonth() + 1;
  136. let day = date.getDate();
  137. if (type === 'start') {
  138. year = year - 60;
  139. } else if (type === 'end') {
  140. year = year + 2;
  141. }
  142. month = month > 9 ? month : '0' + month;;
  143. day = day > 9 ? day : '0' + day;
  144. return `${year}-${month}-${day}`;
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang="scss">
  150. .content {
  151. line-height: 1;
  152. background-color: #FFE1E1;
  153. padding-bottom: 40rpx;
  154. .bgi-box {
  155. width: 750rpx;
  156. .bgi-img {
  157. width: 750rpx;
  158. }
  159. }
  160. .center-box {
  161. width: 405rpx;
  162. background: linear-gradient(0deg, #E73931 0%, #FF4F4F 100%);
  163. border-radius: 10rpx;
  164. margin: -250rpx auto 0;
  165. z-index: 1;
  166. position: relative;
  167. line-height: 66rpx;
  168. text-align: center;
  169. font-size: 30rpx;
  170. font-weight: 500;
  171. color: #FFFFFF;
  172. }
  173. .list-box {
  174. width: 685rpx;
  175. position: relative;
  176. background: #FFFFFF;
  177. border-radius: 29px;
  178. margin: -33rpx auto 0;
  179. font-size: 30rpx;
  180. font-weight: 400;
  181. color: #E63931;
  182. padding: 60rpx 0rpx 30rpx;
  183. .list {
  184. display: flex;
  185. align-items: center;
  186. width: 542rpx;
  187. height: 83rpx;
  188. border: 1px solid #E63931;
  189. margin: 0 auto 30rpx;
  190. padding: 0 40rpx;
  191. border-radius: 83rpx;
  192. .uni-input{
  193. color: #FF9797;
  194. }
  195. .list-left {
  196. width: 150rpx;
  197. }
  198. .list-input {
  199. flex: 1;
  200. color: #FF9797;
  201. .input-placeholder {
  202. color: #FF9797;
  203. }
  204. }
  205. }
  206. }
  207. .sub {
  208. width: 660rpx;
  209. line-height: 100rpx;
  210. text-align: center;
  211. background: linear-gradient(0deg, #C90F1B, #F14D33);
  212. border-radius: 50rpx;
  213. font-size: 36rpx;
  214. font-weight: 400;
  215. color: #FFFFFF;
  216. margin: 40rpx auto 0;
  217. &.action{
  218. background-color: #999999;
  219. }
  220. }
  221. }
  222. </style>