123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- import * as WxJsApi from '@/utils/wxJsApi.js'
- import * as API from '@/apis/index.js'
- export default {
- data() {
- return {
- index:0,
- btn:{
- color: '#1677FF'
- },
- isLoading:false,
- getPointBl:false,//是否定位完成
- longitude: '',
- latitude: '',
- optionsName:'荆州',
- options1:[
- {
- label: '荆州',
- value: '荆州',
- },
- {
- label: '沙市',
- value: '沙市',
- },
- ],
- list: [ ],
- siteList:[
- ]
- }
- },
- onLoad(){
-
- },
- methods: {
- getNewNum(){
-
-
- var pages = getCurrentPages();
- var page = (pages[pages.length - 1]).route;
-
- if(page=="pages/index/index"||
- page=="pages/my/index"||
- page=="pages/news/index"){
- setTimeout(this.getNewNum,10000)
- }else{
- setTimeout(this.getNewNum,1000)
- return;
- }
- var data={
- openId:this.carhelp.getOpenId()
- };
- API.passengerMessageNoReadNum(data).then((res) => {
- var num=res.data.num;
-
-
- if(num){
- uni.setTabBarBadge({
- index: 1,
- text: num+''
- })
- }else{
- uni.removeTabBarBadge({
- index:1
- })
- }
- }).catch(error => {
-
- })
-
-
-
- } ,
- getBanner() {
- API.getBannerInfo("1").then((res) => {
- this.list=res.data;
- for(var i in this.list){
- var obj=this.list[i]
- obj.url=obj.linkUrl
- obj.image=obj.picUrl
- obj.title=obj.name
- }
- this.carhelp.set("bannerList",this.list);
- }).catch(error => {
- this.$refs.common.alert( error);
- })
- },
- bindPickerChange: function(e) {
- // console.log('picker发送选择改变,携带值为', e.target.value)
- this.index = e.target.value
- },
- gotoQuery(){
- uni.navigateTo({
- url:'/pages/query/index?back=true'
- })
- },
- gotoLine(item){
- if(item.id){
- this.carhelp.set("form",{});
- uni.navigateTo({
- url:'/pages/buytickets/selectSite?id='+item.id
- })
- }else{
- uni.navigateTo({
- url:'/pages/route/index?id='+item.routeId
- })
- }
-
- },
- getPoint() {
- this.$refs.common.alert("正在获取定位信息,为您查找附近的站点...");
-
-
- WxJsApi.getLocation().then((res) => {
-
- var latitude = parseFloat(res.latitude);
- var longitude = parseFloat(res.longitude);
-
- this.latitude = latitude;
- this.longitude = longitude;
- //this.$refs.common.alert("定位中...",);
- this.passengerNearbyStation()
- this.getPointBl=true
- this.$refs.common.showLoading(false);
- }).catch(error => {
- this.$refs.common.alert( error);
-
- })
- },
- passengerNearbyStation(){
- this.latitude = '30.306452';
- this.longitude = '112.27642';
-
- var form={
- longitude:this.longitude,
- latitude:this.latitude,
- pageIndex:1,
- pageSize:5
- }
- this.$refs.common.showLoading();
- API.passengerNearbyStation(form).then((res) => {
- this.siteList=res.data;
- this.isLoading=true;
- //this.$refs.common.showLoading(fa);
- if(this.siteList.length){
- this.$refs.common.alert( "已为您查询出附近的站点");
- }else{
- this.$refs.common.alert( "查询成功,附近暂无站点信息!");
- }
- }).catch(error => {
- this.$refs.common.alert( error);
- })
- },
- getScan(){
- this.$refs.common.showLoading()
- WxJsApi.scanQRCode(0,this.$refs.common).then(function(url){
- console.log(url)
-
- window.location.href=url;
- }).catch(error => {
- this.$refs.common.showLoading(false,error)
-
- });
- },
- clickSwiper(index){
-
- var url=this.list[index].url;
- if(url){
- if(url.indexOf("http")==0){
- window.location.href=url;
- }else if(url.indexOf("/pages/")==0){
- uni.navigateTo({
- url:this.list[index].url
- })
- }
- }
- },
- closeDropdown() {
- this.$refs.uDropdown.close();
- }
- },onReady(){
- WxJsApi.getWxConfig(['scanQRCode','getLocation']);
- var list=this.carhelp.get("bannerList");
- if(list){
- this.list=list;
- }
- this.getPoint();
- this.getBanner();
- this.getNewNum()
-
- //清空缓存
- this.carhelp.set("form",{});
- }
- }
|