visitandinfo.js 9.1 KB

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