talent.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <view class="huodong-details">
  3. <view class="p-30 ">
  4. <view class="detail-title">
  5. {{ title }}
  6. </view>
  7. <view class="content-box bg-white m-t-30">
  8. <view class="detail-cell row-between u-border-bottom" v-for="(item, index) in surveyList"
  9. @tap="pickerShow(item.name)">
  10. <view class="width75">
  11. {{item.description}}
  12. </view>
  13. <view class="text-right flex-1" v-if="item.type == 'radio' || item.type == 'select'">
  14. <text class="muted">{{info[item.name]}}</text>
  15. <u-icon name="arrow-right" size="28" color="#B8B8B8"
  16. :label="info[item.name]!= undefined ? '' :'请选择'" label-pos="left"></u-icon>
  17. <u-picker v-model="show[item.name]" mode="selector" :range="item.value"
  18. @confirm="pickerConfirm(index, $event)" @cancel="pickerCancel(index)"></u-picker>
  19. </view>
  20. <view class="text-right flex-1" v-if="item.type == 'checkbox'">
  21. <u-checkbox-group shape="circle" active-color="#DD4250" :name="item.name"
  22. @change="groupChange(index, $event)">
  23. <u-checkbox :name="value" v-for="(value, key) in item.value" :key="key"
  24. v-model="item.checked[key]">
  25. {{value}}
  26. </u-checkbox>
  27. </u-checkbox-group>
  28. </view>
  29. <view class="text-right flex-1" v-if="item.type == 'text'">
  30. <input type="text" v-model="info[item.name]" placeholder="请输入">
  31. </view>
  32. </view>
  33. <view class="detail-cell row-between u-border-bottom">
  34. <view class="bold">
  35. 验证码
  36. </view>
  37. <view class="text-right flex-1 flex row-right">
  38. <input type="text" v-model="info.code" placeholder="请输入">
  39. <image :src="captchaImg" mode="heightFix" style="height: 54rpx;" class="m-l-10"
  40. @tap="refreshCaptcha"></image>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="footer">
  46. <button class="white btn lg" @click="handleConsult">提交</button>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import {
  52. mapGetters,
  53. mapActions
  54. } from 'vuex'
  55. import {
  56. getSurvey,
  57. submitSurvey
  58. } from '@/api/app';
  59. import {
  60. getCaptcha
  61. } from '@/utils/tools'
  62. const app = getApp()
  63. export default {
  64. data() {
  65. return {
  66. show: {},
  67. surveyList: [],
  68. info: {},
  69. captcha: '',
  70. top: 172,
  71. title: '人才信息'
  72. }
  73. },
  74. onLoad(o) {
  75. //人才类型
  76. this.type = this.$Route.query.type;
  77. this.title = this.title = this.$Route.query.title + '人才信息填写';
  78. this.getSurvey();
  79. this.captchaImg = getCaptcha()
  80. },
  81. onShow() {
  82. uni.setNavigationBarTitle({
  83. title: this.title
  84. });
  85. },
  86. onHide() {},
  87. onPullDownRefresh() {},
  88. methods: {
  89. refreshCaptcha() {
  90. this.captchaImg = getCaptcha()
  91. this.$forceUpdate();
  92. },
  93. // ...mapActions(['getUser']),
  94. groupChange(index, detail) {
  95. let item = this.surveyList[index]
  96. this.info[item.name] = detail
  97. },
  98. pickerShow(index) {
  99. this.show[index] = true
  100. this.$forceUpdate();
  101. },
  102. pickerConfirm(index, obj) {
  103. let item = this.surveyList[index]
  104. this.info[item.name] = item.value[obj[0]]
  105. this.show[item.name] = false
  106. this.$forceUpdate();
  107. },
  108. pickerCancel(index, obj) {
  109. let item = this.surveyList[index]
  110. this.show[item.name] = false
  111. this.$forceUpdate();
  112. },
  113. //获取动态表单
  114. async getSurvey() {
  115. const {
  116. status,
  117. data
  118. } = await getSurvey({
  119. type: this.type
  120. });
  121. if (status == 1) {
  122. this.surveyList = data
  123. this.surveyList.map((item, index) => {
  124. // this.show[item.name] = false;
  125. //初始化radio的info
  126. if (item.type == 'radio' || item.type == 'select') {
  127. this.info[item.name] = item.value[0]
  128. }
  129. //checkbox多选判断,初始化checked状态
  130. if (item.type == 'checkbox') {
  131. item.checked = []
  132. console.log(item.value)
  133. item.value.forEach((value, key) => {
  134. item.checked[key] = false
  135. })
  136. return item;
  137. }
  138. })
  139. }
  140. },
  141. //提交表单
  142. async handleConsult() {
  143. // //todo API验证码
  144. // if (this.captcha == '' || this.captcha != 'abcd') {
  145. // this.$toast({
  146. // title: '验证码错误'
  147. // })
  148. // return false;
  149. // }
  150. const {
  151. status,
  152. data,
  153. msg
  154. } = await submitSurvey(this.info);
  155. if (status == 1) {
  156. uni.setStorageSync('policyList', data);
  157. uni.navigateTo({
  158. url: '/pages/policy/list',
  159. })
  160. }
  161. },
  162. },
  163. computed: {
  164. ...mapGetters(['appConfig']),
  165. }
  166. }
  167. </script>
  168. <style lang="less" scoped>
  169. .huodong-details {
  170. padding-bottom: calc(200rpx + env(safe-area-inset-bottom));
  171. }
  172. .details-images {
  173. height: 408rpx;
  174. border-radius: 20rpx;
  175. overflow: hidden;
  176. width: 100%;
  177. image {
  178. width: 100%;
  179. height: 100%;
  180. }
  181. }
  182. .detail-title {
  183. // font-size: 36rpx;
  184. font-weight: bold;
  185. // padding: 30rpx 0;
  186. }
  187. .detail-cell {
  188. display: flex;
  189. // align-items: center;
  190. padding: 30rpx 0;
  191. .cell-img {
  192. padding: 5rpx 0;
  193. image {
  194. width: 48rpx;
  195. height: 48rpx;
  196. display: block
  197. }
  198. }
  199. }
  200. // .muted {
  201. // color: #989898;
  202. // padding-left: 10rpx;
  203. // }
  204. .detail-biaoti {
  205. // font-size: 36rpx;
  206. height: 88rpx;
  207. line-height: 88rpx;
  208. }
  209. .bj-w {
  210. background-color: #fff;
  211. }
  212. .padding-30 {
  213. padding: 0 30rpx !important;
  214. }
  215. .content-box {
  216. padding: 0 24rpx;
  217. box-shadow: 0rpx 8rpx 16rpx 2rpx rgba(0, 0, 0, 0.03);
  218. border-radius: 12rpx 12rpx 12rpx 12rpx;
  219. input {
  220. font-size: 28rpx;
  221. }
  222. textarea {
  223. width: 100%;
  224. height: 100rpx;
  225. font-size: 28rpx;
  226. }
  227. }
  228. .btn-r-border {
  229. position: relative;
  230. &::after {
  231. content: ' ';
  232. width: 1rpx;
  233. height: 36rpx;
  234. background-color: #CCCCCC;
  235. right: 0;
  236. top: 50%;
  237. margin-top: -18rpx;
  238. position: absolute;
  239. }
  240. }
  241. .width75 {
  242. width: 150rpx;
  243. font-weight: bold;
  244. }
  245. </style>
  246. <style lang="scss">
  247. .footer {
  248. left: 0%;
  249. bottom: 30rpx;
  250. width: 100%;
  251. padding: 0 24rpx;
  252. position: fixed;
  253. z-index: 99;
  254. .btn {
  255. height: 84rpx;
  256. line-height: 84rpx;
  257. background-color: $-color-primary;
  258. box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(243, 113, 113, 0.39);
  259. border-radius: 18rpx 18rpx 18rpx 18rpx;
  260. }
  261. }
  262. page {
  263. padding: 0;
  264. }
  265. .talent-tab {
  266. .title {
  267. font-size: 36rpx;
  268. font-weight: 400;
  269. color: #333333;
  270. }
  271. }
  272. </style>