LuckyDrawEventsDetail.vue 6.9 KB

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