index.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import {
  2. ApiModel
  3. } from "../../utils/api"
  4. const _Http = new ApiModel()
  5. Component({
  6. /**
  7. * 组件的属性列表
  8. */
  9. properties: {
  10. userTelephone: {
  11. type: Number
  12. }
  13. },
  14. /**
  15. * 组件的初始数据
  16. */
  17. data: {
  18. //用户名
  19. userName: "",
  20. //身份职位
  21. identity: "",
  22. },
  23. /**
  24. * 组件的方法列表
  25. */
  26. methods: {
  27. /* 用户名 */
  28. setUserName(e) {
  29. this.setData({
  30. userName: e.detail.value
  31. })
  32. },
  33. /* 用户身份 */
  34. setUsereFole(e) {
  35. this.setData({
  36. identity: e.detail.value
  37. })
  38. },
  39. /* 设置默认信息并发送请求 */
  40. setTacitlyApprove() {
  41. let userName = this.data.userName,
  42. identity = this.data.identity;
  43. /* 设置用户名默认值 */
  44. if (userName.length < 1) {
  45. const str = this.data.userTelephone.toString();
  46. userName = str.substring(str.length - 4, str.length) + "用户"
  47. }
  48. /* 设置身份/职位默认值 */
  49. if (identity < 1) {
  50. identity = "管理员";
  51. }
  52. /* 发送请求 */
  53. return _Http.basic({
  54. "accesstoken": wx.getStorageSync('token'),
  55. "classname": "customer.usercenter.usermsg.usermsg",
  56. "method": "update_usermsg",
  57. "content": {
  58. "fname": userName,
  59. "fsex": "",
  60. "fbirthdate": "",
  61. "femail": "",
  62. "fwechatno": "",
  63. "faddress": "",
  64. "frole": identity
  65. }
  66. })
  67. },
  68. /* 下一步,完善商户信息 */
  69. userPerfectMsg() {
  70. this.setTacitlyApprove().then(s => {
  71. console.log(s)
  72. })
  73. },
  74. /* 跳过,跳转首页 */
  75. toHomePage() {
  76. this.setTacitlyApprove().then(s => {
  77. console.log(s)
  78. if (s.msg != "成功") return;
  79. wx.reLaunch({
  80. url: '/pages/tabbarPage/Home/index'
  81. })
  82. })
  83. }
  84. }
  85. })