bind.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. const { Field } = require('../../assets/libs/zanui/index');
  2. var app = getApp();
  3. Page(Object.assign({}, Field, {
  4. data: {
  5. base: {
  6. account: {
  7. name: 'account',
  8. focus: true,
  9. title: '账号',
  10. placeholder: '用户名/邮箱/手机号'
  11. },
  12. password: {
  13. name: 'password',
  14. title: '密码',
  15. inputType: 'password',
  16. placeholder: '请输入你的密码'
  17. },
  18. }
  19. },
  20. onLoad: function (options) {
  21. },
  22. onShow: function () {
  23. if (!app.globalData.userInfo) {
  24. app.error("请登录后再操作", function () {
  25. setTimeout(function () { wx.navigateBack({}) }, 2000);
  26. });
  27. }
  28. },
  29. formSubmit(event) {
  30. var that = this;
  31. app.request('/addons/cms/wxapp.user/bind', event.detail.value, function (data, ret) {
  32. app.globalData.userInfo = data.userInfo;
  33. wx.setStorageSync('token', data.userInfo.token);
  34. app.success(ret.msg, function () {
  35. setTimeout(function () {
  36. //要延时执行的代码
  37. wx.switchTab({
  38. url: 'index'
  39. });
  40. }, 2000); //延迟时间
  41. });
  42. }, function (data, ret) {
  43. app.error(ret.msg);
  44. });
  45. },
  46. formReset(event) {
  47. },
  48. }))