binding.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. if (app.globalData.userSource=="1007"){
  11. that.setData({
  12. ShowPanel: "bebound",
  13. ParentUserID: options.ParentUserID,
  14. NickName: options.NickName,
  15. });
  16. that.download(options.AvatarUrl);
  17. }
  18. else{
  19. wx.showModal({
  20. title: '抱歉',
  21. content: '绑定功能只能用于朋友单聊',
  22. showCancel: false,
  23. confirmText: "知道了",
  24. success:function(){
  25. wx.reLaunch({
  26. url: '../index/index',
  27. })
  28. }
  29. });
  30. }
  31. }
  32. else {
  33. main.getData("GetUserBindingList?UserID=" + app.globalData.userInfo.UserID, function (data) {
  34. if (data && data.length>0){
  35. that.setData({
  36. List:data,
  37. ShowPanel: "unbinding",
  38. });
  39. }
  40. else{
  41. that.setData({
  42. ShowPanel: "binding",
  43. });
  44. }
  45. });
  46. }
  47. that.setData({
  48. Containnerheight: main.getWindowHeight(),
  49. });
  50. },
  51. download: function (avatarUrl){
  52. var that=this;
  53. wx.downloadFile({
  54. url: avatarUrl,
  55. success(res) {
  56. if (res.statusCode === 200) {
  57. that.setData({
  58. AvatarUrl: res.tempFilePath,
  59. });
  60. }
  61. }
  62. });
  63. },
  64. onShow: function () {
  65. var that = this;
  66. if (app.globalData.userInfo.IsShow==1){
  67. wx.getSetting({
  68. success(res) {
  69. if (res.authSetting['scope.userInfo']) {
  70. }
  71. else {
  72. wx.navigateTo({
  73. url: '../index/accredit',
  74. });
  75. }
  76. }
  77. });
  78. }
  79. },
  80. shareFinished: function () {
  81. wx.showModal({
  82. title: '等待对方接受邀请',
  83. content: '请尽快与对方联系确认邀请',
  84. showCancel: false,
  85. confirmText: "知道了",
  86. });
  87. },
  88. gotoBinding: function () {
  89. var that = this;
  90. main.getData("UpdateUserMemberInfo?UserID=" + app.globalData.userInfo.UserID + "&ParentUserID=" + this.data.ParentUserID, function (data) {
  91. wx.reLaunch({
  92. url: '../index/index',
  93. })
  94. });
  95. },
  96. gotoUnBinding: function () {
  97. var that = this;
  98. main.getData("UpdateUserBinding?ParentUserID=" + app.globalData.userInfo.UserID, function (data) {
  99. wx.reLaunch({
  100. url: '../index/index',
  101. })
  102. });
  103. },
  104. onShareAppMessage: function () {
  105. if (this.data.ShowPanel == "binding") {
  106. var path = '/pages/index/index?type=bebound&ParentUserID=' + app.globalData.userInfo.UserID;
  107. path += "&NickName=" + app.globalData.userInfo.NickName;
  108. path += "&AvatarUrl=" + app.globalData.userInfo.AvatarUrl;
  109. return {
  110. title: app.globalData.userInfo.NickName,
  111. path: path,
  112. imageUrl: app.globalData.uploadImageUrl +"web/program_screenshot_bindaccount.png",
  113. }
  114. }
  115. },
  116. })