| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- import common from '../../utils/util';
- import main from '../../utils/main';
- const app = getApp();
- Page({
- data: {
- IsIPad:"",
- AgeList:[{Name:"学龄前",Grade:0},{Name:"一年级",Grade:1},{Name:"二年级",Grade:2},{Name:"三年级",Grade:3},{Name:"四年级",Grade:4},{Name:"五年级",Grade:5},{Name:"六年级",Grade:6},{Name:"初中及以上",Grade:100}],
- },
- onLoad: function (options) {
- this.setData({
- Containnerheight: main.getWindowHeight(),
- IsAccredit:true,
- });
- var that = this;
- var hType=0;
- if (options.Type)
- hType=options.Type;
- main.getData("GetAccreditInfo?Type=" + hType, function (data) {
- that.setData({
- Info: data,
- Htype:hType,
- });
- });
- if (!app.globalData.userInfo)
- app.globalData.userInfo = {};
- if (app.globalData.IsIPad) {
- that.setData({
- IsIPad: "_iPad",
- });
- }
- },
- //得到用户信息
- getUserInfo: function () {
- var that = this
- wx.getUserProfile({
- desc: "登录注册",
- success: function (res2) {
- that.data.Info.Text3=null;
- that.setData({
- Info: that.data.Info,
- });
- app.globalData.userInfo.NickName = res2.userInfo.nickName;
- app.globalData.userInfo.AvatarUrl = res2.userInfo.avatarUrl;
-
- //调用登录接口
- wx.login({
- success: function (res0) {
- app.globalData.userInfo.Code = res0.code;
- that.login(app.globalData.userInfo, res2.userInfo);
- }
- });
- },
- fail: function (res) {
- console.log(res);
- that.gotoReturn();
- }
- });
- },
- login: function (param, param2) {
- var that = this;
- var url = "MiaoguoLogin";
- main.postData(url, {
- Code: param.Code,
- NickName: param2.nickName,
- AvatarUrl: param2.avatarUrl,
- Language: param2.language,
- Gender: param2.gender,
- City: param2.city,
- Province: param2.province,
- Country: param2.country,
- ProgramVersion: app.globalData.Version,
- Introducer: app.globalData.introducer,
- UserSource: app.globalData.userSource,
- SourceID: app.globalData.SourceID,
- LastUserSource: app.globalData.userSource,
- iv: param.iv,
- encryptedData: param.encryptedData,
- }, function (data) {
- app.globalData.userInfo.NickName = data.NickName;
- app.globalData.userInfo.AvatarUrl = data.AvatarUrl;
- app.globalData.userInfo.Language = data.Language;
- app.globalData.userInfo.Gender = data.Gender;
- app.globalData.userInfo.City = data.City;
- app.globalData.userInfo.Province = data.Province;
- app.globalData.userInfo.Country = data.Country;
- app.globalData.userInfo.IsMember = data.IsMember;
- if (app.globalData.userInfo.UserID){
- if (that.data.Htype==1){
- that.setData({
- IsAccredit:false,
- });
- }
- else{
- that.gotoReturn();
- }
- }
- else {
- app.globalData.userInfo.UserID = data.UserID;
- that.gotoReturn();
- }
- wx.setStorageSync("AccreditLimitTime",common.formatTime(new Date(),"-",true)+" 23:59:59");
- });
- },
- gotoReturn: function () {
- var that = this;
- if (app.globalData.userInfo.IsShow == 1 && that.data.Info.Text3){
- wx.showModal({
- title: '提醒',
- showCancel: false,
- content: that.data.Info.Text3,
- confirmText: '知道了',
- success(res) {
- if (res.confirm) {
- wx.setStorageSync("IsRemindContinuousNew",1);
- }
- }
- });
- }
- else{
- wx.navigateBack({
- delta: 1
- });
- }
- },
- setGrade:function(e){
- var that=this;
- var grade=e.currentTarget.dataset.grade;
- console.log(grade);
- var url = 'SetGrade?UserID=' + app.globalData.userInfo.UserID+'&Grade='+grade;
- main.getData(url, function (data) {
- wx.navigateBack({
- delta: 1
- });
- });
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- },
- })
|