| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- import common from '../../utils/util';
- import main from '../../utils/main';
- const app = getApp();
- Page({
- data: {
- IsIPad:"",
- },
- onLoad: function (options) {
- var nickname=app.globalData.userInfo.NickName;
- if (app.globalData.userInfo.NickName=="陌生用户")
- nickname="";
- this.setData({
- Containnerheight: main.getWindowHeight(),
- NickName: nickname,
- AvatarUrl: app.globalData.userInfo.AvatarUrl,
- });
- var that = this;
- var hType=0;
- if (options.Type)
- hType=options.Type;
-
- main.getData("GetAccreditInfo2?Type="+hType, function (data) {
- that.setData({
- Info: data,
- });
- });
-
- if (app.globalData.IsIPad) {
- that.setData({
- IsIPad: "_iPad",
- });
- }
- },
- onChooseAvatar:function(e){
- var that = this;
- console.log(e);
- that.uploadFileToServer(e.detail.avatarUrl, function (data) {
- if (data) {
- that.setData({
- AvatarUrl:app.globalData.uploadImageUrl + data.Target,
- });
- that.save();
- }
- });
- },
- onKeyInput: function (e) {
- var that=this;
- var nickname = e.detail.value;
- that.setData({
- NickName: nickname,
- });
- that.save();
- },
- save:function(){
- var that=this;
- app.globalData.userInfo.NickName=that.data.NickName;
- app.globalData.userInfo.AvatarUrl=that.data.AvatarUrl;
-
- var param={};
- param.NickName=app.globalData.userInfo.NickName;
- param.AvatarUrl=app.globalData.userInfo.AvatarUrl;
- main.postData('UpdateUserNickNameAndAvatar?UserID=' + app.globalData.userInfo.UserID, param, function (data) {
-
- });
- },
- uploadFileToServer: function (file, callback) {
- var url = common.Encrypt("MiaoguoUploadFile2");
- wx.showLoading({
- title: '上传中',
- mask: true,
- });
- wx.uploadFile({
- url: app.globalData.serverUrl + url,
- filePath: file,
- name: 'file',
- success(res) {
- var err = JSON.parse(res.data);
- if (err.errcode == 10000) {
- wx.hideLoading();
- callback(err.result);
- } else {
- wx.hideLoading();
- wx.showModal({
- title: '上传文件失败',
- showCancel: false,
- content: JSON.stringify(err.errMsg),
- });
- }
- },
- fail: function (err) {
- wx.hideLoading();
- wx.showModal({
- title: '上传文件失败',
- showCancel: false,
- content: JSON.stringify(err),
- });
- }
- });
- },
- gotoReturn: function () {
- var that=this;
- if (app.globalData.userInfo.isShow == 1
- && that.data.Info.Remind
- && (that.data.NickName=="陌生用户" || that.data.NickName=="")
- ){
- wx.showModal({
- title: '提醒',
- showCancel: false,
- content: that.data.Info.Remind,
- confirmText: '知道了',
- success(res) {
- if (res.confirm) {
- wx.setStorageSync("IsRemindContinuousNew",1);
- }
- }
- });
- }
- else{
- wx.setStorageSync("AccreditLimitTime",common.formatTime(new Date(),"-",true)+" 23:59:59");
- wx.navigateBack({
- delta: 1
- });
- }
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- },
- })
|