const app = getApp()
const OneID = require('../../utils/gtoneid-dy-min')
Page({
  data: {
    appid: 'rA2G1vfKeE7NlXKPHZrr73',
    version: '',
    oneid: '',
  },
  onLoad: function () {
    let that = this
    this.setData({
      version: OneID.getVersion()
    })
    OneID.init({
      appId: 'rA2G1vfKeE7NlXKPHZrr73',
      onSuccess: function (res) {
        let r = JSON.stringify(res)
        console.log('OneID init success', r)
        that.setData({
          oneid: 'OneID init success' + r
        })
      },
      onFailure: function (res) {
        console.log('OneID init failure', res)
        that.setData({
          oneid: 'OneID init failure' + res
        })
      }
    })
  },
  queryLbs() {
    OneID.queryLBS(5, {
      onSuccess: function (res) {
        let r = JSON.stringify(res)
        console.log('OneID queryLBS success', r)
      },
      onFailure: function (res) {
        let r = JSON.stringify(res)
        console.log('OneID queryLBS failure', r)
      }
    })
  },
  getLocation() {
    tt.getLocation({
      success(res) {
        console.log(`经度${res.longitude}，维度${res.latitude}`);
      },
      fail(res) {
        console.log(`getLocation调用失败`, res);
      },
    });
  }
})