index.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <view>
  3. </view>
  4. </template>
  5. <script>
  6. export default {
  7. data() {
  8. return {
  9. getstationCode:null,
  10. }
  11. },
  12. onShow() {
  13. let stationCode = this.getstationCode
  14. console.log("show",stationCode)
  15. if(stationCode){
  16. this.getstationCode = null
  17. this.getPamars(stationCode)
  18. }else{
  19. console.log("redirect home")
  20. uni.reLaunch({
  21. url:'/pages/index/index'
  22. })
  23. }
  24. },
  25. onLoad(options) {
  26. console.log("options",options)
  27. if(options.stationCode){
  28. this.getstationCode=options.stationCode
  29. }
  30. if((decodeURIComponent(options.q)).split("=")[1]){
  31. this.getstationCode = (decodeURIComponent(options.q)).split("=")[1]
  32. }
  33. },
  34. methods: {
  35. getPamars(stationCode){
  36. if(this.$storage.getJson("token")){
  37. this.$http.getStationExchange({
  38. stationCode: stationCode
  39. }).then(res => {
  40. if (res.code === 0 && res.data) {
  41. uni.navigateTo({
  42. url: '/pages/powerExchange/index?stationCode=' +stationCode + '&exchangeNo=' + res.data
  43. })
  44. } else {
  45. uni.navigateTo({
  46. url: '/pages/public/404?error=' + res.msg
  47. })
  48. }
  49. })
  50. }else{
  51. uni.navigateTo({
  52. url: '/pages/public/login?topage='+stationCode,
  53. });
  54. }
  55. }
  56. }
  57. }
  58. </script>
  59. <style>
  60. </style>