binding.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. wx.getSetting({
  67. success(res) {
  68. if (res.authSetting['scope.userInfo']) {
  69. }
  70. else {
  71. wx.navigateTo({
  72. url: '../index/accredit',
  73. });
  74. }
  75. }
  76. });
  77. },
  78. shareFinished: function () {
  79. wx.showModal({
  80. title: '等待对方接受邀请',
  81. content: '请尽快与对方联系确认邀请',
  82. showCancel: false,
  83. confirmText: "知道了",
  84. });
  85. },
  86. gotoBinding: function () {
  87. var that = this;
  88. main.getData("UpdateUserMemberInfo?UserID=" + app.globalData.userInfo.UserID + "&ParentUserID=" + this.data.ParentUserID, function (data) {
  89. wx.reLaunch({
  90. url: '../index/index',
  91. })
  92. });
  93. },
  94. gotoUnBinding: function () {
  95. var that = this;
  96. main.getData("UpdateUserBinding?ParentUserID=" + app.globalData.userInfo.UserID, function (data) {
  97. wx.reLaunch({
  98. url: '../index/index',
  99. })
  100. });
  101. },
  102. onShareAppMessage: function () {
  103. if (this.data.ShowPanel == "binding") {
  104. var path = '/pages/index/index?type=bebound&ParentUserID=' + app.globalData.userInfo.UserID;
  105. path += "&NickName=" + app.globalData.userInfo.NickName;
  106. path += "&AvatarUrl=" + app.globalData.userInfo.AvatarUrl;
  107. return {
  108. title: app.globalData.userInfo.NickName,
  109. path: path,
  110. imageUrl: "../images/program_screenshot_bindaccount.png",
  111. }
  112. }
  113. },
  114. })