accredit.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. IsIPad:"",
  7. },
  8. onLoad: function (options) {
  9. var nickname=app.globalData.userInfo.NickName;
  10. if (app.globalData.userInfo.NickName=="陌生用户")
  11. nickname="";
  12. this.setData({
  13. Containnerheight: main.getWindowHeight(),
  14. NickName: nickname,
  15. AvatarUrl: app.globalData.userInfo.AvatarUrl,
  16. });
  17. var that = this;
  18. var hType=0;
  19. if (options.Type)
  20. hType=options.Type;
  21. main.getData("GetAccreditInfo2?Type="+hType, function (data) {
  22. that.setData({
  23. Info: data,
  24. });
  25. });
  26. if (app.globalData.IsIPad) {
  27. that.setData({
  28. IsIPad: "_iPad",
  29. });
  30. }
  31. },
  32. onChooseAvatar:function(e){
  33. var that = this;
  34. console.log(e);
  35. that.uploadFileToServer(e.detail.avatarUrl, function (data) {
  36. if (data) {
  37. that.setData({
  38. AvatarUrl:app.globalData.uploadImageUrl + data.Target,
  39. });
  40. that.save();
  41. }
  42. });
  43. },
  44. onKeyInput: function (e) {
  45. var that=this;
  46. var nickname = e.detail.value;
  47. that.setData({
  48. NickName: nickname,
  49. });
  50. that.save();
  51. },
  52. save:function(){
  53. var that=this;
  54. app.globalData.userInfo.NickName=that.data.NickName;
  55. app.globalData.userInfo.AvatarUrl=that.data.AvatarUrl;
  56. var param={};
  57. param.NickName=app.globalData.userInfo.NickName;
  58. param.AvatarUrl=app.globalData.userInfo.AvatarUrl;
  59. main.postData('UpdateUserNickNameAndAvatar?UserID=' + app.globalData.userInfo.UserID, param, function (data) {
  60. });
  61. },
  62. uploadFileToServer: function (file, callback) {
  63. var url = common.Encrypt("MiaoguoUploadFile2");
  64. wx.showLoading({
  65. title: '上传中',
  66. mask: true,
  67. });
  68. wx.uploadFile({
  69. url: app.globalData.serverUrl + url,
  70. filePath: file,
  71. name: 'file',
  72. success(res) {
  73. var err = JSON.parse(res.data);
  74. if (err.errcode == 10000) {
  75. wx.hideLoading();
  76. callback(err.result);
  77. } else {
  78. wx.hideLoading();
  79. wx.showModal({
  80. title: '上传文件失败',
  81. showCancel: false,
  82. content: JSON.stringify(err.errMsg),
  83. });
  84. }
  85. },
  86. fail: function (err) {
  87. wx.hideLoading();
  88. wx.showModal({
  89. title: '上传文件失败',
  90. showCancel: false,
  91. content: JSON.stringify(err),
  92. });
  93. }
  94. });
  95. },
  96. gotoReturn: function () {
  97. var that=this;
  98. if (app.globalData.userInfo.isShow == 1
  99. && that.data.Info.Remind
  100. && (that.data.NickName=="陌生用户" || that.data.NickName=="")
  101. ){
  102. wx.showModal({
  103. title: '提醒',
  104. showCancel: false,
  105. content: that.data.Info.Remind,
  106. confirmText: '知道了',
  107. success(res) {
  108. if (res.confirm) {
  109. wx.setStorageSync("IsRemindContinuousNew",1);
  110. }
  111. }
  112. });
  113. }
  114. else{
  115. wx.setStorageSync("AccreditLimitTime",common.formatTime(new Date(),"-",true)+" 23:59:59");
  116. wx.navigateBack({
  117. delta: 1
  118. });
  119. }
  120. },
  121. onShareAppMessage: function () {
  122. return {
  123. title: app.globalData.ShareTitle,
  124. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  125. imageUrl: app.globalData.ShareImage,
  126. }
  127. },
  128. })