index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import * as WxJsApi from '@/utils/wxJsApi.js'
  2. import * as API from '@/apis/index.js'
  3. export default {
  4. data() {
  5. return {
  6. btn:{
  7. color: '#1677FF'
  8. },
  9. getPointBl:false,//是否定位完成
  10. longitude: '',
  11. latitude: '',
  12. list: [{
  13. image: 'https://cdn.uviewui.com/uview/swiper/1.jpg',
  14. title: '昨夜星辰昨夜风,画楼西畔桂堂东',
  15. url:"/pages/buytickets/index?id=0cb4dd6c-ca33-4837-bd4a-7f01afb4d1a3"
  16. },
  17. {
  18. image: 'https://cdn.uviewui.com/uview/swiper/2.jpg',
  19. title: '身无彩凤双飞翼,心有灵犀一点通',
  20. url:"/pages/buytickets/index?id=0cb4dd6c-ca33-4837-bd4a-7f01afb4d1a3"
  21. },
  22. {
  23. image: 'https://cdn.uviewui.com/uview/swiper/3.jpg',
  24. title: '谁念西风独自凉,萧萧黄叶闭疏窗,沉思往事立残阳',
  25. url:"/pages/buytickets/index?id=0cb4dd6c-ca33-4837-bd4a-7f01afb4d1a3"
  26. }
  27. ],
  28. siteList:[
  29. ]
  30. }
  31. },
  32. onLoad(){
  33. },
  34. methods: {
  35. gotoQuery(){
  36. uni.navigateTo({
  37. url:'/pages/query/index'
  38. })
  39. },
  40. gotoLine(item){
  41. uni.navigateTo({
  42. url:'/pages/buytickets/selectSite?id='+item.id
  43. })
  44. },
  45. getPoint() {
  46. this.$refs.common.alert("定位中...");
  47. WxJsApi.getLocation().then((res) => {
  48. var latitude = parseFloat(res.latitude);
  49. var longitude = parseFloat(res.longitude);
  50. this.latitude = latitude;
  51. this.longitude = longitude;
  52. this.passengerNearbyStation();
  53. this.getPointBl=true
  54. }).catch(error => {
  55. this.$refs.common.alert( error);
  56. })
  57. },
  58. passengerNearbyStation(){
  59. this.latitude = '30.284867';
  60. this.longitude = '112.291269';
  61. var form={
  62. longitude:this.longitude,
  63. latitude:this.latitude,
  64. pageIndex:1,
  65. pageSize:5
  66. }
  67. API.passengerNearbyStation(form).then((res) => {
  68. this.siteList=res.data;
  69. }).catch(error => {
  70. this.$refs.common.alert( error);
  71. })
  72. },
  73. getScan(){
  74. WxJsApi.scanQRCode(0).then(function(url){
  75. console.log(url)
  76. window.location.href=url;
  77. });
  78. },
  79. clickSwiper(index){
  80. var url=this.list[index].url;
  81. if(url){
  82. if(url.indexOf("http")==0){
  83. window.location.href=url;
  84. }else if(url.indexOf("/pages/")==0){
  85. uni.navigateTo({
  86. url:this.list[index].url
  87. })
  88. }
  89. }
  90. },
  91. closeDropdown() {
  92. this.$refs.uDropdown.close();
  93. }
  94. },onReady(){
  95. WxJsApi.getWxConfig(['scanQRCode','getLocation']);
  96. this.getPoint();
  97. //清空缓存
  98. this.carhelp.set("form",{});
  99. }
  100. }