index.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import * as WxJsApi from '@/utils/wxJsApi.js'
  2. import * as API from '@/apis/index.js'
  3. export default {
  4. data() {
  5. return {
  6. index:0,
  7. btn:{
  8. color: '#1677FF'
  9. },
  10. getPointBl:false,//是否定位完成
  11. longitude: '',
  12. latitude: '',
  13. optionsName:'荆州',
  14. options1:[
  15. {
  16. label: '荆州',
  17. value: '荆州',
  18. },
  19. {
  20. label: '沙市',
  21. value: '沙市',
  22. },
  23. ],
  24. list: [ ],
  25. siteList:[
  26. ]
  27. }
  28. },
  29. onLoad(){
  30. },
  31. methods: {
  32. getBanner() {
  33. API.getBannerInfo("1").then((res) => {
  34. this.list=res.data;
  35. for(var i in this.list){
  36. var obj=this.list[i]
  37. obj.url=obj.linkUrl
  38. obj.image=obj.picUrl
  39. obj.title=obj.name
  40. }
  41. this.carhelp.set("bannerList",this.list);
  42. }).catch(error => {
  43. this.$refs.common.alert( error);
  44. })
  45. },
  46. bindPickerChange: function(e) {
  47. // console.log('picker发送选择改变,携带值为', e.target.value)
  48. this.index = e.target.value
  49. },
  50. gotoQuery(){
  51. uni.navigateTo({
  52. url:'/pages/query/index'
  53. })
  54. },
  55. gotoLine(item){
  56. this.carhelp.set("form",{});
  57. uni.navigateTo({
  58. url:'/pages/buytickets/selectSite?id='+item.id
  59. })
  60. },
  61. getPoint() {
  62. this.$refs.common.alert("正在获取定位信息,为您查找附近的站点...");
  63. WxJsApi.getLocation().then((res) => {
  64. var latitude = parseFloat(res.latitude);
  65. var longitude = parseFloat(res.longitude);
  66. this.latitude = latitude;
  67. this.longitude = longitude;
  68. //this.$refs.common.alert("定位中...",);
  69. this.passengerNearbyStation()
  70. this.getPointBl=true
  71. this.$refs.common.showLoading(false);
  72. }).catch(error => {
  73. this.$refs.common.alert( error);
  74. })
  75. },
  76. passengerNearbyStation(){
  77. // this.latitude = '30.284867';
  78. // this.longitude = '112.291269';
  79. var form={
  80. longitude:this.longitude,
  81. latitude:this.latitude,
  82. pageIndex:1,
  83. pageSize:5
  84. }
  85. this.$refs.common.showLoading();
  86. API.passengerNearbyStation(form).then((res) => {
  87. this.siteList=res.data;
  88. //this.$refs.common.showLoading(fa);
  89. if(this.siteList.length){
  90. this.$refs.common.alert( "已为您查询出附近的站点");
  91. }else{
  92. this.$refs.common.alert( "查询成功,附近暂无站点信息!");
  93. }
  94. }).catch(error => {
  95. this.$refs.common.alert( error);
  96. })
  97. },
  98. getScan(){
  99. WxJsApi.scanQRCode(0).then(function(url){
  100. console.log(url)
  101. window.location.href=url;
  102. });
  103. },
  104. clickSwiper(index){
  105. var url=this.list[index].url;
  106. if(url){
  107. if(url.indexOf("http")==0){
  108. window.location.href=url;
  109. }else if(url.indexOf("/pages/")==0){
  110. uni.navigateTo({
  111. url:this.list[index].url
  112. })
  113. }
  114. }
  115. },
  116. closeDropdown() {
  117. this.$refs.uDropdown.close();
  118. }
  119. },onReady(){
  120. WxJsApi.getWxConfig(['scanQRCode','getLocation']);
  121. var list=this.carhelp.get("bannerList");
  122. if(list){
  123. this.list=list;
  124. }
  125. this.getPoint();
  126. this.getBanner();
  127. //清空缓存
  128. this.carhelp.set("form",{});
  129. }
  130. }