LuckyDrawEventsDetail.vue 8.4 KB

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