|
@@ -0,0 +1,160 @@
|
|
|
+// pages/welfareMall/staffManage/staffManage.js
|
|
|
+import WelfareMall from '../../../api/welfareMall'
|
|
|
+import { parseTime } from '../../../utils/util'
|
|
|
+import {getMobileCache, getPhoneNumber as getPhoneNumberSync} from '../../../utils/user'
|
|
|
+Page({
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面的初始数据
|
|
|
+ */
|
|
|
+ data: {
|
|
|
+ lock: false,
|
|
|
+ noResult: false,
|
|
|
+ noMore: false,
|
|
|
+ mobileTop: 'TONY WU',
|
|
|
+ storeList: [],
|
|
|
+ storeStaffList: [],
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面加载
|
|
|
+ */
|
|
|
+ onLoad: function (options) {
|
|
|
+ this.getStoreListByStaff();
|
|
|
+ this.getStoreStaffList();
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面初次渲染完成
|
|
|
+ */
|
|
|
+ onReady: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面显示
|
|
|
+ */
|
|
|
+ onShow: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面隐藏
|
|
|
+ */
|
|
|
+ onHide: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面卸载
|
|
|
+ */
|
|
|
+ onUnload: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面相关事件处理函数--监听用户下拉动作
|
|
|
+ */
|
|
|
+ onPullDownRefresh: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面上拉触底事件的处理函数
|
|
|
+ */
|
|
|
+ onReachBottom: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户点击右上角分享
|
|
|
+ */
|
|
|
+ onShareAppMessage: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+ // 根据职员获取门店列表
|
|
|
+ getStoreListByStaff: function() {
|
|
|
+ WelfareMall.getStoreListByStaff({
|
|
|
+ mobile: getMobileCache(),
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.userStaffListView(res.data)
|
|
|
+ }
|
|
|
+ this.data.lock = false
|
|
|
+ }).catch(_ => {
|
|
|
+ console.log(_)
|
|
|
+ this.data.lock = false
|
|
|
+ })
|
|
|
+},
|
|
|
+
|
|
|
+ userStaffListView: function(data) {
|
|
|
+ if (!Array.isArray(data) || data.length == 0) {
|
|
|
+ console.log("门店列表数据为空");
|
|
|
+ if (this.data.page == 1) {
|
|
|
+ this.setData({
|
|
|
+ mobileTop:getMobileCache(),
|
|
|
+ noResult: true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ mobileTop:getMobileCache(),
|
|
|
+ noMore: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // data.forEach(v => {
|
|
|
+ // let payeTime = v.payedAt
|
|
|
+ // v.payedAt = parseTime(payeTime, "{y}.{m}.{d} {h}:{i}:{s}")
|
|
|
+ // })
|
|
|
+
|
|
|
+ this.data.storeList = this.data.storeList.concat(...data)
|
|
|
+ this.setData({
|
|
|
+ mobileTop:getMobileCache(),
|
|
|
+ storeList: this.data.storeList
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ // 根据登录手机号获取职员列表
|
|
|
+ getStoreStaffList: function() {
|
|
|
+ WelfareMall.getStoreStaffList({
|
|
|
+ mobile: getMobileCache(),
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.userStoreStaffListView(res.data)
|
|
|
+ }
|
|
|
+ this.data.lock = false
|
|
|
+ }).catch(_ => {
|
|
|
+ console.log(_)
|
|
|
+ this.data.lock = false
|
|
|
+ })
|
|
|
+},
|
|
|
+
|
|
|
+ userStoreStaffListView: function(data) {
|
|
|
+ if (!Array.isArray(data) || data.length == 0) {
|
|
|
+ console.log("职员列表数据为空");
|
|
|
+ if (this.data.page == 1) {
|
|
|
+ this.setData({
|
|
|
+ mobileTop:getMobileCache(),
|
|
|
+ noResult: true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ mobileTop:getMobileCache(),
|
|
|
+ noMore: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // data.forEach(v => {
|
|
|
+ // let payeTime = v.payedAt
|
|
|
+ // v.payedAt = parseTime(payeTime, "{y}.{m}.{d} {h}:{i}:{s}")
|
|
|
+ // })
|
|
|
+
|
|
|
+ this.data.storeStaffList = this.data.storeStaffList.concat(...data)
|
|
|
+ this.setData({
|
|
|
+ mobileTop:getMobileCache(),
|
|
|
+ storeStaffList: this.data.storeStaffList
|
|
|
+ })
|
|
|
+ },
|
|
|
+})
|