12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- const {
- login,
- register
- } = require('./../../utils/api.js')
- import routePath from '../../utils/routePath.js';
- import routeUtil from '../../utils/routeUtil.js';
- Page({
- data: {
- nvabarData: {
- showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
- title: '', //导航栏 中间的标题
- },
- isYs: false,
- isAgree: false,
- },
- egree() {
- this.setData({
- isAgree: !this.data.isAgree
- })
- },
- goabout(e) {
- wx.navigateTo({
- url: './../aboutInfo/aboutInfo?type=' + e.currentTarget.dataset.index,
- })
- },
- getPhoneNumber(e) {
- if (e.detail.errMsg != "getPhoneNumber:ok") {
- wx.showToast({
- title: "获取手机号失败",
- icon: 'fail',
- duration: 2000
- });
- return;
- }
- var phoneCode = e.detail.code;
- if (phoneCode) {
- wx.login({
- success: res1 => {
- wx.showLoading({
- title: '加载中',
- });
- // {"openid":"oZHPJ5JcNem2och3ToaocggmUENw","unionid":null,"userId":null,"deviceUid":null,"accessToken":null,"phone":null,"headUrl":"","nickname":"","isNewUser":true}
- login({
- code: res1.code,
- unShowLoad: true,
- }).then((res2) => {
- register({
- openid: res2.openid,
- code: phoneCode,
- unShowLoad: true,
- }).then((res3) => {
- var phone = res3.phone;
- getCurrentPages()[0].loginReset(phone, function () {
- wx.showToast({
- title: "登录成功",
- icon: 'success',
- duration: 2000
- });
- }, function () {
- setTimeout(() => {
- routeUtil.redirectTo(routePath.deviceList);
- }, 2000);
- }, function () {
- wx.hideLoading();
- });
- });
- });
- },
- fail(fail1) {
- wx.hideLoading();
- },
- });
- }
- },
- notlogin() {
- wx.showToast({
- title: '请同意协议',
- icon: "none"
- })
- }
- })
- // 需要用授权登录
- // if ((res.isNewUser && res.isNewUser === true) || !phone) {
- // return;
- // };
|