获取当前地理位置的js

小程序 文章 2022-02-24 12:00 573 0 全屏看文

AI助手支持GPT4.0

获取当前地理位置的jsGet the js of the current geographic location

获取当前地理位置的js

#Page({


  /**

   * 页面的初始数据

   */

  data: {

    latitude:33.637008,

    longitude:114.683015,

    markers:[{

      iconPath:'/imagesavi.png',id:0,

      latitude:33.637008,

      longitude:114.683015,width:50,heigth:50,

      name:"至善会堂",

      address: '周口师范学院'

    }]

  },

markertap:function(e){

  var id=e.detail.markerId

  wx.openLocation({

    latitude:this.data.markers[id].latitude,

    longitude:this.data.markers[id].longitude,

    name:this.data.markers[id].name,

    address:this.data.markers[id].address

  })

}

 

})

#Page({ /** * 页面的初始数据 */ data: { latitude:33.637008, longitude:114.683015, markers:[{ iconPath:'/imagesavi.png',id:0, latitude:33.637008, longitude:114.683015,width:50,heigth:50, name:"至善会堂", address: '周口师范学院' }] }, markertap:function(e){ var id=e.detail.markerId wx.openLocation({ latitude:this.data.markers[id].latitude, longitude:this.data.markers[id].longitude, name:this.data.markers[id].name, address:this.data.markers[id].address }) } })

回答:

平平无奇算卦小能手:

计算机

 index。js

Page({

  data: {

   num:'0',

   op:' '

 },

 result:null,

 isClear:false,

 numBtn:function(e){

   var num=e.target.dataset.val

   if(this.data.num==='0'||this.isClear){

     this.setData({num:num})

     this.isClear=false

 }else{

   this.setData({num:this.data.num+num})

 }

},

opBtn:function(e){

 var op=this.data.op

 var num=Number(this.data.num)

 this.setData({op:e.target.dataset.val})

 if(this.isClear){

   return

 }

 this.isClear=true

 if(this.result===null)

 {

   this.result=num

   return

 }

 if(op==='+')

  {

    this.result=this.result+num

  }else if(op==='-')

  {

    this.result=this.result-num

  }

  else if(op==='*'){

    this.result=this.result*num

  }

  else if(op==='/'){

    this.result=this.resultum

  }

  else if(op==='%'){

    this.result=this.result%num

  }

  this.setData({num:this.result+''})

},


dotBtn:function(){

  if(this.isClear){

    this.setData({num:'0.'})

    this.isClear=false

  }

  if(this.data.num.indexOf('.')>=0)

  {

    return

  }

  this.setData({num:this.data.num+'.'})

},


delBtn:function(){

  var num=this.data.num.substr(0,this.data.num.length-1)

  this.setData({num:num===''?'0':num})

},

resetBtn:function(){

  this.result=null

  this.isClear=false

  this.setData({num:'0',op:''})

}

})


index。wxml

<!-- 上半部分:显示数字和运算符 -->

<view class="result">

  <view class="result-num">{{num}}</view>

  <view class="result-op">{{op}}</view>

</view>


<!-- 下半部分:显示各种按钮 -->

<view class="btns">

  <view>

    <view hover-class="bg" bindtap="resetBtn">C</view>

    <view hover-class="bg" bindtap="delBtn">DEL</view>

    <view hover-class="bg" bindtap="opBtn" data-val="%">%</view>

    <view hover-class="bg" bindtap="opBtn" data-val="/">/</view>

  </view>


   <view>

    <view hover-class="bg" bindtap="numBtn" data-val="7">7</view>

    <view hover-class="bg" bindtap="numBtn" data-val="8">8</view>

    <view hover-class="bg" bindtap="numBtn" data-val="9">9</view>

    <view hover-class="bg" bindtap="opBtn" data-val="*">*</view>

  </view>

  <view>

    <view hover-class="bg" bindtap="numBtn" data-val="4">4</view>

    <view hover-class="bg" bindtap="numBtn" data-val="5">5</view>

    <view hover-class="bg" bindtap="numBtn" data-val="6">6</view>

    <view hover-class="bg" bindtap="opBtn" data-val="-">-</view>

  </view>


  <view>

    <view hover-class="bg" bindtap="numBtn" data-val="1">1</view>

    <view hover-class="bg" bindtap="numBtn" data-val="2">2</view>

    <view hover-class="bg" bindtap="numBtn" data-val="3">3</view>

    <view hover-class="bg" bindtap="opBtn" data-val="+">+</view>

  </view>


  <view>

    <view hover-class="bg" bindtap="numBtn" data-val="0">0</view>

    <view hover-class="bg" bindtap="dotBtn">.</view>

    <view hover-class="bg" bindtap="opBtn" data-val="=">=</view>

  </view>


</view>


index。wxss

page{

  display: flex;

  flex-direction: column;

  height: 100%;

}


.result{

  flex:1;

  background: #f3f6fe;

  position: relative;

}


.result-num{

  position: absolute;

  font-size: 27pt;

  bottom: 5vh;

  right: 3vw;

}


.result-op{

  font-size: 15pt;

  position: absolute;

  bottom: 1vh;

  right: 3vw;

}


.bg{

  background: #eee;

}


.btns{

  flex:1;

  display: flex;

  flex-direction: column;

  font-size: 17pt;

  border-top: 1rpx solid #ccc;

  border-left: 1rpx solid #ccc;


.btns > view{

  flex:1;

  display: flex;

}


.btns > view>view{

  flex-basis: 25%;

  border-right: 1rpx solid #ccc;

  border-bottom: 1rpx solid #ccc;

  box-sizing: border-box;

  display: flex;

  justify-content: center;

  align-items: center;

}


.btns > view:last-child>view:first-child{

  flex-basis: 50%;


.btns>view:first-child>view:first-child{

  color: #f00;

}


.btns>view>view:last-child{

  color: #fc8e00;

}




秦天:

.tr{

  background-color: red;

  display: flex;

  justify-content: center;

  align-items: center;

  height:8vh;

 

}

.td{

  flex: 1;

  text-align: center;

}

.p1{

  background-color:white;

  color: black;

}

.p2{

  background-color: seagreen;

}

.c1{

  color: white;

}

秦天:节目样式文件
秦天:

<view class="table">

<view class="tr">

<view class="td c1"> 序号</view>

<view  class="td c1" >晚会安排</view>

</view>

<view class="c" wx:for="{{party}}" wx:key="{{index}}">

<view wx:if="{{index%2==1}}" class=" tr p1">

<view class="td">{{item.order}}</view>

<view class="td">{{item.detail}}</view>

</view>

<view wx:else class=" tr p2">

<view class="td">{{item.order}}</view>

<view class="td">{{item.detail}}</view>

</view>

</view>

</view>

秦天:节目HTML
秦天:data: {
    party:[
{order:'01',detail:'领导为新年贺词'},
{order:'02',detail:'开场舞-A+艺舞堂'},
{order:'01',detail:'歌曲《Stay with me》'},
{order:'03',detail:'走秀《We are all 20》'},
{order:'04',detail: '小品《喜从天降》'},
{order:'06',detail: '抽奖环节'},
{order:'07',detail: '朗诵《礼赞20年》'},
{order:'08',detail: '古典舞《繁花》'},
{order:'09',detail: '武术《刚柔并济》'}
    ]
  },
秦天:

<image class="bg" src="/uploads/cj/article/2022/02/24/c5b6d0face1c10a7038c56d20d3eede9.jpg"/>

<view class="p1">

<image class="p11" src="/uploads/cj/article/2022/02/24/13daf57037fa4c45f964739653930e04.jpg"/>

<image class="p12" src="/uploads/cj/article/2022/02/24/6a03fe61ebcff6529c81eb2c20aa6dca.jpg"/>

</view>

<view class="p2">

<text class="p21">计算机科学与技术学院</text>

<text class="p22">2020年元旦晚会</text>

</view>

<view class="content">

<view class="title">

<text>主办单位:计算机科学与技术学院</text>

<text space="ensp">时   间:2019年12月30日</text>

<text space="ensp">地   点:至善会堂</text>

</view>

<view class="row">

<navigator url="/pages/map/map" hover-class="none">

<image class="location" src="/uploads/cj/article/2022/02/24/9cb505d167325df56271993302a27a31.jpg"></image>

<avigator>

<navigator url="/pages/map/map" hover-class="none">

    <button class="button">查看地图</button>

<avigator>

</view>

<view class="row">

<navigator url="/pages/detail/detail" hover-class="none">

<image class="location" src="/uploads/cj/article/2022/02/24/71f56aa9418c9066875e44453c5af20d.jpg"></image>

<avigator>

<navigator url="/pages/detail/detail" hover-class="none">

    <button class="button">查看详情</button>

<avigator>

</view>

<view class="row">

<navigator url="" hover-class="none" bindtap="callGroom">

<image class="location" src="/uploads/cj/article/2022/02/24/2602d2ba1239f22392f735f2ce16986f.jpg" ></image>

<avigator>

<navigator url="" hover-class="none" bindtap="callGroom">

    <button class="button">拨打电话</button>

<avigator>

</view>

</view>

秦天:主页html
秦天:

<map latitude="{{latitude}}longitude="{{longitude}}markers="{{markers}}bindmarkertap="markertap"></map>


秦天:wxml
秦天:Page({
  /**
   * 页面的初始数据
   */
  data: {
    latitude:33.637008,
    longitude:114.683015,
    markers:[{
      iconPath:'/imagesavi.png',id:0,
      latitude:33.637008,
      longitude:114.683015,width:50,heigth:50,
      name:"至善会堂",
      address: '周口师范学院'
    }]
  },
markertap:function(e){
  var id=e.detail.markerId
  wx.openLocation({
    latitude:this.data.markers[id].latitude,
    longitude:this.data.markers[id].longitude,
    name:this.data.markers[id].name,
    address:this.data.markers[id].address
  })
}
})

-EOF-

AI助手支持GPT4.0