distinguish.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // pages/welfareMall/staff/distinguish.js
  2. import WelfareMall from '../../../api/welfareMall'
  3. import { parseTime } from '../../../utils/util'
  4. import {getMobileCache, getPhoneNumber as getPhoneNumberSync} from '../../../utils/user'
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. isLogin: false,
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function (options) {
  16. wx.hideShareMenu();
  17. this.setData({
  18. isLogin: getMobileCache() != ''
  19. })
  20. if(this.data.isLogin){
  21. this.discernStoreStaff();
  22. } else {
  23. wx.switchTab({
  24. url:"/pages/welfareMall/personal/personal",
  25. })
  26. }
  27. },
  28. /**
  29. * 生命周期函数--监听页面初次渲染完成
  30. */
  31. onReady: function () {
  32. },
  33. /**
  34. * 生命周期函数--监听页面显示
  35. */
  36. onShow: function () {
  37. },
  38. /**
  39. * 生命周期函数--监听页面隐藏
  40. */
  41. onHide: function () {
  42. },
  43. /**
  44. * 生命周期函数--监听页面卸载
  45. */
  46. onUnload: function () {
  47. },
  48. /**
  49. * 页面相关事件处理函数--监听用户下拉动作
  50. */
  51. onPullDownRefresh: function () {
  52. },
  53. /**
  54. * 页面上拉触底事件的处理函数
  55. */
  56. onReachBottom: function () {
  57. },
  58. /**
  59. * 用户点击右上角分享
  60. */
  61. onShareAppMessage: function () {
  62. },
  63. discernStoreStaff: async function(){
  64. /**
  65. * 根据手机识别职员信息
  66. */
  67. let resStaff = await WelfareMall.discernStoreStaff({
  68. mobile: getMobileCache(),
  69. });
  70. if(resStaff.data.found){
  71. let staffInfo = resStaff.data;
  72. let shopowner = "no";
  73. if(staffInfo.staffList != null && staffInfo.staffList.length >0){
  74. for(var i=0;i<staffInfo.staffList.length;i++){
  75. //判断员工是否是店长
  76. if(1 == staffInfo.staffList[i].staff.isShopowner){
  77. shopowner = "have";
  78. break;
  79. }
  80. }
  81. }
  82. setTimeout(function () {
  83. wx.redirectTo({
  84. url:"../staff/isStaff?shopowner="+shopowner,
  85. })
  86. }, 2000) //延迟时间
  87. } else {
  88. setTimeout(function () {
  89. wx.redirectTo({
  90. url:"../staff/noStaff"
  91. })
  92. }, 2000) //延迟时间
  93. }
  94. },
  95. })