LuckyDrawEventsDetail.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <view>
  3. <view class="">
  4. <cu-custom :isBack="false" :backUrl="'/pages/test/luckyDraw/LuckyDrawEvents'" 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. <u--form :model="inputForm" labelWidth="60px" class="u-form" labelPosition="left" :rules="rules" ref="inputForm">
  43. <u-form-item label="姓名: " prop="name" :required="true"
  44. :rules="[
  45. ]">
  46. <u--input v-model="inputForm.name" placeholder="请输入姓名" clearable></u--input>
  47. </u-form-item>
  48. <u-form-item label="公司: " prop="companyName" :required="true"
  49. :rules="[
  50. ]">
  51. <jp-picker v-model="inputForm.companyName" rangeKey="label" rangeValue="value" :range="[
  52. { label: '评估公司', value: '评估公司' },
  53. { label: '会计师事务所', value: '会计师事务所' },
  54. { label: '中审分所', value: '中审分所' },
  55. { label: '项目公司', value: '项目公司' },
  56. { label: '其他', value: '其他' }
  57. ]" ></jp-picker>
  58. </u-form-item>
  59. <u-form-item label="部门: " prop="officeName" :required="true"
  60. :rules="[
  61. ]">
  62. <u--input v-model="inputForm.officeName" placeholder="请输入部门" clearable></u--input>
  63. </u-form-item>
  64. <u-form-item label="电话号码: " prop="phone" :required="true"
  65. :rules="[
  66. ]">
  67. <u--input v-model="inputForm.phone" placeholder="请输入电话号码" clearable></u--input>
  68. </u-form-item>
  69. <u-form-item style="margin-top: 20px; text-align: center;">
  70. <el-button type="primary" :disabled="isSubmitting" @click="formSubmit" style="width: 100%;">
  71. {{ isSubmitting ? '提交中...' : '报名' }}
  72. </el-button>
  73. </u-form-item>
  74. </u--form>
  75. </view>
  76. </view>
  77. </view>
  78. </template>
  79. <script>
  80. var graceChecker = require("@/common/graceChecker.js");
  81. import LuckyDrawEventsService from '@/api/test/luckyDraw/LuckyDrawEventsService'
  82. import LuckyDrawMembersService from '@/api/test/luckyDraw/LuckyDrawMembersService.js'
  83. export default {
  84. data() {
  85. return {
  86. rules: {
  87. },
  88. inputForm: {
  89. name: '',
  90. officeName: '',
  91. companyName: '',
  92. phone: '',
  93. eventId: ''
  94. },
  95. list: [],
  96. dataDetail: {},
  97. companyList: [
  98. '评估公司','会计师事务所','中审分所','项目公司','其他'
  99. ],
  100. isSubmitting: false, // 用于控制提交按钮的状态
  101. companyIndex: -1
  102. };
  103. },
  104. luckyDrawMembersService: null,
  105. luckyDrawEventsService: null,
  106. onLoad(option) {
  107. this.luckyDrawEventsService = new LuckyDrawEventsService()
  108. this.luckyDrawMembersService = new LuckyDrawMembersService()
  109. let { eventId } = option
  110. this.init(eventId)
  111. },
  112. onReady() {
  113. },
  114. methods: {
  115. // 数据初始化方法
  116. init(id) {
  117. this.luckyDrawEventsService.queryById(id).then((data) => {
  118. this.dataDetail = data
  119. })
  120. },
  121. // 跳转活动报名页面 参数eventId为活动id
  122. signUp() {
  123. uni.navigateTo({
  124. url: '/pages/test/luckyDraw/LuckyDrawRegister?eventId='+this.dataDetail.id
  125. })
  126. },
  127. // 跳转活动中奖信息页面 参数eventId为活动id
  128. toLottery() {
  129. uni.navigateTo({
  130. url: '/pages/test/luckyDraw/LuckyDrawShowList?eventId='+this.dataDetail.id
  131. })
  132. },
  133. // 跳转报名详情页面 参数eventId为活动id
  134. toLuckyDrawMember() {
  135. uni.navigateTo({
  136. url: '/pages/test/luckyDraw/LuckyDrawMemberList?eventId='+this.dataDetail.id
  137. })
  138. },
  139. async formSubmit(e) {
  140. if (this.isSubmitting) return; // 防止多次点击提交
  141. //定义表单规则
  142. var rule = [
  143. {name:"name", checkType : "notnull", checkRule:"", errorMsg:"姓名不能为空"},
  144. {name:"companyName", checkType : "notnull", checkRule:"", errorMsg:"公司不能为空"},
  145. {name:"officeName", checkType : "notnull", checkRule:"", errorMsg:"部门不能为空"},
  146. {name:"phone", checkType : "notnull", checkRule:"", errorMsg:"电话号码不能为空"},
  147. {name:"phone", checkType : "isMobileNumber", checkRule:"", errorMsg:"电话号码格式不正确"}
  148. ];
  149. //进行表单检查
  150. var formData = this.inputForm;
  151. var checkRes = graceChecker.check(formData, rule);
  152. var flag = false;
  153. if (checkRes) {
  154. } else {
  155. uni.showToast({ title: graceChecker.error, icon: "none" });
  156. }
  157. if (this.inputForm.phone) {
  158. this.luckyDrawMembersService.findMobilePhoneOnly(this.inputForm.phone).then((data) => {
  159. if (data !== 0) {
  160. uni.showToast({
  161. title: '联系电话已存在,请重新填写',
  162. icon: "none",
  163. duration:2000
  164. })
  165. } else {
  166. this.isSubmitting = true;
  167. uni.showLoading();
  168. try {
  169. this.inputForm.eventId = this.dataDetail.id
  170. const data = this.luckyDrawMembersService.save(this.inputForm);
  171. uni.showToast({ title: data, icon: "success" });
  172. uni.navigateTo({
  173. url: '/pages/test/luckyDraw/LuckyDrawMemberList?eventId='+this.dataDetail.id
  174. });
  175. //清空表数据
  176. this.inputForm.name = ''
  177. this.inputForm.officeName = ''
  178. this.inputForm.companyName = ''
  179. this.inputForm.phone = ''
  180. this.inputForm.eventId = ''
  181. // 确保 picker 组件正确地被重置
  182. // this.$refs.inputForm.resetFields()
  183. this.$set(this.inputForm, 'companyName', ' ');
  184. } catch (error) {
  185. console.error(error);
  186. } finally {
  187. this.isSubmitting = false;
  188. uni.hideLoading();
  189. }
  190. }
  191. })
  192. }
  193. },
  194. changeCompany(e){
  195. this.companyIndex = e.target.value;
  196. this.inputForm.companyName = this.companyList[this.companyIndex]
  197. }
  198. },
  199. }
  200. </script>
  201. <style>
  202. </style>