chuTi.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <view class="box">
  3. <u-navbar :autoBack="true" title="出题得分" bgColor="rgba(255,255,255,0)" :placeholder="true" titleStyle="font-weight:bold;color:#000000"></u-navbar>
  4. <!-- 表单 -->
  5. <view class="example">
  6. <uni-forms style="padding: 0 20rpx 0 20rpx" label-position="top" ref="valiForm" :rules="rules" :modelValue="valiFormData">
  7. <uni-forms-item label="标题" label-width="80px" required name="titVal">
  8. <uni-easyinput v-model="valiFormData.titVal" placeholder="请输入标题" />
  9. </uni-forms-item>
  10. <uni-forms-item label="问题" label-width="100px" required name="problemVal">
  11. <uni-easyinput v-model="valiFormData.problemVal" placeholder="请输入问题" />
  12. </uni-forms-item>
  13. <uni-forms-item label="选项" label-width="100px" required name="optionVal">
  14. <uni-easyinput v-model="valiFormData.optionVal" placeholder="例如:A1 B:2" />
  15. </uni-forms-item>
  16. <uni-forms-item label="答案" label-width="100px" required name="answerVal">
  17. <uni-easyinput v-model="valiFormData.answerVal" placeholder="请输入正确答案" />
  18. </uni-forms-item>
  19. <uni-forms-item label="答案解析" label-width="80px" required name="analysisVal">
  20. <uni-easyinput type="textarea" v-model="valiFormData.analysisVal" />
  21. </uni-forms-item>
  22. <uni-forms-item label="本题关联考点" label-width="110px" required name="associationVal">
  23. <uni-easyinput type="textarea" v-model="valiFormData.associationVal" />
  24. </uni-forms-item>
  25. </uni-forms>
  26. <view class="text-wrapper_3" @click="submit('valiForm')">
  27. <view class="tit">提交</view>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. return {
  36. /* 表单数据 */
  37. valiFormData: {
  38. titVal: '',
  39. answerVal: '',
  40. problemVal: '',
  41. optionVal: '',
  42. analysisVal: '',
  43. associationVal: ''
  44. },
  45. /* 校验规则 */
  46. rules: {
  47. // 对titVal字段进行必填验证
  48. titVal: {
  49. // titVal 字段的校验规则
  50. rules: [
  51. // 校验 titVal 不能为空
  52. {
  53. required: true,
  54. errorMessage: '请输入标题'
  55. }
  56. // 对titVal字段进行长度验证
  57. // {
  58. // minLength: 1,
  59. // maxLength: 6,
  60. // errorMessage: '{label}长度在 {minLength} 到 {maxLength} 个字符'
  61. // }
  62. ],
  63. // 当前表单域的字段中文名,可不输入
  64. label: '标题',
  65. validateTrigger: 'submit'
  66. },
  67. /* 问题校验 */
  68. problemVal: {
  69. // problemVal 字段的校验规则
  70. rules: [
  71. // 校验 problemVal 不能为空
  72. {
  73. required: true,
  74. errorMessage: '请输入问题'
  75. }
  76. // 对problemVal字段进行长度验证
  77. // {
  78. // minLength: 11,
  79. // maxLength: 11,
  80. // errorMessage: '{label}长度为 {minLength} 个字符'
  81. // }
  82. ],
  83. // 当前表单域的字段中文名,可不输入
  84. label: '问题',
  85. validateTrigger: 'submit'
  86. },
  87. /* 选项校验 */
  88. optionVal: {
  89. // optionVal 字段的校验规则
  90. rules: [
  91. // 校验 optionVal 不能为空
  92. {
  93. required: true,
  94. errorMessage: '请输入选项'
  95. }
  96. // 对optionVal字段进行长度验证
  97. // {
  98. // minLength: 18,
  99. // maxLength: 18,
  100. // errorMessage: '{label}长度为 {minLength} 个字符'
  101. // }
  102. ]
  103. },
  104. /* 答案 解析*/
  105. analysisVal: {
  106. rules: [
  107. // 校验 analysisVal 不能为空
  108. {
  109. required: true,
  110. errorMessage: '请输入答案解析'
  111. }
  112. ]
  113. },
  114. // 答案
  115. answerVal: {
  116. rules: [
  117. // 校验 不能为空
  118. {
  119. required: true,
  120. errorMessage: '请输入正确答案'
  121. }
  122. ]
  123. }
  124. }
  125. };
  126. },
  127. methods: {
  128. submit() {
  129. this.$refs.valiForm.validate(['id'], async (err, valiFormData) => {
  130. if (!err) {
  131. console.log('校验成功');
  132. /* 检验成功 */
  133. const { name, mobile, address, idCard, unit } = this.valiFormData;
  134. this.$api.applyVolunteer(
  135. {
  136. name: name,
  137. mobile: mobile,
  138. address: address,
  139. Unit_name: unit,
  140. id_card: idCard
  141. },
  142. function (res) {
  143. if (res.code === 0) {
  144. that.$common.successToShow(res.msg);
  145. } else {
  146. that.$common.errorToShow('服务器异常请稍后再试');
  147. }
  148. // console.log(res);
  149. }
  150. );
  151. }
  152. });
  153. }
  154. }
  155. };
  156. </script>
  157. <style>
  158. .box {
  159. width: 100%;
  160. padding-bottom: 50rpx;
  161. background-image: url('https://huli-app.wenlvti.net/app_static/WenWuGuanJia/image/xbg_2.png');
  162. background-size: 100% 100%;
  163. background-attachment: fixed;
  164. background-repeat: repeat-y;
  165. height: 100%;
  166. }
  167. .text-wrapper_3 {
  168. margin: auto;
  169. height: 80rpx;
  170. flex-direction: column;
  171. width: 240rpx;
  172. background: url('/static/img/search_bg2.png') no-repeat;
  173. background-size: 100% 100%;
  174. }
  175. .tit {
  176. text-align: center;
  177. font-size: 36rpx;
  178. line-height: 80rpx;
  179. letter-spacing: 6rpx;
  180. text-align: center;
  181. font-weight: 700;
  182. background: linear-gradient(180deg, #af7e44 0%, #934b36 100%);
  183. -webkit-background-clip: text;
  184. -webkit-text-fill-color: transparent;
  185. }
  186. /deep/.uni-forms-item__error {
  187. color: red !important;
  188. }
  189. .is-input-border {
  190. background-color: #f7dfc0 !important;
  191. }
  192. .uni-forms-item__label {
  193. color: #000000 !important;
  194. }
  195. .example {
  196. height: 87%;
  197. margin: 20rpx 32rpx 0 32rpx;
  198. }
  199. .uni-forms {
  200. padding: 0 20rpx 0 20rpx;
  201. }
  202. .uni-forms-item {
  203. margin-bottom: 30rpx !important;
  204. }
  205. </style>