123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407 |
- import * as WxJsApi from '@/utils/wxJsApi.js'
- import * as API from '@/apis/index.js'
- export default {
- data() {
- return {
- isReady:false,
- rbool:false,
- wxinit:false,
- index:0,
- btn:{
- color: '#1677FF'
- },
- remindBl:false,
- remindInfo:null,
- isLoading:false,
- getPointBl:false,//是否定位完成
- longitude: '',
- latitude: '',
- optionsName:'荆州',
- options1:[
-
- ],
- list: [ ],
- siteList:[
- ],
- radiolist: [
- {
- name: '不提醒',
- isRemind: "0",
- },
- {
- name: '提前1站',
- isRemind: "1",
- },
- {
- name: '提前2站',
- isRemind: "2",
- }
- ],
- // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
- value: 'orange',
- }
- },
- onLoad(){
-
- },
- methods: {
-
- // 选中某个单选框时,由radio时触发
- radioChange(e) {
- // console.log(e);
- },
- // 选中任一radio时,由radio-group触发
- remindHD(){
-
-
- var item= this.remindInfo
-
- if(item.isRemind==0){
- if(this.remindInfo.remindId){
- this.del(item.remindId,item.isRemind!=0)
- }
- return
- }
- if(item.remindId){
- this.del(item.remindId,item.isRemind!=0)
- }else{
- this.add()
- }
-
-
- },
- del(id,bl){
- API.cancelRemind(id).then((res) => {
- this.remindInfo.remindId=""
- if(bl){
- this.add()
- }else{
- this.$refs.common.alert( "设置成功");
- }
- }).catch(error => {
- this.$refs.common.alert( error);
- })
- },
- add(){
- var item= this.remindInfo
- var obj={
- startStationId:item.startStationId,
- remindStationId :item.ticketDownStationId,
- stopInAdvance:item.isRemind,
- remindType:"2",
- vehicleShiftId:item.vehicleShiftId,
- openId:this.carhelp.getOpenId()
- }
- API.saveRemind(obj).then((res) => {
- item.remindId=res.data.id
- this.$refs.common.alert( "设置成功");
-
- }).catch(error => {
- this.$refs.common.alert( error);
- })
- },
- radioGroupChange(item) {
- this.remindHD();
- },
-
- getRemindInfo(){
-
- API.queryRemind(this.carhelp.getOpenId()).then((res) => {
-
- if(res.data.length){
- this.remindInfo=res.data[0]
- var obj=this.remindInfo
- if(obj.remindId){
- this.rbool=true;
- obj.isRemind=obj.stopInAdvance;
- }else{
- obj.isRemind="0";
- }
- }
- }).catch(error => {
- this.$refs.common.alert( error);
- })
- },
-
- 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()
- };
-
- if(!this.carhelp.getOpenId()){
- return
- }
- API.passengerMessageNoReadNum(data).then((res) => {
- var num=res.data.num;
-
-
- if(num){
- uni.setTabBarBadge({
- index: 2,
- text: num+''
- })
- }else{
- uni.removeTabBarBadge({
- index:2
- })
- }
- }).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);
- })
- },
- getOwnerRegion(){
- var obj={
- longitude:this.longitude,
- latitude:this.latitude
- }
- API.getOwnerRegion(obj).then((res) => {
- //this.options1=res.data;
-
- }).catch(error => {
- this.$refs.common.alert( error);
- })
- },
- setRegion(){
- var obj={
- longitude:this.longitude,
- latitude:this.latitude
- }
- API.getOwnerRegion(obj).then((res) => {
-
- var index=0;
- var regionN = this.carhelp.get("car_region");
- var region=res.data.id;
- var obj1={};
- var obj2={};
- for(var i in this.options1 ){
- if(this.options1[i].id==region){
- index=i;
- obj1=this.options1[i]
- }
- if(this.options1[i].id==regionN){
- this.index=i;
- obj2=this.options1[i]
- }
- }
-
- if(regionN&®ionN!=region){
-
- var nowDate =new Date();
- var curDay=nowDate.getFullYear()*10000+(nowDate.getMonth()+1)*10000+nowDate.getDate()*10000+nowDate.getHours()*100+nowDate.getMinutes();
- var temp = this.carhelp.get("car_region_cur");
- var i=30;
- if(process.car.NODE_ENV!="prod"){
- i=3
- }
-
- if(temp&&temp+i>curDay){
- return
- }
- this.carhelp.set("car_region_cur",curDay);
-
- //是否切换
- this.$refs.common.setFnc(()=>{
- this.index=index;
- this.carhelp.set("car_region",region);
- })
- this.$refs.common.confirm('定位显示您在“'+obj1.name+'”,是否切换','切换')
- }else{
- this.index=index;
- this.carhelp.set("car_region",region);
- }
-
- }).catch(error => {
- this.$refs.common.alert( error);
- })
- },
- getRegion(bl) {
- API.getRegionList().then((res) => {
- this.options1=res.data;
- if(this.options1.length){
- this.carhelp.set("car_region_temp", this.options1[0].id);
- }
- var region= this.carhelp.get("car_region");
- if(region){
- for(var i in this.options1 ){
- if(this.options1[i].id==region){
- this.index=i;
- break;
- }
- }
- }
- if(bl){
- this.setRegion();
- }
-
- }).catch(error => {
- this.$refs.common.alert( error);
- })
- },
- bindPickerChange: function(e) {
-
- this.index = e.target.value
- var obj=this.options1[ this.index];
- var nowDate=new Date();
- var curDay=nowDate.getFullYear()*10000+(nowDate.getMonth()+1)*10000+nowDate.getDate()*10000+nowDate.getHours()*100+nowDate.getMinutes();
- this.carhelp.set("car_region_cur",curDay);
- this.carhelp.set("car_region",obj.id);
-
- },
- gotoQuery(){
- uni.navigateTo({
- url:'/pages/query/index?back=true'
- })
- },
- gotoLine(item,downid){
- uni.navigateTo({
- url:'/pages/route/index?id='+item.routeId+"&upid="+item.startStationId+"&downid="+downid
- })
-
- },
- gotoLineList(downid){
-
- uni.navigateTo({
- url:"/pages/index/sitePage?id="+downid+"&longitude="+this.longitude+"&latitude="+this.latitude
- })
-
- },
- 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.getRegion(true);
-
- //this.$refs.common.alert("定位中...",);
- this.passengerNearbyStation()
- this.getPointBl=true
- this.$refs.common.showLoading(false);
- }).catch(error => {
- this.$refs.common.alert( error);
-
- })
- },
- passengerNearbyStation(){
- if(process.car.SIMPLE_RUN){
- 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(['getLocation','addEventListener']).then(()=>{
- this.wxinit=true;
- var _this=this;
-
- })
- //WxJsApi.requestSubscribeMessage(['Ilxy2TX264A3RHqRyDZqL_xUDxi9OuBNeJoDOBfMRHg'])
-
- var list=this.carhelp.get("bannerList");
- if(list){
- this.list=list;
- }
- //this.remindHD()
- this.getPoint();
- this.getBanner();
- this.getNewNum();
- this.getRemindInfo();
-
- this.getRegion();
- //清空缓存
- this.carhelp.set("form",{});
- this.isReady=true;
- },onShow(){
- if(this.isReady){
- this.getPoint();
- this.getRemindInfo();
- }
-
- },
- }
|