info-menu.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. const WXAPI = require('apifm-wxapi')
  2. const AUTH = require('../../utils/auth')
  3. Page({
  4. data: {
  5. },
  6. onLoad: function (options) {
  7. },
  8. onShow: function () {
  9. AUTH.wxaCode().then(code => {
  10. this.data.code = code
  11. })
  12. this.getUserApiInfo()
  13. },
  14. async getUserApiInfo() {
  15. const res = await WXAPI.userDetail(wx.getStorageSync('token'))
  16. if (res.code == 0) {
  17. let _data = {}
  18. _data.apiUserInfoMap = res.data
  19. if (res.data.base.mobile) {
  20. _data.userMobile = res.data.base.mobile
  21. }
  22. if (this.data.order_hx_uids && this.data.order_hx_uids.indexOf(res.data.base.id) != -1) {
  23. _data.canHX = true // 具有扫码核销的权限
  24. }
  25. const adminUserIds = wx.getStorageSync('adminUserIds')
  26. if (adminUserIds && adminUserIds.indexOf(res.data.base.id) != -1) {
  27. _data.isAdmin = true
  28. }
  29. if (res.data.peisongMember && res.data.peisongMember.status == 1) {
  30. _data.memberChecked = false
  31. } else {
  32. _data.memberChecked = true
  33. }
  34. this.setData(_data);
  35. }
  36. },
  37. getPhoneNumber: function(e) {
  38. if (!e.detail.errMsg || e.detail.errMsg != "getPhoneNumber:ok") {
  39. wx.showModal({
  40. title: '提示',
  41. content: e.detail.errMsg,
  42. showCancel: false
  43. })
  44. return;
  45. }
  46. WXAPI.bindMobileWxapp(wx.getStorageSync('token'), this.data.code, e.detail.encryptedData, e.detail.iv).then(res => {
  47. AUTH.wxaCode().then(code => {
  48. this.data.code = code
  49. })
  50. if (res.code === 10002) {
  51. AUTH.openLoginDialog()
  52. return
  53. }
  54. if (res.code == 0) {
  55. wx.showToast({
  56. title: '绑定成功',
  57. icon: 'success',
  58. duration: 2000
  59. })
  60. this.getUserApiInfo();
  61. } else {
  62. wx.showModal({
  63. title: '提示',
  64. content: res.msg,
  65. showCancel: false
  66. })
  67. }
  68. })
  69. },
  70. processLogin(e) {
  71. if (!e.detail.userInfo) {
  72. wx.showToast({
  73. title: '已取消',
  74. icon: 'none',
  75. })
  76. return;
  77. }
  78. AUTH.register(this);
  79. },
  80. })