LuckyDrawRegister.vue 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <view>
  3. <cu-custom bgColor="bg-gradual-blue" :isBack="true">
  4. <block slot="backText">返回</block>
  5. <block slot="content">活动报名</block>
  6. </cu-custom>
  7. <form @submit="formSubmit()">
  8. <view class="cu-form-group margin-top">
  9. <view class="title"><text class="red-color ">* </text>姓名</view>
  10. <input placeholder="请输入姓名" name="name" v-model="inputForm.name"></input>
  11. </view>
  12. <view class="cu-form-group ">
  13. <view class="title"><text class="red-color ">* </text>部门</view>
  14. <picker @change="changeOffice" :value="officeIndex" :range="officeList">
  15. <view class="picker">
  16. {{officeIndex>-1?officeList[officeIndex]:'请选择'}}
  17. </view>
  18. </picker>
  19. </view>
  20. <view class="cu-form-group ">
  21. <view class="title"><text class="red-color ">* </text>电话号码</view>
  22. <input placeholder="请输入电话号码" name="phone" v-model="inputForm.phone"></input>
  23. </view>
  24. <view class=" margin-top" style="padding-left: 7px;padding-right: 7px;">
  25. <button style="width: 100%;" class='cu-btn lg bg-gradual-blue shadow ' form-type="submit">提交</button>
  26. </view>
  27. </form>
  28. </view>
  29. </template>
  30. <script>
  31. var graceChecker = require("@/common/graceChecker.js");
  32. import LuckyDrawMembersService from '@/api/test/luckyDraw/LuckyDrawMembersService.js'
  33. export default {
  34. data() {
  35. return {
  36. eventId: '',
  37. inputForm: {
  38. name: '',
  39. officeName: '',
  40. mobile: '',
  41. eventId: ''
  42. },
  43. officeList: [
  44. '工程一部','工程二部','工程三部','工程四部','工程五部','招标代理部','兴光评估','其他'
  45. ],
  46. officeIndex: -1
  47. };
  48. },
  49. luckyDrawMembersService: null,
  50. onLoad(option) {
  51. this.luckyDrawMembersService = new LuckyDrawMembersService()
  52. let { eventId } = option
  53. this.inputForm.eventId = eventId
  54. },
  55. methods: {
  56. formSubmit: function(e) {
  57. //定义表单规则
  58. var rule = [
  59. {name:"name", checkType : "notnull", checkRule:"", errorMsg:"姓名不能为空"},
  60. {name:"officeName", checkType : "notnull", checkRule:"", errorMsg:"部门不能为空"},
  61. {name:"phone", checkType : "notnull", checkRule:"", errorMsg:"电话号码不能为空"},
  62. {name:"phone", checkType : "isMobileNumber", checkRule:"", errorMsg:"电话号码格式不正确"}
  63. ];
  64. //进行表单检查
  65. var formData = this.inputForm;
  66. var checkRes = graceChecker.check(formData, rule);
  67. if(checkRes){
  68. uni.showLoading()
  69. this.luckyDrawMembersService.save(this.inputForm).then((data) => {
  70. uni.showToast({title:data, icon:"success"});
  71. uni.navigateTo({
  72. url: '/pages/test/luckyDraw/LuckyDrawEvents?is_sucess='+'200'
  73. })
  74. }).catch((e)=>{
  75. })
  76. }else{
  77. uni.showToast({ title: graceChecker.error, icon: "none" });
  78. }
  79. },
  80. changeOffice(e){
  81. this.officeIndex = e.target.value;
  82. this.inputForm.officeName = this.officeList[this.officeIndex]
  83. }
  84. }
  85. }
  86. </script>
  87. <style>
  88. </style>