123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390 |
- const app = require('../../utils/util.js');
- Page({
- data: {
- logs: [],
- currentTabIndex: 0,
- select_all: false,
- isTrue: false,
- isAllTrue: false, // 控制全选和反选的按钮
- listData: [],
- batchIds: '', //选中的ids,
- active: 0,
- show: false,
- infos: {},
- photos: [],
- scrollHeight: '',
- scrollHeight1: '',
- list: [], //探访的数据哈
- number: null,
- },
- onTabsItemTap: function (event) {
- let index = event.currentTarget.dataset.index;
- this.setData({
- currentTabIndex: index
- })
- },
- cellClick(e) {
- console.log(e.currentTarget.dataset.infos);
- if (e.currentTarget.dataset.infos.status !== "2") {
- let that = this
- let fid = e.currentTarget.dataset.infos.fid;
- let name = e.currentTarget.dataset.infos.name;
- const app = getApp()
- app.globalData.id = fid
- app.globalData.name = name
- wx.switchTab({
- url: `/pages/collectInfo/collectInfo`,
- success: function (e) {
- var page = getCurrentPages().pop();
- if (page == undefined || page == null) return;
- page.onLoad();
- }
- })
- } else {
- wx.showToast({
- title: "审核中禁止修改",
- icon: 'none',
- duration: 2000,
- })
- }
- },
- // 探访的记录详情页面
- visitJilu(e) {
- console.log(e.currentTarget.dataset.infos, "000");
- let photos = e.currentTarget.dataset.infos.visitPhoto.split(",");
- console.log(photos, "打印下锕");
- this.setData({
- show: true,
- infos: e.currentTarget.dataset.infos,
- photos: photos
- })
- },
- onClickHide() {
- this.setData({
- show: false
- });
- },
- //删除
- deletes() {
- console.log("ssss");
- let that = this;
- wx.showModal({
- content: '该操作会将所有选中数据删除", "是否删除?',
- success(res) {
- if (res.confirm) {
- //确定绑定的操作
- if (that.data.batchIds.length) {
- for (let item of that.data.batchIds) {
- that.deleteById(item);
- }
- wx.showToast({
- title: '删除成功',
- icon: 'none',
- duration: 2000,
- success: function () {
- switch (that.data.number) {
- case 0:
- that.openIdInfo();
- break;
- case 1:
- that.openIdInfo({
- status: "1"
- });
- break;
- case 2:
- that.openIdInfo({
- status: "0"
- });
- break;
- case 3:
- this.openIdInfo({
- status: "2"
- });
- break;
- case 4:
- this.openIdInfo({
- status: "3"
- });
- break;
- case 5:
- that.openIdInfo({
- status: "4"
- });
- break;
- default:
- that.openIdInfo();
- }
- }
- })
- that.setData({
- isAllTrue: false,
- })
- } else {
- wx.showToast({
- title: '请选择要删除的记录',
- icon: 'none',
- duration: 2000,
- })
- }
- } else if (res.cancel) {
- //取消绑定的操作
- }
- }
- })
- },
- deleteById(id) {
- wx.request({
- url: app.globalData.publicUrl + '/wxinfo/delete',
- method: "GET",
- header: {
- appletsId: wx.getStorageSync('openId')
- },
- data: {
- id: id
- },
- success: (res) => {
- console.log(res, "000");
- }
- })
- },
- //全选与反全选
- selectall: function (e) {
- console.log(e)
- var that = this;
- var arr = []; //存放选中id的数组
- console.log(that.data.listData);
- for (let i = 0; i < that.data.listData.length; i++) {
- if (that.data.listData[i].status != '3') {
- that.data.listData[i].checked = (!that.data.select_all);
- console.log(that.data.select_all);
- if (that.data.listData[i].checked == true) {
- // 全选获取选中的值
- arr = arr.concat(that.data.listData[i]._id.split(','));
- }
- }
- }
- console.log(arr)
- that.setData({
- listData: that.data.listData,
- select_all: (!that.data.select_all),
- batchIds: arr
- })
- },
- //单选
- checkboxChange: function (e) {
- console.log(e.detail.value, "打印的值是啥呢")
- this.setData({
- batchIds: e.detail.value //单个选中的值
- })
- },
- tabsChange(e) {
- this.setData({
- number: e.detail.index,
- isAllTrue: false,
- select_all: false
- })
- switch (e.detail.index) {
- case 0:
- this.openIdInfo();
- break;
- case 1:
- this.openIdInfo({
- status: "1"
- });
- break;
- case 2:
- this.openIdInfo({
- status: "0"
- });
- break;
- case 3:
- this.openIdInfo({
- status: "2"
- });
- break;
- case 4:
- this.openIdInfo({
- status: "3"
- });
- break;
- case 5:
- this.openIdInfo({
- status: "4"
- });
- break;
- default:
- this.openIdInfo();
- break;
- }
- },
- openIdInfo(p) {
- this.oldInfo(p);
- },
- oldInfo(p) {
- console.log("老人锕");
- wx.showLoading({
- title: '加载中',
- mask: true
- })
- wx.request({
- url: app.globalData.publicUrl + '/wxinfo/listByOpenid',
- method: "GET",
- data: p,
- header: {
- appletsId: wx.getStorageSync('openId')
- },
- success: (res) => {
- console.log(res, "0000");
- if (res.data.code == 0) {
- wx.hideLoading();
- this.setData({
- listData: res.data.data
- })
- }
- }
- })
- },
- visitInfo() {
- wx.showLoading({
- title: '加载中',
- mask: true
- })
- wx.request({
- url: app.globalData.publicUrl + '/visit/list',
- method: "GET",
- header: {
- appletsId: wx.getStorageSync('openId')
- },
- success: (res) => {
- console.log(res, "0000");
- if (res.data.code == 0) {
- wx.hideLoading();
- this.setData({
- list: res.data.data
- })
- }
- },
- complete: () => {
- wx.hideLoading();
- }
- })
- },
- computeScrollViewHeight() {
- let that = this
- let query = wx.createSelectorQuery().in(this)
- console.log(query,"111111111111111");
- query.select('.zizi').boundingClientRect()
- query.select('.delete-box').boundingClientRect()
- query.exec(res => {
- console.log(res,"000000000000000000000");
-
- let searchHeight = res[0].height
- let titleHeight = res[1].height
- let windowHeight = wx.getSystemInfoSync().windowHeight
- let scrollHeight = windowHeight - searchHeight - titleHeight - 30 - 10 - 50 - 44
- this.setData({
- scrollHeight: scrollHeight
- })
- })
- },
- computeScrollViewHeight1() {
- let that = this
- let query = wx.createSelectorQuery().in(this)
- query.select('.zizi').boundingClientRect()
- query.exec(res => {
- console.log(res);
-
- let searchHeight = res[0].height
- let windowHeight = wx.getSystemInfoSync().windowHeight
- let scrollHeight = windowHeight - searchHeight - 30 - 5 - 50
- this.setData({
- scrollHeight1: scrollHeight
- })
- })
- },
- onLoad() {
- },
- onShow() {
- console.log(wx.getStorageSync('user'), "打印");
- if (wx.getStorageSync('user') == '') {
- wx.showModal({
- showCancel: false,
- content: '当前您未登录,请登录',
- success (res) {
- if (res.confirm) {
- wx.redirectTo({
- url: '/pages/login/login',
- })
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
-
- this.setData({
- isTrue: false,
- })
- } else {
- this.setData({
- isAllTrue: false,
- select_all: false,
- isTrue: true,
- })
- if(this.data.isTrue){
- console.log("看我锕锕锕锕锕锕锕啊 ");
-
- this.computeScrollViewHeight();
- this.computeScrollViewHeight1();
- }
- this.oldInfo();
- this.visitInfo();
-
- switch (this.data.number) {
- case 0:
- this.openIdInfo();
- break;
- case 1:
- this.openIdInfo({
- status: "1"
- });
- break;
- case 2:
- this.openIdInfo({
- status: "0"
- });
- break;
- case 3:
- this.openIdInfo({
- status: "2"
- });
- break;
- case 4:
- this.openIdInfo({
- status: "3"
- });
- break;
- case 5:
- this.openIdInfo({
- status: "4"
- });
- break;
- default:
- this.openIdInfo();
- break;
- }
- this.visitInfo();
- }
- },
- onHide() {
- this.setData({
- show: false
- })
- }
- })
|