industry.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. };
  33. },
  34. onLoad() {
  35. this.getIndustry();
  36. },
  37. methods: {
  38. getIndustry() {
  39. req.getRequest(api.company_industry, {}, json => {
  40. this.industryList = json;
  41. this.rightArray = json[0].children;
  42. });
  43. },
  44. checkIndustry(index){
  45. if(this.checkIndex == index) return false;
  46. this.checkIndex = index;
  47. this.rightArray = this.industryList[this.checkIndex].children;
  48. this.arrayIndex=-1;
  49. },
  50. checkArray(index){
  51. if(this.arrayIndex == index) return false;
  52. this.arrayIndex = index;
  53. this.industryName = this.rightArray[this.arrayIndex].name;
  54. this.tradeId = this.rightArray[this.arrayIndex].id;
  55. },
  56. save(){
  57. if(this.arrayIndex < 0) return req.msg('请选择行业');
  58. let pages = getCurrentPages(); //获取所有页面栈实例列表
  59. let nowPage = pages[ pages.length - 1]; //当前页页面实例
  60. let prevPage = pages[ pages.length - 2 ]; //上一页页面实例
  61. prevPage.$vm.industryName = this.industryName; //修改上一页面的 couponNumber 参数值为 value
  62. prevPage.$vm.tradeId = this.tradeId; //修改上一页面的 couponNumber 参数值为 value
  63. uni.navigateBack({ //uni.navigateTo跳转的返回,默认1为返回上一级
  64. delta: 1
  65. });
  66. }
  67. }
  68. };
  69. </script>
  70. <style>
  71. @import "./industry.css";
  72. </style>