industry.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view>
  3. <view class="industry">
  4. <view class="left">
  5. <view :class="'li dflex' + (checkIndex == index ? ' active':'')" v-for="(item,index) in industryList" :key="index" @click="checkIndustry(index)">
  6. {{item.name}}
  7. </view>
  8. </view>
  9. <view class="right">
  10. <view :class="'li' + (arrayIndex == index ? ' active':'')" v-for="(item,index) in rightArray" :key="index" @click="checkArray(index)">
  11. {{item.name}}
  12. </view>
  13. </view>
  14. </view>
  15. <view class="btn" @click="save()">确定</view>
  16. </view>
  17. </template>
  18. <script>
  19. const req = require('../../utils/request.js');
  20. const api = require('../../utils/api.js');
  21. const util = require('../../utils/util.js');
  22. var app = getApp();
  23. export default {
  24. data() {
  25. return {
  26. industryList: [],
  27. checkIndex: 0,
  28. rightArray: [],
  29. arrayIndex: -1,
  30. industryName: '',
  31. tradeId: '',
  32. isPoistion: false
  33. };
  34. },
  35. onLoad(options) {
  36. this.isPoistion = options.isPoistion
  37. var titleTxt = '';
  38. if (this.isPoistion) {
  39. titleTxt = '选择职位';
  40. this.getPositionList();
  41. } else {
  42. titleTxt = '选择行业';
  43. this.getIndustry();
  44. }
  45. uni.setNavigationBarTitle({
  46. title: titleTxt
  47. });
  48. },
  49. methods: {
  50. getPositionList() {
  51. req.getRequest(api.api_position_list, {}, data => {
  52. this.industryList = data;
  53. this.rightArray = data[0].children;
  54. });
  55. },
  56. getIndustry() {
  57. req.getRequest(api.company_industry, {}, json => {
  58. this.industryList = json;
  59. this.rightArray = json[0].children;
  60. });
  61. },
  62. checkIndustry(index){
  63. if(this.checkIndex == index) return false;
  64. this.checkIndex = index;
  65. this.rightArray = this.industryList[this.checkIndex].children;
  66. this.arrayIndex=-1;
  67. },
  68. checkArray(index){
  69. if(this.arrayIndex == index) return false;
  70. this.arrayIndex = index;
  71. this.industryName = this.rightArray[this.arrayIndex].name;
  72. this.tradeId = this.rightArray[this.arrayIndex].id;
  73. },
  74. save(){
  75. if(this.arrayIndex < 0) return req.msg('请选择行业');
  76. let pages = getCurrentPages(); //获取所有页面栈实例列表
  77. let nowPage = pages[ pages.length - 1]; //当前页页面实例
  78. let prevPage = pages[ pages.length - 2 ]; //上一页页面实例
  79. if(this.isPoistion){
  80. prevPage.$vm.job = this.industryName;
  81. }else{
  82. prevPage.$vm.industryName = this.industryName; //修改上一页面的 couponNumber 参数值为 value
  83. prevPage.$vm.tradeId = this.tradeId; //修改上一页面的 couponNumber 参数值为 value
  84. }
  85. uni.navigateBack({ //uni.navigateTo跳转的返回,默认1为返回上一级
  86. delta: 1
  87. });
  88. }
  89. }
  90. };
  91. </script>
  92. <style>
  93. @import "./industry.css";
  94. </style>