binding.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. },
  7. onLoad: function (options) {
  8. var that = this;
  9. if (options && options.type && options.type == "bebound") {
  10. var bBind = 0;
  11. //console.log("userSource3:" + app.globalData.userSource);
  12. var arrUserSource = [1007, 1037, 1089, 1006, 1001, 1005, 1048, 1012, 1024, 1042, 1011, 1106, 1035, 1047, 1020, 1013, 1053];
  13. for (var i = 0; i < arrUserSource.length; i++) {
  14. if (app.globalData.userSource == arrUserSource[i]) {
  15. bBind = 1;
  16. break;
  17. }
  18. }
  19. if (options && options.BindTime) {
  20. var time = new Date(options.BindTime);
  21. var timeNow = new Date();
  22. var sub = common.diffDate("s", time, timeNow);
  23. if (app.globalData.userSource==1006) {
  24. if (sub > 86400) {
  25. bBind = -1;
  26. }
  27. }
  28. else{
  29. if (sub > 180) {
  30. bBind = -1;
  31. }
  32. }
  33. }
  34. if (bBind == 1) {
  35. that.setData({
  36. ShowPanel: "bebound",
  37. ParentUserID: options.ParentUserID,
  38. NickName: options.NickName,
  39. });
  40. that.download(options.AvatarUrl);
  41. }
  42. else {
  43. if (bBind == -1) {
  44. wx.showModal({
  45. title: '请求时间过期',
  46. content: '请联系邀请人,再次私聊发给您。',
  47. showCancel: false,
  48. confirmText: "知道了",
  49. success: function () {
  50. wx.reLaunch({
  51. url: '../index/index',
  52. });
  53. }
  54. });
  55. }
  56. else {
  57. wx.showModal({
  58. title: '无效邀请',
  59. content: '发群无效。请联系邀请人,单独私聊发给您。',
  60. showCancel: false,
  61. confirmText: "知道了",
  62. success: function () {
  63. wx.reLaunch({
  64. url: '../index/index',
  65. });
  66. }
  67. });
  68. }
  69. }
  70. }
  71. else {
  72. main.getData("GetUserBindingList?UserID=" + app.globalData.userInfo.UserID, function (data) {
  73. if (data && data.length > 0) {
  74. that.setData({
  75. List: data,
  76. ShowPanel: "unbinding",
  77. });
  78. }
  79. else {
  80. that.setData({
  81. ShowPanel: "binding",
  82. });
  83. }
  84. });
  85. }
  86. that.setData({
  87. Containnerheight: main.getWindowHeight(),
  88. });
  89. },
  90. download: function (avatarUrl) {
  91. var that = this;
  92. wx.downloadFile({
  93. url: avatarUrl,
  94. success(res) {
  95. if (res.statusCode === 200) {
  96. that.setData({
  97. AvatarUrl: res.tempFilePath,
  98. });
  99. }
  100. }
  101. });
  102. },
  103. onShow: function (options) {
  104. var that = this;
  105. if (app.globalData.userInfo.isShow == 1) {
  106. var today=wx.getStorageSync("AccreditLimitTime");
  107. if (common.formatTime(new Date(),"-")>today){
  108. wx.navigateTo({
  109. url: '../index/accredit?Type=binding',
  110. });
  111. }
  112. }
  113. },
  114. shareFinished: function () {
  115. setTimeout(function () {
  116. wx.showModal({
  117. title: '等待对方接受邀请',
  118. content: '请尽快与对方联系确认邀请',
  119. showCancel: false,
  120. confirmText: "知道了",
  121. });
  122. }, 3000);
  123. },
  124. gotoBinding: function () {
  125. var that = this;
  126. main.getData("UpdateUserMemberInfo?UserID=" + app.globalData.userInfo.UserID + "&ParentUserID=" + this.data.ParentUserID, function (data) {
  127. wx.reLaunch({
  128. url: '../index/index',
  129. })
  130. });
  131. },
  132. gotoUnBinding: function () {
  133. var that = this;
  134. main.getData("UpdateUserBinding?ParentUserID=" + app.globalData.userInfo.UserID, function (data) {
  135. wx.reLaunch({
  136. url: '../index/index',
  137. })
  138. });
  139. },
  140. onShareAppMessage: function () {
  141. if (this.data.ShowPanel == "binding") {
  142. var time = common.formatTime(new Date());
  143. var path = '/pages/index/index?type=bebound&ParentUserID=' + app.globalData.userInfo.UserID + '&BindTime=' + time;
  144. path += "&NickName=" + app.globalData.userInfo.NickName;
  145. path += "&AvatarUrl=" + app.globalData.userInfo.AvatarUrl;
  146. //console.log(path);
  147. return {
  148. title: "帐号绑定 " + time,
  149. path: path,
  150. imageUrl: app.globalData.uploadImageUrl + "web/program_screenshot_bindaccount.png",
  151. }
  152. }
  153. },
  154. })