123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- const app = getApp()
- var arr = [];
- Page({
- data: {
- //测试.
- versions: false,
- token: '',
- img: app.globalData.imgUrl,
- title: app.globalData.title,
- logoUrl: '',
- bind_mobile: 0,
- session_key: '',
- isAgree:false,
- },
- onLoad: function (options) {
- var that = this;
- my.setNavigationBar({
- title: app.globalData.title
- })
- this.setData({
- logoUrl: app.globalData.logoUrl
- })
- },
- skipXieyi:function(){
- my.navigateTo({
- url: '/pages/agreement/agreement',
- })
- },
- onGotUserInfo: function (e) {
- console.log(e)
- if (e.detail.errMsg == "getUserInfo:fail auth deny") {
- my.showToast({
- content: '授权失败请重试',
- icon: 'none'
- })
- } else {
- my.showLoading({
- content: '登陆中请稍等...',
- mask: true
- })
- if (e.detail.rawData) {
- var data = e.detail.userInfo
- my.setStorageSync({ 'key': 'userInfo', data: data })
- if (my.getStorageSync({ 'key': 'home' }).data.id != undefined) {
- data.area_id = my.getStorageSync({ 'key': 'home' }).data.id
- }
- console.log(data)
- app.request("/auth/weapp-userinfo-sync", data, "POST").then(res => {
- if (res.status == 200) {
- my.showToast({
- content: '授权成功',
- icon: 'none'
- })
- my.setStorageSync({ 'key': 'userInfo', data: res.data })
- // my.navigateBack()
- if (app.globalData.compatible) {
- console.log(app.globalData.compatible)
- my.redirectTo({
- url: '/pages/compatible/index/index',
- })
- } else {
- my.redirectTo({
- url: '/pages/index/index',
- })
- }
- } else {
- my.showToast({
- content: '登陆失败请重试',
- icon: 'none'
- })
- my.redirectTo({
- url: '/pages/index/index',
- })
- }
- })
- } else {
- my.showToast({
- content: '授权失败',
- icon: 'none'
- })
- }
- }
- },
- onAuthError: function () {
- my.showToast({
- content: '授权失败请重试',
- type: 'none'
- });
- },
- getUserPhoneNumber: function (e) {
- console.log(e)
- my.getPhoneNumber({
- success: (res) => {
- console.log(res, "KKKKKKKKKKK")
- let encryptedData = JSON.parse(res.response).response;
- //userObject.phoneInfo = res.response;
- console.log(encryptedData);
- //手机号解密请求
- // phoneAuth(res.response);
- // my.alert({
- // title: encryptedData,
- // });4nbLCy+uBSvO8waRPGv3/EsHNqpa68oN8bPAyJqGjCT6UAVIaMuwChCdRsJkrsKRT3lGHdqyaET7YL2IptOLp7pZYW6w4wl9BHDLmx6V9kRindBZMBTYKzp7ov99o/E6rG3fZZCXSNA59aiKMojMA+JIzMRuo3GRBOcq0YEml6I=
- if (encryptedData.length == 172) return;
- let data = {
- phone_detail: JSON.stringify(arr),
- type: '3',
- session_key: encryptedData,
- auth_id: this.data.auth_id
- }
- app.request('/auth/mobileLogin', data, 'POST', app.globalData.req).then(res => {
- console.log(res, "PPPPppp")
- my.setStorageSync({ key: 'userInfo', data: res.data.user })
- my.setStorageSync({ key: 'token', data: res.data.token });
- console.log(my.getStorageSync({ key: 'token' }))
- // my.setStorageSync('token', res.data.token)
- // my.setStorageSync('token_time', res.data.exp)
- // my.setStorageSync('userInfo', res.data.user)
- my.reLaunch({
- url: '/pages/index/index',
- })
- })
- },
- fail: (res) => {
- console.log(res, "error");
- }
- })
- },
- //手机号登陆
- phoneLogin: function () {
- my.navigateTo({
- url: '/pages/phonelogin/phonelogin',
- })
- },
- //暂不登录
- noSign: function () {
- my.reLaunch({
- url: '/pages/index/index',
- })
- },
- //点击同意用户协议
- clickAgree(){
- this.setData({
- isAgree:!this.data.isAgree
- })
- },
- onReady: function () {
- },
- onShow: function () {
- my.hideBackHome()
- },
- onHide: function () {
- },
- onUnload: function () {
- },
- onPullDownRefresh: function () {
- },
- onReachBottom: function () {
- },
- onShareAppMessage: function () {
- }
- })
|