talent.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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. cengci,
  154. msg
  155. } = await submitSurvey(this.info);
  156. if (status == 1) {
  157. uni.setStorageSync('policyList', data);
  158. uni.setStorageSync('policyCengci', cengci);
  159. uni.navigateTo({
  160. url: '/pages/policy/list',
  161. })
  162. }
  163. },
  164. },
  165. computed: {
  166. ...mapGetters(['appConfig']),
  167. }
  168. }
  169. </script>
  170. <style lang="less" scoped>
  171. .huodong-details {
  172. padding-bottom: calc(200rpx + env(safe-area-inset-bottom));
  173. }
  174. .details-images {
  175. height: 408rpx;
  176. border-radius: 20rpx;
  177. overflow: hidden;
  178. width: 100%;
  179. image {
  180. width: 100%;
  181. height: 100%;
  182. }
  183. }
  184. .detail-title {
  185. // font-size: 36rpx;
  186. font-weight: bold;
  187. // padding: 30rpx 0;
  188. }
  189. .detail-cell {
  190. display: flex;
  191. // align-items: center;
  192. padding: 30rpx 0;
  193. .cell-img {
  194. padding: 5rpx 0;
  195. image {
  196. width: 48rpx;
  197. height: 48rpx;
  198. display: block
  199. }
  200. }
  201. }
  202. // .muted {
  203. // color: #989898;
  204. // padding-left: 10rpx;
  205. // }
  206. .detail-biaoti {
  207. // font-size: 36rpx;
  208. height: 88rpx;
  209. line-height: 88rpx;
  210. }
  211. .bj-w {
  212. background-color: #fff;
  213. }
  214. .padding-30 {
  215. padding: 0 30rpx !important;
  216. }
  217. .content-box {
  218. padding: 0 24rpx;
  219. box-shadow: 0rpx 8rpx 16rpx 2rpx rgba(0, 0, 0, 0.03);
  220. border-radius: 12rpx 12rpx 12rpx 12rpx;
  221. input {
  222. font-size: 28rpx;
  223. }
  224. textarea {
  225. width: 100%;
  226. height: 100rpx;
  227. font-size: 28rpx;
  228. }
  229. }
  230. .btn-r-border {
  231. position: relative;
  232. &::after {
  233. content: ' ';
  234. width: 1rpx;
  235. height: 36rpx;
  236. background-color: #CCCCCC;
  237. right: 0;
  238. top: 50%;
  239. margin-top: -18rpx;
  240. position: absolute;
  241. }
  242. }
  243. .width75 {
  244. width: 150rpx;
  245. font-weight: bold;
  246. }
  247. </style>
  248. <style lang="scss">
  249. .footer {
  250. left: 0%;
  251. bottom: 30rpx;
  252. width: 100%;
  253. padding: 0 24rpx;
  254. position: fixed;
  255. z-index: 99;
  256. .btn {
  257. height: 84rpx;
  258. line-height: 84rpx;
  259. background-color: $-color-primary;
  260. box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(243, 113, 113, 0.39);
  261. border-radius: 18rpx 18rpx 18rpx 18rpx;
  262. }
  263. }
  264. page {
  265. padding: 0;
  266. }
  267. .talent-tab {
  268. .title {
  269. font-size: 36rpx;
  270. font-weight: 400;
  271. color: #333333;
  272. }
  273. }
  274. </style>