index.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <view class="content main-bg">
  3. <soldier ref="soldier" v-if="type === '2' || type === '3'"></soldier>
  4. <!-- <soldier v-if="type === '3'"></soldier> -->
  5. <merchant ref="merchant" v-if="type === '5'"></merchant>
  6. <merchantExamine ref="merchantExamine" v-if="type === '4'"></merchantExamine>
  7. </view>
  8. </template>
  9. <script>
  10. import soldier from '@/pages/soldier/home/index'
  11. import merchant from '@/pages/merchant/home/index'
  12. import merchantExamine from '@/pages/manage/merchant/merchantExamine'
  13. export default {
  14. components:{
  15. soldier,
  16. merchant,
  17. merchantExamine
  18. },
  19. data() {
  20. return {
  21. type: '2'
  22. }
  23. },
  24. onLoad() {
  25. uni.startPullDownRefresh();
  26. },
  27. onPullDownRefresh() {
  28. let role = uni.getStorageSync('role');
  29. if(role){
  30. this.type = role;
  31. }
  32. if(this.type === '1'){
  33. this.type = '5'
  34. this.handleShow();
  35. }else if(this.type === '4'){
  36. this.handleManage();
  37. }
  38. setTimeout(function () {
  39. uni.stopPullDownRefresh();
  40. }, 1000);
  41. },
  42. onShow() {
  43. let role = uni.getStorageSync('role');
  44. if(role){
  45. this.type = role;
  46. }
  47. if(this.type === '1'){
  48. this.type = '5'
  49. this.handleShow();
  50. }else if(this.type === '4'){
  51. this.handleManage();
  52. }else{
  53. console.log('onShow handleSoldier ')
  54. this.handleSoldier();
  55. }
  56. },
  57. methods: {
  58. handleShow(){
  59. let userInfo = uni.getStorageSync('userInfo');
  60. if(userInfo.nickName === "null"){
  61. uni.redirectTo({
  62. url: '/pages/merchant/home/modify'
  63. })
  64. }else{
  65. let that = this;
  66. this.$nextTick(function(){
  67. that.$refs.merchant.show();
  68. })
  69. }
  70. },
  71. handleManage(){
  72. this.type = '4';
  73. let that = this;
  74. this.$nextTick(function(){
  75. that.$refs.merchantExamine.show("qwe")
  76. })
  77. },
  78. handleSoldier(){
  79. console.log('this.type', this.type)
  80. console.log('this.$refs.soldier', this.$refs.soldier)
  81. let that = this;
  82. this.$nextTick(function(){
  83. that.$refs.soldier.showSoldier()
  84. })
  85. }
  86. }
  87. }
  88. </script>
  89. <style>
  90. .content {
  91. width: 100%;
  92. height: auto;
  93. }
  94. </style>