bind_member_hexiao.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. var app = getApp();
  2. var util = require('../../utils/util.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. community_id: '',
  9. name: '',
  10. mobile: '',
  11. is_login: true
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. util.check_login() ? this.setData({ is_login: true }) : this.setData({ is_login: false });
  18. var scene = decodeURIComponent(options.scene);
  19. if (scene != 'undefined') {
  20. let community_id = scene;
  21. this.setData({ community_id })
  22. } else {
  23. wx.showModal({
  24. title: '提示',
  25. content: '无效二维码,请重新获取!',
  26. showCancel: false,
  27. success(res) {
  28. if (res.confirm) {
  29. wx.redirectTo({
  30. url: '/lionfish_comshop/pages/index/index',
  31. })
  32. }
  33. }
  34. })
  35. }
  36. },
  37. /**
  38. * 授权成功回调
  39. */
  40. authSuccess: function () {
  41. this.setData({ is_login: true })
  42. },
  43. bindInfo: function(){
  44. var that = this;
  45. var token = wx.getStorageSync('token');
  46. let name = this.data.name;
  47. let mobile = this.data.mobile;
  48. let community_id = this.data.community_id;
  49. if (name == '') {
  50. wx.showToast({
  51. title: '请输入姓名!',
  52. icon: 'none'
  53. })
  54. return false;
  55. }
  56. if (mobile == '' || !(/^1(3|4|5|6|7|8|9)\d{9}$/.test(mobile))) {
  57. wx.showToast({
  58. title: '手机号码有误',
  59. icon: 'none'
  60. })
  61. return false;
  62. }
  63. wx.showLoading();
  64. app.util.request({
  65. 'url': 'entry/wxapp/index',
  66. 'data': {
  67. controller: 'community.bind_community_member_do',
  68. token: token,
  69. community_id: community_id,
  70. name,
  71. mobile
  72. },
  73. dataType: 'json',
  74. success: function (res) {
  75. if(res.data.code==0) {
  76. wx.showToast({
  77. title: '绑定成功',
  78. icon: 'none'
  79. },()=>{
  80. wx.redirectTo({
  81. url: '/lionfish_comshop/pages/user/me',
  82. })
  83. })
  84. }
  85. }
  86. })
  87. },
  88. getName: function(e){
  89. console.log(e)
  90. let name = e.detail.value;
  91. this.setData({ name })
  92. },
  93. getMobile: function (e) {
  94. console.log(e)
  95. let mobile = e.detail.value;
  96. this.setData({ mobile })
  97. },
  98. /**
  99. * 生命周期函数--监听页面显示
  100. */
  101. onShow: function () {
  102. }
  103. })