register.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. const app = getApp();
  2. const verify = require("../../../common/js/verify.js");
  3. const {
  4. arrayFindKey
  5. } = require("../../../common/js/common.js");
  6. let self;
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. info: {},
  13. sex: ['保密', '男', '女'],
  14. sex_index: 1,
  15. type: ['请选择用户类型', '高层次人才', '职业经理人协会会员', '政府人员', '晋江人力资本公司vip会员', '其他'],
  16. type_index: 0,
  17. status: 0,
  18. comment: '',
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. self = this;
  25. app.get('teahouse/user/getUserInfo', function (res) {
  26. if (res) {
  27. self.setData({
  28. info: {
  29. name: res.name,
  30. mobile: res.mobile,
  31. idcard: res.idcard,
  32. company: res.company,
  33. job: res.job,
  34. }
  35. });
  36. self.setData({
  37. sex_index: res.sex
  38. });
  39. self.setData({
  40. type_index: arrayFindKey(self.data.type, res.type)
  41. });
  42. self.setData({
  43. comment: res.comment
  44. });
  45. self.setData({
  46. status: res.status
  47. });
  48. }
  49. });
  50. },
  51. changeSex(e) {
  52. let index = e.detail.value;
  53. this.setData({
  54. sex_index: index
  55. });
  56. },
  57. changeType(e) {
  58. let index = e.detail.value;
  59. this.setData({
  60. type_index: index
  61. });
  62. },
  63. vmodel(e) {
  64. this.setData({
  65. ['info.' + e.currentTarget.dataset.value]: e.detail.value
  66. })
  67. },
  68. onSubmit() {
  69. let info = self.data.info;
  70. if (verify.isEmpty(info.name)) {
  71. app.msg('姓名不能为空');
  72. return false;
  73. }
  74. if (verify.isEmpty(info.mobile) && !verify.isMobile(info.mobile)) {
  75. app.msg('电话格式不正确');
  76. return false;
  77. }
  78. if (info.type_index == 0) {
  79. app.msg('请选择用户类型');
  80. return false;
  81. }
  82. info.sex = self.data.sex_index;
  83. info.type = self.data.type[self.data.type_index];
  84. app.post('teahouse/user/editUserInfo', info, function (res) {
  85. app.msg('提交成功,等待审核', () => {
  86. wx.switchTab({
  87. url: '/pages/home/home/home',
  88. });
  89. });
  90. });
  91. },
  92. /**
  93. * 用户点击右上角分享
  94. */
  95. onShareAppMessage() {
  96. return {
  97. title: "晋爱人才",
  98. path: "/pages/home/home/home",
  99. };
  100. }
  101. })