晋江文学城
下一章 上一章  目录  设置

6、第 6 章 uniap ...

  •   onLoad(option) {
      this.name = option.name // 页面跳转带来的来电人姓名
      this.city = option.city // 来电人城市
      this.calling()
      this.playLs();
      },

      onUnload() {
      console.log(\"销毁页面\")
      clearInterval(this.timer) // 清除来电震动定时器
      clearInterval(this.phoneJs); // 清除通话时间定时器
      this.ringToneContext.stop(); // 停止来电铃声
      },

      methods:{
      // 挂电话
      toback() {
      console.log(\"拒绝\")
      clearInterval(this.timer)
      this.ringToneContext.stop()
      uni.navigateBack()
      },
      // 接听电话
      answerPhone() {
      var n = this;
      clearInterval(n.timer)
      n.ringToneContext.stop()
      n.callFlg = false
      // n.timeJiShi()
      n.phoneJs = setInterval(() => {
      n.timerPhone++;
      }, 1000);
      },

      // 结束通话
      endCall() {
      clearInterval(this.phoneJs);
      uni.navigateBack()
      },
      // 调用微信震动
      calling() {
      this.timer = setInterval(function() {
      uni.vibrateLong()
      }, 2000);
      },

      // 播放铃声
      playLs() {
      var n = this;
      n.ringToneContext = uni.createInnerAudioContext()
      n.ringToneContext.src = n.ringSrc
      n.ringToneContext.play()
      n.ringToneContext.onEnded(function() {
      n.playLs();
      });
      },

      // 停止方法
      stop() {
      clearInterval(n);
      },

      }

  • 昵称:
  • 评分: 2分|鲜花一捧 1分|一朵小花 0分|交流灌水 0分|别字捉虫 -1分|一块小砖 -2分|砖头一堆
  • 内容:
  •             注:1.评论时输入br/即可换行分段。
  •                 2.发布负分评论消耗的月石并不会给作者。
  •             查看评论规则>>