| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- const app = getApp();
- const verify = require("../../../common/js/verify.js");
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- admin_id: 0,
- keyword: ['', '', '', ''],
- tab: 0,
- is_first: [true, true, true, true],
- list: [
- [],
- [],
- [],
- []
- ],
- no_more: [false, false, false, false],
- page: [1, 1, 1, 1],
- custombar: app.globalData.CustomBar,
- nav_top: 0,
- nav_fixed: false,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- const admin_id = wx.getStorageSync('admin_id');
- if (verify.isEmpty(admin_id)) {
- wx.redirectTo({
- url: '/pages/talent/admin/login',
- })
- }
- this.setData({
- admin_id: admin_id
- });
- this.getList();
- },
- //tab切换
- tabSelect(e) {
- let tab = e.currentTarget.dataset.tab;
- this.setData({
- tab: tab
- });
- let is_first = this.data.is_first;
- if (is_first[tab]) {
- is_first[tab] = false;
- this.setData({
- is_first: is_first
- });
- this.getList();
- }
- },
- //搜索
- bindInput(e) {
- let keyword = this.data.keyword;
- keyword[this.data.tab] = e.detail.value;
- this.setData({
- keyword: keyword
- });
- },
- bindSearch() {
- this.resetParam();
- this.getList();
- },
- //获取数据
- getList() {
- let self = this;
- let tab = this.data.tab;
- let no_more = this.data.no_more;
- //没有下一页
- if (no_more[tab]) {
- return false;
- }
- //获取数据
- app.post('talent/admin/lists', {
- status: +tab + 1,
- page: self.data.page[tab],
- keyword: self.data.keyword[tab],
- }, function (res) {
- if (res.length < 10) {
- no_more[tab] = true;
- self.setData({
- no_more: no_more
- });
- }
- let list = self.data.list;
- list[tab] = list[tab].concat(res);
- let page = self.data.page;
- page[tab]++;
- self.setData({
- list: list,
- page: page
- });
- })
- },
- //重置参数
- resetParam() {
- let tab = this.data.tab;
- let list = this.data.list;
- list[tab] = [];
- let no_more = this.data.no_more;
- no_more[tab] = false;
- let page = this.data.page;
- page[tab] = 1;
- this.setData({
- list: list,
- no_more: no_more,
- page: page
- });
- },
- resetKeyword() {
- let keyword = this.data.keyword;
- keyword[this.data.tab] = '';
- this.setData({
- keyword: keyword
- });
- },
- //滚动事件
- onPageScroll(e) {
- if (e.scrollTop >= this.data.nav_top) {
- if (!this.data.nav_fixed) {
- this.setData({
- nav_fixed: true
- });
- }
- } else {
- if (this.data.nav_fixed) {
- this.setData({
- nav_fixed: false
- });
- }
- }
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- this.resetParam();
- this.resetKeyword();
- this.getList();
- wx.stopPullDownRefresh();
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- this.getList();
- },
- logout() {
- wx.removeStorageSync('admin_id');
- wx.redirectTo({
- url: '/pages/talent/admin/login',
- })
- },
- scan() {
- const admin_id = this.data.admin_id;
- const self = this;
- wx.scanCode({
- success({
- result
- }) {
- app.post('talent/admin/scan', {
- code: result,
- admin_id: admin_id
- }, function (res) {
- app.confirm(`接站成功,姓名:${res.talent.name},班次:${res.appointment.shift},出行时间:${res.appointment.start_time}`, function () {
- self.resetParam();
- self.getList();
- });
- });
- },
- fail(res) {
- if (res.errMsg != "scanCode:fail cancel") {
- app.msg('扫码错误,请重新扫码!');
- }
- }
- });
- },
- confirmInfo(e) {
- const id = e.currentTarget.dataset.id;
- const self = this;
- app.confirm('是否确认信息', function () {
- app.post('talent/admin/confirm', {
- id: id,
- admin_id: self.data.admin_id
- }, function () {
- app.msg('操作成功');
- self.resetParam();
- self.getList();
- });
- })
- },
- applyByMobile(e) {
- const self = this;
- const id = e.currentTarget.dataset.id;
- wx.showModal({
- title: '请输入手机号',
- editable: true,
- placeholderText: '请输入手机号',
- success: (res) => {
- app.post('talent/admin/applyByMobile', {
- id: id,
- admin_id: self.data.admin_id,
- mobile: res.content
- }, function () {
- app.msg('操作成功');
- self.resetParam();
- self.getList();
- });
- }
- })
- },
- //拔打电话
- callMobile(e){
- let mobile = e.currentTarget.dataset.mobile;
- if (mobile == '') {
- app.msg('暂无联系方式!');
- return false;
- }
- wx.makePhoneCall({
- phoneNumber: mobile
- })
- },
- ViewImage(e) {
- wx.previewImage({
- urls: [e.currentTarget.dataset.url],
- });
- },
- })
|