distinguish.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. await WelfareMall.discernStoreStaff({
  71. mobile: getMobileCache(),
  72. }).then(res => {
  73. if (res.code == 200) {
  74. let resStaff = res
  75. if(resStaff.data.found){
  76. let staffInfo = resStaff.data;
  77. let shopowner = "no";
  78. if(staffInfo.staffList != null && staffInfo.staffList.length >0){
  79. for(var i=0;i<staffInfo.staffList.length;i++){
  80. //判断员工是否是店长
  81. if(1 == staffInfo.staffList[i].staff.isShopowner){
  82. shopowner = "have";
  83. break;
  84. }
  85. }
  86. }
  87. setTimeout(function () {
  88. wx.redirectTo({
  89. url:"../staff/isStaff?shopowner="+shopowner,
  90. })
  91. }, 2000) //延迟时间
  92. } else {
  93. setTimeout(function () {
  94. wx.redirectTo({
  95. url:"../staff/noStaff"
  96. })
  97. }, 2000) //延迟时间
  98. }
  99. } else{
  100. wx.switchTab({
  101. url:"/pages/welfareMall/personal/personal",
  102. })
  103. }
  104. }).catch(_ => {
  105. console.log(_)
  106. wx.switchTab({
  107. url:"/pages/welfareMall/personal/personal",
  108. })
  109. })
  110. },
  111. })