LuckyDrawEventsDetail.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view>
  3. <view class="">
  4. <cu-custom :isBack="true" bgColor="bg-gradual-blue">
  5. <block slot="backText">返回</block>
  6. <block slot="content">活动详情</block>
  7. </cu-custom>
  8. </view>
  9. <view class="cu-card article">
  10. <view class="cu-item shadow">
  11. <!-- 活动名称 -->
  12. <view class="title">
  13. <view class="text-center"> {{dataDetail.name}} </view>
  14. </view>
  15. <!-- 活动详情 -->
  16. <view class="content">
  17. <view class="desc">
  18. <view class="text-content-luckyDraw"> {{dataDetail.detail}} </view>
  19. </view>
  20. </view>
  21. <!-- 图片 -->
  22. <view class="content" style="margin-top: 15px;">
  23. <image style="width: 100%;" src="/static/lucky_draw_events.jpg" mode="widthFix"></image>
  24. </view>
  25. <view class=" padding-lr" :key="'00'" :id="'00'">
  26. <view class="cu-bar solid-bottom bg-white">
  27. <view class="action">
  28. <!-- <text class="cuIcon-present text-red"></text>-->
  29. <!-- <text class="text-red" style="margin-left: 2upx;" @click="toLottery()">-->
  30. <!-- 中奖信息-->
  31. <!-- </text>-->
  32. </view>
  33. <view class="action">
  34. <text class="text-red" style="" @click="toLuckyDrawMember()">
  35. 报名详情
  36. </text>
  37. <text class="cuIcon-friend text-red"></text>
  38. </view>
  39. </view>
  40. </view>
  41. <!-- 表单 -->
  42. <form @submit="formSubmit">
  43. <view class="cu-form-group margin-top">
  44. <view class="title"><text class="red-color ">* </text>姓名</view>
  45. <input style=" margin-top: 30px;" placeholder="请输入姓名" name="name" v-model="inputForm.name"></input>
  46. </view>
  47. <view class="cu-form-group margin-top">
  48. <view class="title"><text class="red-color ">* </text>部门</view>
  49. <input style=" margin-top: 30px;" placeholder="请输入部门" name="officeName" v-model="inputForm.officeName"></input>
  50. </view>
  51. <view class="cu-form-group ">
  52. <view class="title"><text class="red-color ">* </text>公司</view>
  53. <picker @change="changeCompany" :value="companyIndex" :range="companyList">
  54. <view class="picker" >
  55. {{companyIndex > -1 ? companyList[companyIndex] : '请选择'}}
  56. </view>
  57. </picker>
  58. </view>
  59. <view class="cu-form-group ">
  60. <view class="title"><text class="red-color ">* </text>电话号码</view>
  61. <input style=" margin-top: 30px;" placeholder="请输入电话号码" name="phone" v-model="inputForm.phone"></input>
  62. </view>
  63. <view class="margin-top" style="padding-left: 7px; padding-right: 7px;">
  64. <button :disabled="isSubmitting" style="width: 100%;" class='cu-btn lg bg-gradual-blue shadow' form-type="submit">
  65. {{ isSubmitting ? '提交中...' : '报名' }}
  66. </button>
  67. </view>
  68. </form>
  69. </view>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. var graceChecker = require("@/common/graceChecker.js");
  75. import LuckyDrawEventsService from '@/api/test/luckyDraw/LuckyDrawEventsService'
  76. import LuckyDrawMembersService from '@/api/test/luckyDraw/LuckyDrawMembersService.js'
  77. export default {
  78. data() {
  79. return {
  80. inputForm: {
  81. name: '',
  82. officeName: '',
  83. companyName: '',
  84. phone: '',
  85. eventId: ''
  86. },
  87. list: [],
  88. dataDetail: {},
  89. companyList: [
  90. '评估公司','会计师事务所','中审分所','项目公司','咨询公司','其他'
  91. ],
  92. isSubmitting: false, // 用于控制提交按钮的状态
  93. companyIndex: -1
  94. };
  95. },
  96. luckyDrawMembersService: null,
  97. luckyDrawEventsService: null,
  98. onLoad(option) {
  99. this.luckyDrawEventsService = new LuckyDrawEventsService()
  100. this.luckyDrawMembersService = new LuckyDrawMembersService()
  101. let { eventId } = option
  102. this.init(eventId)
  103. },
  104. onReady() {
  105. },
  106. methods: {
  107. // 数据初始化方法
  108. init(id) {
  109. this.luckyDrawEventsService.queryById(id).then((data) => {
  110. this.dataDetail = data
  111. })
  112. },
  113. // 跳转活动报名页面 参数eventId为活动id
  114. signUp() {
  115. uni.navigateTo({
  116. url: '/pages/test/luckyDraw/LuckyDrawRegister?eventId='+this.dataDetail.id
  117. })
  118. },
  119. // 跳转活动中奖信息页面 参数eventId为活动id
  120. toLottery() {
  121. uni.navigateTo({
  122. url: '/pages/test/luckyDraw/LuckyDrawShowList?eventId='+this.dataDetail.id
  123. })
  124. },
  125. // 跳转报名详情页面 参数eventId为活动id
  126. toLuckyDrawMember() {
  127. uni.navigateTo({
  128. url: '/pages/test/luckyDraw/LuckyDrawMemberList?eventId='+this.dataDetail.id
  129. })
  130. },
  131. async formSubmit(e) {
  132. if (this.isSubmitting) return; // 防止多次点击提交
  133. //定义表单规则
  134. var rule = [
  135. {name:"name", checkType : "notnull", checkRule:"", errorMsg:"姓名不能为空"},
  136. {name:"officeName", checkType : "notnull", checkRule:"", errorMsg:"部门不能为空"},
  137. {name:"companyName", checkType : "notnull", checkRule:"", errorMsg:"公司不能为空"},
  138. {name:"phone", checkType : "notnull", checkRule:"", errorMsg:"电话号码不能为空"},
  139. {name:"phone", checkType : "isMobileNumber", checkRule:"", errorMsg:"电话号码格式不正确"}
  140. ];
  141. //进行表单检查
  142. var formData = this.inputForm;
  143. var checkRes = graceChecker.check(formData, rule);
  144. var flag = false;
  145. if (checkRes) {
  146. } else {
  147. uni.showToast({ title: graceChecker.error, icon: "none" });
  148. }
  149. if (this.inputForm.phone) {
  150. this.luckyDrawMembersService.findMobilePhoneOnly(this.inputForm.phone).then((data) => {
  151. if (data !== 0) {
  152. uni.showToast({
  153. title: '联系电话已存在,请重新填写',
  154. icon: "none",
  155. duration:2000
  156. })
  157. } else {
  158. this.isSubmitting = true;
  159. uni.showLoading();
  160. try {
  161. this.inputForm.eventId = this.dataDetail.id
  162. const data = this.luckyDrawMembersService.save(this.inputForm);
  163. uni.showToast({ title: data, icon: "success" });
  164. uni.navigateTo({
  165. url: '/pages/test/luckyDraw/LuckyDrawEvents?is_sucess=200'
  166. });
  167. } catch (error) {
  168. console.error(error);
  169. } finally {
  170. this.isSubmitting = false;
  171. uni.hideLoading();
  172. }
  173. }
  174. })
  175. }
  176. },
  177. changeCompany(e){
  178. this.companyIndex = e.target.value;
  179. this.inputForm.companyName = this.companyList[this.companyIndex]
  180. }
  181. },
  182. }
  183. </script>
  184. <style>
  185. </style>