visitandinfo.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. const app = require('../../utils/util.js');
  2. const tools = require('../../utils/tools.js');
  3. Page({
  4. data: {
  5. logs: [],
  6. currentTabIndex: 0,
  7. select_all: false,
  8. isTrue: false,
  9. isAllTrue: false, // 控制全选和反选的按钮
  10. listData: [],
  11. batchIds: '', //选中的ids,
  12. active0: 0,
  13. active1: 0,
  14. show: false,
  15. infos: {},
  16. photos: [],
  17. scrollHeight: '',
  18. scrollHeight1: '',
  19. list: [], //巡访的数据哈
  20. number: null,
  21. isShowTrue: false
  22. },
  23. onTabsItemTap: function (event) {
  24. let index = event.currentTarget.dataset.index;
  25. this.setData({
  26. currentTabIndex: index
  27. })
  28. },
  29. cellClick(e) {
  30. if (e.currentTarget.dataset.infos.status !== "2") {
  31. let fid = e.currentTarget.dataset.infos.fid;
  32. let name = e.currentTarget.dataset.infos.name;
  33. const app = getApp()
  34. app.globalData.id = fid
  35. app.globalData.name = name
  36. wx.switchTab({
  37. url: `/pages/collectInfo/collectInfo`,
  38. success: function (e) {
  39. var page = getCurrentPages().pop();
  40. if (page == undefined || page == null) return;
  41. page.onLoad();
  42. }
  43. })
  44. } else {
  45. wx.showToast({
  46. title: "审核中禁止修改",
  47. icon: 'none',
  48. duration: 2000,
  49. })
  50. }
  51. },
  52. // 巡访的记录详情页面
  53. visitJilu(e) {
  54. wx.navigateTo({
  55. url: '../../pages/workDailyInfo/workDailyInfo?infos=' + JSON.stringify(e.currentTarget.dataset.infos),
  56. })
  57. },
  58. onClickHide() {
  59. this.setData({
  60. show: false
  61. });
  62. },
  63. //删除
  64. deletes() {
  65. if (this.data.batchIds.length) {
  66. wx.showModal({
  67. content: '该操作会删除所有选中数据,是否继续?',
  68. success: (res) => {
  69. if (res.confirm) {
  70. let num = 0;
  71. for (let item of this.data.batchIds) {
  72. wx.request({
  73. url: app.globalData.publicUrl + '/wxinfo/delete',
  74. method: "GET",
  75. header: {
  76. appletsId: wx.getStorageSync('openId')
  77. },
  78. data: {
  79. id: item
  80. },
  81. success: () => {
  82. num += 1;
  83. if (num == this.data.batchIds.length) {
  84. wx.showToast({
  85. title: '删除成功',
  86. icon: 'none',
  87. duration: 2000,
  88. success: () => {
  89. switch (this.data.number) {
  90. case 0:
  91. this.openIdInfo();
  92. break;
  93. case 1:
  94. this.openIdInfo({
  95. status: "1"
  96. });
  97. break;
  98. case 2:
  99. this.openIdInfo({
  100. status: "0"
  101. });
  102. break;
  103. case 3:
  104. this.openIdInfo({
  105. status: "2"
  106. });
  107. break;
  108. case 4:
  109. this.openIdInfo({
  110. status: "3"
  111. });
  112. break;
  113. case 5:
  114. this.openIdInfo({
  115. status: "4"
  116. });
  117. break;
  118. default:
  119. this.openIdInfo();
  120. }
  121. }
  122. })
  123. this.setData({
  124. isAllTrue: false,
  125. })
  126. }
  127. }
  128. })
  129. }
  130. console.log(num)
  131. }
  132. }
  133. })
  134. } else {
  135. wx.showToast({
  136. title: '请选择要删除的记录',
  137. icon: 'none',
  138. duration: 2000,
  139. })
  140. }
  141. },
  142. //全选与反全选
  143. selectall: function () {
  144. var arr = []; //存放选中id的数组
  145. for (let i = 0; i < this.data.listData.length; i++) {
  146. if (this.data.listData[i].status != '3') {
  147. this.data.listData[i].checked = (!this.data.select_all);
  148. if (this.data.listData[i].checked == true) {
  149. arr = arr.concat(this.data.listData[i]._id.split(','));
  150. }
  151. }
  152. }
  153. this.setData({
  154. listData: this.data.listData,
  155. select_all: (!this.data.select_all),
  156. batchIds: arr
  157. })
  158. },
  159. //单选
  160. checkboxChange: function (e) {
  161. console.log(e.detail.value, "打印的值是啥呢")
  162. this.setData({
  163. batchIds: e.detail.value //单个选中的值
  164. })
  165. },
  166. tabsChange(e) {
  167. this.setData({
  168. number: e.detail.index,
  169. isAllTrue: false,
  170. select_all: false
  171. })
  172. switch (e.detail.index) {
  173. case 0:
  174. this.openIdInfo();
  175. break;
  176. case 1:
  177. this.openIdInfo({
  178. status: "1"
  179. });
  180. break;
  181. case 2:
  182. this.openIdInfo({
  183. status: "0"
  184. });
  185. break;
  186. case 3:
  187. this.openIdInfo({
  188. status: "2"
  189. });
  190. break;
  191. case 4:
  192. this.openIdInfo({
  193. status: "3"
  194. });
  195. break;
  196. case 5:
  197. this.openIdInfo({
  198. status: "4"
  199. });
  200. break;
  201. default:
  202. this.openIdInfo();
  203. break;
  204. }
  205. },
  206. openIdInfo(p) {
  207. this.oldInfo(p);
  208. },
  209. oldInfo(p) {
  210. console.log('我查数据了')
  211. wx.showLoading({
  212. title: '加载中',
  213. mask: true
  214. })
  215. wx.request({
  216. url: app.globalData.publicUrl + '/wxinfo/listByOpenid',
  217. method: "GET",
  218. data: p,
  219. header: {
  220. appletsId: wx.getStorageSync('openId')
  221. },
  222. success: (res) => {
  223. console.log(res.data.data, "00111111100");
  224. if (res.data.code == 0) {
  225. wx.hideLoading();
  226. this.setData({
  227. listData: res.data.data
  228. })
  229. if (res.data.data.length == 0) {
  230. this.setData({
  231. isShowTrue: 'none'
  232. })
  233. } else {
  234. this.setData({
  235. isShowTrue: 'block'
  236. })
  237. }
  238. }
  239. }
  240. })
  241. },
  242. visitInfo() {
  243. wx.showLoading({
  244. title: '加载中',
  245. mask: true
  246. })
  247. wx.request({
  248. url: app.globalData.publicUrl + '/visit/list',
  249. method: "GET",
  250. header: {
  251. appletsId: wx.getStorageSync('openId')
  252. },
  253. success: (res) => {
  254. console.log(res, "0000");
  255. if (res.data.code == 0) {
  256. wx.hideLoading();
  257. this.setData({
  258. list: res.data.data
  259. })
  260. }
  261. },
  262. complete: () => {
  263. wx.hideLoading();
  264. }
  265. })
  266. },
  267. computeScrollViewHeight() {
  268. this.setData({
  269. scrollHeight: wx.getSystemInfoSync().windowHeight * 2 - 115 - wx.getSystemInfoSync().screenHeight + wx.getSystemInfoSync().statusBarHeight
  270. })
  271. },
  272. computeScrollViewHeight1() {
  273. this.setData({
  274. scrollHeight1: wx.getSystemInfoSync().windowHeight * 2 - wx.getSystemInfoSync().screenHeight + wx.getSystemInfoSync().statusBarHeight
  275. })
  276. },
  277. onShow() {
  278. wx.showLoading({
  279. title: '加载中',
  280. })
  281. tools.rzStatus().then((res) => {
  282. if (res.data.code == 0) {
  283. if (res.data.data) {
  284. // tools.finishInfo().then((res) => {
  285. // console.log(res.data.data.perfect, '我完善信息了吗 1代表完后 0代表未完成')
  286. // console.log(res.data.data.comparison, '我人脸识别过了吗 1代表完后 0代表未完成')
  287. // if (res.data.data.perfect == '0') {
  288. // wx.redirectTo({
  289. // url: '/pages/finishInfo/finishInfo',
  290. // })
  291. // return;
  292. // }
  293. // if (res.data.data.perfect == '1' && res.data.data.comparison == '0') {
  294. // wx.redirectTo({
  295. // url: '/pages/faceRecognition/faceRecognition',
  296. // })
  297. // return;
  298. // }
  299. this.setData({
  300. isAllTrue: false,
  301. select_all: false,
  302. isTrue: true,
  303. })
  304. if (this.data.isTrue) {
  305. this.computeScrollViewHeight();
  306. this.computeScrollViewHeight1();
  307. }
  308. this.oldInfo();
  309. this.visitInfo();
  310. switch (this.data.number) {
  311. case 0:
  312. this.openIdInfo();
  313. break;
  314. case 1:
  315. this.openIdInfo({
  316. status: "1"
  317. });
  318. break;
  319. case 2:
  320. this.openIdInfo({
  321. status: "0"
  322. });
  323. break;
  324. case 3:
  325. this.openIdInfo({
  326. status: "2"
  327. });
  328. break;
  329. case 4:
  330. this.openIdInfo({
  331. status: "3"
  332. });
  333. break;
  334. case 5:
  335. this.openIdInfo({
  336. status: "4"
  337. });
  338. break;
  339. default:
  340. this.openIdInfo();
  341. break;
  342. }
  343. this.visitInfo();
  344. wx.hideLoading()
  345. // })
  346. }
  347. } else {
  348. wx.hideLoading()
  349. wx.clearStorageSync();
  350. wx.showModal({
  351. showCancel: false,
  352. content: '当前您未登录,请登录',
  353. success(res) {
  354. if (res.confirm) {
  355. wx.redirectTo({
  356. url: '/pages/login/login',
  357. })
  358. }
  359. }
  360. })
  361. }
  362. })
  363. },
  364. onHide() {
  365. this.setData({
  366. show: false,
  367. listData: []
  368. })
  369. }
  370. })