register.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. const app = getApp();
  2. const request = require('../../utils/request.js');
  3. import Toast from '../../miniprogram_npm/@vant/weapp/toast/toast';
  4. Page({
  5. data: {
  6. phone: ''
  7. },
  8. onLoad: function (options) {
  9. // if(!wx.getStorageSync('userId')){
  10. // wx.showModal({
  11. // title: '提示',
  12. // content: '请扫描二维码进入小程序',
  13. // showCancel: false,
  14. // success: (res) => {
  15. // if (res.confirm) {
  16. // wx.navigateTo({
  17. // url: '/pages/login/login',
  18. // })
  19. // }
  20. // }
  21. // })
  22. // return false;
  23. // }
  24. // let userId = app.globalData.userId;
  25. },
  26. onuserChange(e) {
  27. this.setData({
  28. user: e.detail
  29. })
  30. },
  31. onpwdChange(e) {
  32. this.setData({
  33. pwd: e.detail
  34. })
  35. },
  36. async register() {
  37. this.setData({
  38. usererr: this.data.user ? '' : '账号不能为空',
  39. pwderr: this.data.pwd ? '' : '密码不能为空'
  40. })
  41. if (this.data.user && this.data.pwd) {
  42. let options = {
  43. url: 'resource/miniapp/user/register',
  44. // data:params,
  45. data: {
  46. 'loginName': this.data.user,
  47. 'password': this.data.pwd,
  48. 'accountId': ''
  49. },
  50. method: 'POST'
  51. }
  52. let res = await request.query(options);
  53. console.log(res)
  54. if (res.data.code === 200) {
  55. wx.showModal({
  56. title: '提示',
  57. content: '注册成功',
  58. showCancel: false,
  59. success: (res) => {
  60. if (res.confirm) {
  61. wx.navigateTo({
  62. url: '/pages/login/login?user=' + this.data.user + '&&pwd=' + this.data.pwd,
  63. })
  64. }
  65. }
  66. })
  67. } else if (res.data.msg === '客户信息有误,请联系管理员!') {
  68. wx.showModal({
  69. title: '提示',
  70. content: '请扫描二维码进入小程序',
  71. showCancel: false,
  72. success: (res) => {
  73. if (res.confirm) {
  74. wx.scanCode({
  75. success: (res) => {},
  76. fail: (res) => {
  77. console.log(res)
  78. }
  79. })
  80. }
  81. }
  82. })
  83. } else {
  84. Toast.fail(res.data.msg);
  85. }
  86. }
  87. },
  88. /**
  89. * 生命周期函数--监听页面初次渲染完成
  90. */
  91. onReady: function () {
  92. },
  93. /**
  94. * 生命周期函数--监听页面显示
  95. */
  96. onShow: function () {
  97. },
  98. /**
  99. * 生命周期函数--监听页面隐藏
  100. */
  101. onHide: function () {
  102. },
  103. /**
  104. * 生命周期函数--监听页面卸载
  105. */
  106. onUnload: function () {
  107. },
  108. /**
  109. * 页面相关事件处理函数--监听用户下拉动作
  110. */
  111. onPullDownRefresh: function () {
  112. },
  113. /**
  114. * 页面上拉触底事件的处理函数
  115. */
  116. onReachBottom: function () {
  117. },
  118. /**
  119. * 用户点击右上角分享
  120. */
  121. onShareAppMessage: function () {
  122. },
  123. login() {
  124. wx.navigateTo({
  125. url: '/pages/login/login',
  126. })
  127. }
  128. })