second.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. <template>
  2. <view class="content">
  3. <view class="flex til-list" v-if="status == ''">
  4. <view class="" @click="navTo('/pages/applyHelp/index?id='+id)">基本信息</view>
  5. <view class="red">信息选择</view>
  6. <view class="" @click="navTo('/pages/applyHelp/third?id='+id)">家庭成员情况</view>
  7. <view class="" @click="navTo('/pages/applyHelp/fourth?id='+id)">详细情况</view>
  8. </view>
  9. <view class="flex til-list" v-if="status == 2">
  10. <view class="" @click="navTo('/pages/applyHelp/index?id='+id+'&status=2')">基本信息</view>
  11. <view class="red">信息选择</view>
  12. <view class="" @click="navTo('/pages/applyHelp/third?id='+id+'&status=2')">家庭成员情况</view>
  13. <view class="" @click="navTo('/pages/applyHelp/fourth?id='+id+'&status=2')">详细情况</view>
  14. </view>
  15. <view class="content_box">
  16. <view class="list-name">身份</view>
  17. <view class="uni-list">
  18. <radio-group @change="radioChange1">
  19. <view class="radio-list flex_item">
  20. <label class="uni-list-cell uni-list-cell-pd flex_item" v-for="(item, index) in identity" :key="item.name">
  21. <view><radio :disabled="disabled" style="transform:scale(0.7)" color='#FF727E' :value="item.name" :checked="index === current1" /></view>
  22. <view>{{item.name}}</view>
  23. </label>
  24. </view>
  25. </radio-group>
  26. </view>
  27. </view>
  28. <view class="content_box">
  29. <view class="list-name">婚姻状况</view>
  30. <view class="uni-list">
  31. <radio-group @change="radioChange2">
  32. <view class="radio-list flex_item">
  33. <label class="uni-list-cell uni-list-cell-pd flex_item" v-for="(item, index) in marital" :key="item.name">
  34. <view><radio :disabled="disabled" style="transform:scale(0.7)" color='#FF727E' :value="item.name" :checked="index === current2" /></view>
  35. <view>{{item.name}}</view>
  36. </label>
  37. </view>
  38. </radio-group>
  39. </view>
  40. </view>
  41. <view class="content_box">
  42. <view class="list-name">是否医保</view>
  43. <view class="uni-list">
  44. <radio-group @change="radioChange3">
  45. <view class="radio-list flex_item">
  46. <label class="uni-list-cell uni-list-cell-pd flex_item" v-for="(item, index) in insurance" :key="item.name">
  47. <view><radio :disabled="disabled" style="transform:scale(0.7)" color='#FF727E' :value="item.name" :checked="index === current3" /></view>
  48. <view>{{item.name}}</view>
  49. </label>
  50. </view>
  51. </radio-group>
  52. </view>
  53. </view>
  54. <view class="content_box">
  55. <view class="list-name">对象特征</view>
  56. <view class="uni-list">
  57. <radio-group @change="radioChange4">
  58. <view class="radio-list flex_item">
  59. <label class="uni-list-cell uni-list-cell-pd flex_item" v-for="(item, index) in characteristics" :key="item.name">
  60. <view><radio :disabled="disabled" style="transform:scale(0.7)" color='#FF727E' :value="item.name" :checked="index === current4" /></view>
  61. <view>{{item.name}}</view>
  62. </label>
  63. </view>
  64. </radio-group>
  65. </view>
  66. </view>
  67. <view class="content_box">
  68. <view class="list-name">致困原因(最多选三项)</view>
  69. <view class="uni-list">
  70. <checkbox-group @change="checkboxChange">
  71. <view class="radio-list flex_item">
  72. <label class="uni-list-cell uni-list-cell-pd flex_item" v-for="item in maleLike" :key="item.name">
  73. <view>
  74. <checkbox :disabled="disabled" :value="item.name" style="transform:scale(0.7)" color='#FF727E' :checked="item.checked" />
  75. </view>
  76. <view>{{item.name}}</view>
  77. </label>
  78. </view>
  79. </checkbox-group>
  80. </view>
  81. </view>
  82. <view class="add-btn" v-if="status == ''" @click="confirm">下一步</view>
  83. <view class="add-btn" v-if="status == 2" @click="Tosecond">下一步</view>
  84. </view>
  85. </template>
  86. <script>
  87. import uniList from '@/components/uni-list/uni-list.vue';
  88. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  89. import LbPicker from '@/components/lb-picker/index.vue'
  90. import { upload,add_two_help } from '@/api/index.js';
  91. import { getList,helpdetail } from '@/api/applyHelp.js';
  92. export default {
  93. components: {
  94. uniList,
  95. uniListItem,
  96. LbPicker
  97. },
  98. data() {
  99. return {
  100. identity:[{//身份
  101. value: '1',
  102. name: '居民'
  103. },{
  104. value: '2',
  105. name: '村民'
  106. },{
  107. value: '3',
  108. name: '农民工'
  109. },{
  110. value: '4',
  111. name: '在岗'
  112. },{
  113. value: '5',
  114. name: '下岗'
  115. },{
  116. value: '6',
  117. name: '离退休'
  118. },{
  119. value: '7',
  120. name: '病退病休'
  121. }],
  122. current1: '',
  123. checked:'',
  124. marital:[{//婚姻状况
  125. value: '1',
  126. name: '已婚'
  127. },{
  128. value: '2',
  129. name: '未婚'
  130. },{
  131. value: '3',
  132. name: '离异'
  133. },{
  134. value: '4',
  135. name: '丧偶'
  136. }],
  137. current2: '',
  138. checked2:'',
  139. insurance:[{//医保
  140. value: '1',
  141. name: '是'
  142. },{
  143. value: '2',
  144. name: '否'
  145. }],
  146. current3: '',
  147. checked3:'',
  148. characteristics:[{//对象特征
  149. value: '1',
  150. name: '低保对象'
  151. },{
  152. value: '2',
  153. name: '重度残疾'
  154. },{
  155. value: '3',
  156. name: '低保边缘对象'
  157. },{
  158. value: '4',
  159. name: '孤儿、孤寡老人'
  160. },{
  161. value: '5',
  162. name: '因灾、因病致穷家庭'
  163. },{
  164. value: '6',
  165. name: '其它'
  166. }],
  167. current4:'',
  168. checked4:'',
  169. maleLike:[{//致困原因(最多选三项)
  170. value: '1',
  171. name: '意外灾害'
  172. },{
  173. value: '2',
  174. name: '本人大病'
  175. },{
  176. value: '3',
  177. name: '子女上学'
  178. },{
  179. value: '4',
  180. name: '收入低无法维持基本生活'
  181. },{
  182. value: '5',
  183. name: '残疾'
  184. },{
  185. value: '6',
  186. name: '供养直系亲属大病'
  187. },{
  188. value: '7',
  189. name: '下岗失业',
  190. },{
  191. value: '8',
  192. name: '其它'
  193. }],
  194. currentArr: [], // 当前用户想要的选项,最大为5
  195. hasPass: false, // 用户之前是否选择过,是为true
  196. oldArr: [], // 上一次的返回值
  197. status:'',//审核通过
  198. disabled:false,
  199. };
  200. },
  201. onLoad(option) {
  202. if(option.id){
  203. this.id = option.id;
  204. this.helpDetail();
  205. }
  206. if(option.status){
  207. this.status = option.status;
  208. this.disabled = true;
  209. }
  210. },
  211. onUnload() {
  212. uni.navigateTo({
  213. url: '/pages/applyHelp/cation'
  214. });
  215. },
  216. methods: {
  217. //申请详情
  218. helpDetail(){
  219. let obj = this;
  220. helpdetail({
  221. id:obj.id
  222. }).then(({ data }) => {
  223. obj.id = data.id;
  224. console.log(data)
  225. if(data.capacity){
  226. obj.checked = data.capacity;
  227. obj.type = 2;
  228. if(obj.checked == '居民'){
  229. obj.current1 = 0;
  230. }
  231. if(obj.checked == '村民'){
  232. obj.current1 = 1;
  233. }
  234. if(obj.checked == '农民工'){
  235. obj.current1 = 2;
  236. }
  237. if(obj.checked == '在岗'){
  238. obj.current1 = 3;
  239. }
  240. if(obj.checked == '下岗'){
  241. obj.current1 = 4;
  242. }
  243. if(obj.checked == '离退休'){
  244. obj.current1 = 5;
  245. }
  246. if(obj.checked == '病退病休'){
  247. obj.current1 = 6;
  248. }
  249. }
  250. if(data.matrimonial){
  251. obj.checked2 = data.matrimonial;
  252. if(obj.checked2 == '已婚'){
  253. obj.current2 = 0;
  254. }
  255. if(obj.checked2 == '未婚'){
  256. obj.current2 = 1;
  257. }
  258. if(obj.checked2 == '离异'){
  259. obj.current2 = 2;
  260. }
  261. if(obj.checked2 == '丧偶'){
  262. obj.current2 = 3;
  263. }
  264. }
  265. if(data.medical){
  266. obj.checked3 = data.medical;
  267. if(obj.checked3 == '是'){
  268. obj.current3 = 0;
  269. }
  270. if(obj.checked3 == '否'){
  271. obj.current3 = 1;
  272. }
  273. }
  274. if(data.aspect){
  275. obj.checked4 = data.aspect;
  276. if(obj.checked4 == '低保对象'){
  277. obj.current4 = 0;
  278. }
  279. if(obj.checked4 == '重度残疾'){
  280. obj.current4 = 1;
  281. }
  282. if(obj.checked4 == '低保边缘对象'){
  283. obj.current4 = 2;
  284. }
  285. if(obj.checked4 == '孤儿、孤寡老人'){
  286. obj.current4 = 3;
  287. }
  288. if(obj.checked4 == '因灾、因病致穷家庭'){
  289. obj.current4 = 4;
  290. }
  291. if(obj.checked4 == '其它'){
  292. obj.current4 = 5;
  293. }
  294. if(obj.checked4 == '病退病休'){
  295. obj.current4 = 6;
  296. }
  297. }
  298. if(data.poverty){
  299. let poverty = data.poverty.split(",");
  300. let values = poverty;
  301. let items = obj.maleLike;
  302. for (let i = 0, lenI = items.length; i < lenI; ++i) {
  303. let item = items[i]
  304. if(values.includes(item.name)){
  305. obj.$set(item,'checked',true)
  306. }else{
  307. obj.$set(item,'checked',false)
  308. }
  309. }
  310. obj.oldArr = values;
  311. }
  312. }).catch(err => {
  313. console.log(err);
  314. });
  315. },
  316. //提交
  317. confirm() {
  318. let obj = this;
  319. if(obj.oldArr == ''){
  320. this.$api.msg('请选择致困原因!');
  321. return;
  322. }
  323. if(obj.oldArr.length > 3){
  324. this.$api.msg('致困原因最多选三项!');
  325. return;
  326. }
  327. add_two_help({
  328. id:obj.id,
  329. capacity:obj.checked,
  330. matrimonial:obj.checked2,
  331. medical:obj.checked3,
  332. aspect:obj.checked4,
  333. poverty:obj.oldArr.toString(),
  334. }).then(function(e) {
  335. obj.$api.msg(e.msg);
  336. setTimeout(function(){
  337. uni.navigateTo({
  338. url:'/pages/applyHelp/third?id='+obj.id
  339. })
  340. }, 2000);
  341. })
  342. .catch(e => {
  343. obj.$api.msg(e.message);
  344. });
  345. },
  346. Tosecond(){
  347. uni.navigateTo({
  348. url:'/pages/applyHelp/third?id='+this.id+'&status=2'
  349. })
  350. },
  351. radioChange1(evt){
  352. this.checked = evt.detail.value;
  353. console.log(this.checked)
  354. },
  355. radioChange2(evt){
  356. this.checked2 = evt.detail.value;
  357. console.log(this.checked2)
  358. },
  359. radioChange3(evt){
  360. this.checked3 = evt.detail.value;
  361. console.log(this.checked3)
  362. },
  363. radioChange4(evt){
  364. this.checked4 = evt.detail.value;
  365. console.log(this.checked4)
  366. },
  367. checkboxChange: function (e) {
  368. if (e.detail.value.length > 3) { // 如果选择的个数超过3个
  369. if (!this.hasPass) { // 当用户选择数量是第一次超过3
  370. this.hasPass = true
  371. if (e.detail.value.length > this.oldArr.length) { // 如果当前选择总数大于上一次选择总数(用户没有取消过选择)
  372. this.currentArr = e.detail.value.slice(0, 3)
  373. uni.showToast({
  374. title: '最多3个',
  375. icon: 'none'
  376. })
  377. } else { // 如果当前选择总数小于上一次选择总数(用户取消部分选择)
  378. let arr = []
  379. for (var i = 0; i < this.currentArr.length; i++) {
  380. for (var j = 0; j < 3; j++) {
  381. if (this.currentArr[i] === e.detail.value[j]) {
  382. arr.push(this.currentArr[i])
  383. } else {
  384. continue
  385. }
  386. }
  387. }
  388. this.currentArr = arr
  389. }
  390. } else { // 当用户选择数量不是第一次超过3(这时候change事件的返回值里有不一定是用户想要的值,所以需要做判断)
  391. if (e.detail.value.length > this.oldArr.length) { // 用户又增加了选项
  392. let n = e.detail.value.length
  393. if (this.currentArr.length < 3) {
  394. this.currentArr.push(e.detail.value[n - 1])
  395. } else {
  396. uni.showToast({
  397. title: '最多3个',
  398. icon: 'none'
  399. })
  400. }
  401. } else { // 用户取消了部分选项
  402. let arr = []
  403. for (var i = 0; i < this.currentArr.length; i++) {
  404. let n = e.detail.value.indexOf(this.currentArr[i])
  405. if (n !== -1) {
  406. arr.push(this.currentArr[i])
  407. } else {
  408. continue
  409. }
  410. }
  411. this.currentArr = arr
  412. }
  413. }
  414. } else { // 如果选择的个数小于等于3
  415. if (this.hasPass) { // 不是第一次小于3,即之前多选过,后来又取消选择
  416. if (e.detail.value.length < this.oldArr.length) { // 用户取消了部分选择
  417. let arr = []
  418. for (var i = 0; i < this.currentArr.length; i++) {
  419. let n = e.detail.value.indexOf(this.currentArr[i])
  420. if (n !== -1) {
  421. arr.push(this.currentArr[i])
  422. } else {
  423. continue
  424. }
  425. }
  426. this.currentArr = arr
  427. } else { // 用户增加选择,增加的新选项在数组最后
  428. let n = e.detail.value.length
  429. this.currentArr.push(e.detail.value[n - 1])
  430. }
  431. } else { // 是第一次小于3,这个最简单了,直接选了什么就给什么
  432. this.currentArr = e.detail.value
  433. }
  434. if (e.detail.value.length === 0) { // 如果用户取消了全部选择,让hasPass为false,即下一次再选时就会判断为第一次选择
  435. this.hasPass = false
  436. }
  437. }
  438. for (var i = 0, lenI = this.maleLike.length; i < lenI; ++i) { // 给用户的选项添加样式
  439. this.maleLike[i].isChecked = false;
  440. for (var j = 0, lenJ = this.currentArr.length; j < lenJ; ++j) {
  441. if (String(this.maleLike[i].value) === String(this.currentArr[j])) {
  442. this.maleLike[i].isChecked = true
  443. break
  444. }
  445. }
  446. }
  447. this.oldArr = e.detail.value // 把当前返回值赋值给上一次的返回值
  448. console.log(this.oldArr,88)
  449. },
  450. navTo(url) {
  451. uni.navigateTo({
  452. url
  453. });
  454. }
  455. }
  456. };
  457. </script>
  458. <style lang="scss">
  459. page {
  460. background: $page-color-base;
  461. min-height: 100%;
  462. }
  463. .content{
  464. padding-bottom: 100rpx;
  465. }
  466. .tip{
  467. color: #DE2412;
  468. background-color: #FEE2E3;
  469. font-size: 24rpx;
  470. padding: 25rpx 35rpx;
  471. }
  472. .til-list{
  473. padding: 35rpx 50rpx;
  474. font-size: 28rpx;
  475. color: #666666;
  476. .red{
  477. color: #E62129 !important;
  478. }
  479. }
  480. .content_box {
  481. background-color: #ffffff;
  482. padding: 0rpx 25rpx;
  483. margin: 25rpx auto;
  484. .list-name{
  485. padding-top: 25rpx;
  486. font-size: 35rpx;
  487. padding-left: 15rpx;
  488. padding-bottom: 10rpx;
  489. }
  490. }
  491. .row {
  492. display: flex;
  493. align-items: center;
  494. // position: relative;
  495. padding: 0 30rpx;
  496. height: 110rpx;
  497. background: #fff;
  498. border-bottom: 1rpx solid #f8f6f6;
  499. .tit {
  500. flex-shrink: 0;
  501. width: 180rpx;
  502. font-size: 30rpx;
  503. color: $font-color-dark;
  504. }
  505. .value{
  506. width: 100%;
  507. text-align: right;
  508. }
  509. .input {
  510. flex: 1;
  511. font-size: 30rpx;
  512. color: $font-color-dark;
  513. text-align: right;
  514. }
  515. .iconlocation {
  516. font-size: 36rpx;
  517. color: $font-color-light;
  518. }
  519. }
  520. .radio-list{
  521. display: flex;
  522. flex-wrap: wrap;
  523. font-size: 28rpx;
  524. padding-top: 30rpx;
  525. .uni-label-pointer{
  526. padding-right: 25rpx;
  527. padding-bottom: 30rpx;
  528. }
  529. }
  530. .add-btn{
  531. position: fixed;
  532. bottom: 0rpx;
  533. left: 0rpx;
  534. width: 100%;
  535. height: 100rpx;
  536. font-size: 28rpx;
  537. color: #FFFFFF;
  538. background-color: #FF727E;
  539. line-height: 100rpx;
  540. text-align: center;
  541. }
  542. </style>