my.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. const app = getApp()
  2. const util = require("../../../utils/util");
  3. const api = require('../../../api/api.js');
  4. // const update = require('../../../api/update.js');
  5. const user = require('../../../utils/user.js');
  6. import moment from 'moment'
  7. Page({
  8. data: {
  9. interviewInfo: [],
  10. interviewShow: false,
  11. userInfo: {},
  12. labelName: [],
  13. homeInfo: {
  14. onPositionYear: '',
  15. salary: '',
  16. total: '',
  17. unReadSize: "",
  18. workerInfo: {},
  19. workerNotice: [],
  20. stationAdminName: '',
  21. stationAdminTel: '',
  22. },
  23. salary: {
  24. salary: '',
  25. total: ''
  26. },
  27. hasLogin: true,
  28. currentDate: moment(new Date()).format('YYYY-MM-DD'),
  29. currentWeek: '',
  30. myRebuyInfo: {
  31. looseOrderRebuy: 0,
  32. looseOrder: 0,
  33. cycleOrderRebuy: 0,
  34. cycleOrder: 0,
  35. looseOrderRebuyRate: 0,
  36. cycleOrderRebuyRate: 0
  37. },
  38. animate: false,
  39. msgList: [
  40. ],
  41. modalShow: false,
  42. unReadSize: "",
  43. workerInfo: {},
  44. workerNotice: [],
  45. workerNoticeAlert: [],
  46. alertNoticeInfo: {
  47. },
  48. isUat: false
  49. },
  50. goFeedback() {
  51. if (this.data.alertNoticeInfo.isFeedback == 1) {
  52. // 跳转到回执页面
  53. // app.globalData.alertNoticeInfo=this.data.alertNoticeInfo;
  54. wx.navigateTo({
  55. url: '/pages/upgrade/msgReceipt/msgReceipt?id=' + this.data.alertNoticeInfo.id
  56. });
  57. } else if (this.data.alertNoticeInfo.isFeedback != 1 && this.data.alertNoticeInfo.pagePath == '') {
  58. // 调已读接口
  59. util.request(api.readNotice, {
  60. id: this.data.alertNoticeInfo.id
  61. }, 'GET').then(res => {
  62. if (res.errno === 0) {
  63. this.getMsgCenter();
  64. }
  65. });
  66. } else {
  67. // 调已读接口
  68. util.request(api.readNotice, {
  69. id: this.data.alertNoticeInfo.id
  70. }, 'GET').then(res => {
  71. if (res.errno === 0) {
  72. // 跳转其他页面
  73. wx.navigateTo({
  74. url: this.data.alertNoticeInfo.pagePath
  75. });
  76. }
  77. });
  78. }
  79. },
  80. goJoinCp() {
  81. wx.navigateTo({
  82. url: '/pages/upgrade/cp/join',
  83. })
  84. },
  85. /**
  86. * 生命周期函数--监听页面加载
  87. */
  88. onLoad: function (options) {
  89. // val(this.messageScroll,2000);
  90. // let week=util.getWeek(this.data.currentDate);
  91. // this.setData({
  92. // currentWeek:week
  93. // });
  94. // this.getRebuyInfo();
  95. this.isNewYearReport();
  96. // this.getHomeInfo()
  97. // wx.hideTabBar();
  98. },
  99. isNewYearReport() { //是否新年报备
  100. util.request(api.NewYearReported).then(res => {
  101. if (res.data) {
  102. wx.showModal({
  103. title: '返乡调查',
  104. content: '新年返乡调查已开始,是否现在去报备?',
  105. success: function (sm) {
  106. if (sm.confirm) {
  107. wx.navigateTo({
  108. url: '/pages/servant/gohome/report',
  109. })
  110. }
  111. }
  112. });
  113. }
  114. })
  115. },
  116. lastWeek() {
  117. let current = moment(new Date((new Date(this.data.currentDate)).getTime() - 7 * 24 * 60 * 60 * 1000)).format('YYYY-MM-DD');
  118. console.log(current);
  119. let week = util.getWeek(current);
  120. this.setData({
  121. currentDate: current,
  122. currentWeek: week
  123. });
  124. this.getRebuyInfo();
  125. },
  126. nextWeek() {
  127. let current = moment(new Date((new Date(this.data.currentDate)).getTime() + 7 * 24 * 60 * 60 * 1000)).format('YYYY-MM-DD');
  128. console.log(current);
  129. let week = util.getWeek(current);
  130. this.setData({
  131. currentDate: current,
  132. currentWeek: week
  133. });
  134. this.getRebuyInfo();
  135. },
  136. getRebuyInfo() {
  137. util.request(api.myRebuyInfo, {
  138. date: this.data.currentDate,
  139. }, 'GET').then(res => {
  140. if (res.errno === 0) {
  141. this.setData({
  142. myRebuyInfo: res.data
  143. });
  144. }
  145. });
  146. },
  147. messageScroll() {
  148. this.setData({
  149. animate: true
  150. });
  151. setTimeout(() => {
  152. let list = this.data.msgList;
  153. list.push(list[0]);
  154. this.setData({
  155. msgList: list
  156. });
  157. list.shift();
  158. this.setData({
  159. msgList: list,
  160. animate: false
  161. });
  162. }, 3000);
  163. },
  164. makeCall(e) {
  165. let mobile = e.currentTarget.dataset.mobile;
  166. wx.makePhoneCall({
  167. phoneNumber: mobile,
  168. })
  169. },
  170. exitLogin: function () {
  171. wx.showModal({
  172. title: '',
  173. confirmColor: '#b4282d',
  174. content: '退出登录?',
  175. success: function (res) {
  176. if (!res.confirm) {
  177. return;
  178. }
  179. util.request(api.AuthLogout, {}, 'POST');
  180. app.globalData.hasLogin = false;
  181. wx.removeStorageSync('token');
  182. wx.removeStorageSync('userInfo');
  183. wx.redirectTo({
  184. url: '/pages/index/index'
  185. });
  186. }
  187. })
  188. },
  189. getInterview() {
  190. util.request(api.interview, {
  191. // workerNo:this.data.userInfo.workerNo,
  192. // status:1,
  193. }, 'GET').then(res => {
  194. console.log(res);
  195. if (res.errno == 0) {
  196. // if(res.data&&res.data!=null){
  197. // if(res.data.length>=1){
  198. this.setData({
  199. interviewInfo: res.data
  200. });
  201. // }
  202. // }
  203. }
  204. });
  205. },
  206. operateInterview(e) {
  207. let type = e.currentTarget.dataset.type;
  208. let id = e.currentTarget.dataset.id;
  209. let content = (type == 1 ? '确定接受邀请么?' : '确定拒绝邀请么?')
  210. wx.showModal({
  211. title: '',
  212. content: content,
  213. success: res => {
  214. if (res.confirm) {
  215. util.request(api.acceptOrRefuseInterview, {
  216. interviewId: id,
  217. isAccept: type,
  218. }, 'GET').then(res => {
  219. console.log(res);
  220. if (res.errno == 0) {
  221. this.getInterview();
  222. }
  223. });
  224. }
  225. }
  226. });
  227. },
  228. getHomeInfo() {
  229. util.request(api.homeInfo, {}, 'GET').then(res => {
  230. console.log(res);
  231. if (res.errno === 0) {
  232. console.log(res.data.workerInfo.labelNames);
  233. console.log(res.data.workerInfo.labelNames.split(','));
  234. this.setData({
  235. homeInfo: res.data,
  236. labelName: res.data.workerInfo.labelNames == "" ? [] : res.data.workerInfo.labelNames.split(','),
  237. // 'homeInfo.unReadSize':res.data.unReadSize>99?99:res.data.unReadSize
  238. });
  239. }
  240. });
  241. },
  242. goLeave() { //请假
  243. wx.navigateTo({
  244. url: '/pages/servant/leave/leave',
  245. });
  246. // wx.showModal({
  247. // title: '提醒',
  248. // content: '暂未开通,敬请期待',
  249. // showCancel: false
  250. // });
  251. },
  252. goHouse() {
  253. wx.showModal({
  254. title: '提醒',
  255. content: '暂未开通,敬请期待',
  256. showCancel: false
  257. })
  258. },
  259. getPerfect() {
  260. // wx.navigateTo({
  261. // url: '/pages/servant/perfect/perfectWorkerInfo'
  262. // });
  263. wx.navigateTo({
  264. url: '/pages/upgrade/completeInfo/completeInfo'
  265. });
  266. },
  267. goBookIndex(e) {
  268. if (this.data.hasLogin) {
  269. let tab = e.currentTarget.dataset.index
  270. let route = e.currentTarget.dataset.route
  271. try {
  272. wx.setStorageSync('tab', tab);
  273. } catch (e) {
  274. }
  275. wx.navigateTo({
  276. url: route,
  277. })
  278. } else {
  279. wx.navigateTo({
  280. url: "/pages/index/index"
  281. });
  282. };
  283. },
  284. // goNucleicList() {
  285. // wx.navigateTo({
  286. // url: '/pages/servant/nucleic/list'
  287. // });
  288. // wx.navigateTo({
  289. // url: '/pages/servant/gohome/report',
  290. // })
  291. // },
  292. goMessage() {
  293. wx.navigateTo({
  294. url: '/pages/upgrade/messageList/messageList'
  295. })
  296. },
  297. goSalaryDetail(e) { //查询工资明细
  298. // const {
  299. // year,
  300. // month
  301. // } = calendar.getCurrentYM();
  302. // let m = '11';
  303. // if (m < 10) m = '0' + String(m);
  304. // let year='2022-';
  305. let month = moment(new Date()).format('YYYY-MM');
  306. let type = e.currentTarget.dataset.type;
  307. let total = (type == 1 ? this.data.homeInfo.salary : this.data.homeInfo.total);
  308. //servantType 表示服务者身份99是临时服务者 明细页可以显示提现按钮
  309. wx.navigateTo({
  310. url: '/pages/servant/salary/detail/detail?month=' + month + '&total=' + total + '&type=' + type + '&servantType=' + '' + '&blance=' + this.data.homeInfo.salary
  311. });
  312. },
  313. goNucleicList() {
  314. // wx.navigateTo({
  315. // url: '/pages/servant/nucleic/list'
  316. // })
  317. wx.navigateTo({
  318. url: '/pages/servant/gohome/report',
  319. })
  320. },
  321. copyNum() {
  322. wx.setClipboardData({
  323. data: this.data.homeInfo.workerShareCode,
  324. success: function (res) {
  325. console.log(res);
  326. wx.showToast({
  327. title: '复制成功',
  328. icon: 'none',
  329. duration: 2000
  330. });
  331. }
  332. })
  333. },
  334. goLearnCenter() {
  335. wx.navigateTo({
  336. url: '/pages/upgrade/learnCenter/learnCenter',
  337. })
  338. },
  339. closeModal() {
  340. this.setData({
  341. modalShow: false
  342. });
  343. },
  344. /**
  345. * 生命周期函数--监听页面初次渲染完成
  346. */
  347. onReady: function () {
  348. },
  349. /**
  350. * 生命周期函数--监听页面显示
  351. */
  352. onShow: function () {
  353. let week = util.getWeek(this.data.currentDate);
  354. let userInfo = wx.getStorageSync('userInfo');
  355. this.setData({
  356. currentWeek: week,
  357. userInfo: userInfo
  358. });
  359. if (userInfo && userInfo.id < 0) {
  360. // 未入职状态
  361. this.setData({
  362. interviewShow: true
  363. });
  364. this.getInterview();
  365. this.getHomeInfo();
  366. return;
  367. }
  368. // setInterval(this.messageScroll,2000);
  369. this.getRebuyInfo();
  370. this.isNewYearReport();
  371. this.getHomeInfo();
  372. this.getMsgCenter();
  373. //是否测试环境
  374. // if(api.WxApiRoot.indexOf("uat")){
  375. // this.setData({
  376. // isUat:true
  377. // })
  378. // }
  379. this.setData({
  380. isUat: wx.getStorageSync('isUat')
  381. })
  382. },
  383. getMsgCenter() {
  384. let userInfo = wx.getStorageSync('userInfo');
  385. util.request(api.getMsgCenter, {
  386. workerNo: userInfo.workerNo,
  387. }, 'GET').then(res => {
  388. if (res.errno === 0) {
  389. this.setData({
  390. unReadSize: res.data.unReadSize > 99 ? 99 : res.data.unReadSize,
  391. workerNotice: res.data.workerNotice,
  392. workerNoticeAlert: res.data.workerNoticeAlert,
  393. modalShow: res.data.workerNoticeAlert.length > 0 ? true : false,
  394. alertNoticeInfo: res.data.workerNoticeAlert.length > 0 ? res.data.workerNoticeAlert[0] : {}
  395. });
  396. }
  397. });
  398. },
  399. goMaster(){
  400. // util.request(api.transferIntroductionQrCode, {
  401. // }, 'POST').then(res=> {
  402. // if (res.errno === 0) {
  403. // let url=res.data;
  404. // wx.previewImage({
  405. // current: url, // 当前显示图片的http链接
  406. // urls: [url] // 需要预览的图片http链接列表
  407. // })
  408. // }else{
  409. // wx.showToast({
  410. // title: res.errmsg,
  411. // icon:'none'
  412. // })
  413. // }
  414. // });
  415. // meetZzy 1有资格 0没资格
  416. // pauseZzy 1暂停 0没有暂停
  417. let meetZzy=this.data.homeInfo.workerInfo.meetZzy;
  418. let pauseZzy=this.data.homeInfo.workerInfo.pauseZzy;
  419. if(meetZzy==0){
  420. wx.navigateTo({
  421. url: '/pages/master/joinGain/joinGain',
  422. });
  423. }else if(meetZzy==1&&pauseZzy==1){
  424. // 已暂停
  425. wx.navigateTo({
  426. url: '/pages/master/pauseMaster/pauseMaster',
  427. })
  428. }else{
  429. wx.navigateTo({
  430. url: '/pages/master/shareMaster/shareMaster?rid='+this.data.userInfo.id,
  431. });
  432. }
  433. },
  434. goIm(){
  435. wx.navigateTo({
  436. url: '/pages/chat/im/im'
  437. });
  438. },
  439. onHide: function () {
  440. },
  441. onUnload: function () {
  442. },
  443. /**
  444. * 页面相关事件处理函数--监听用户下拉动作
  445. */
  446. onPullDownRefresh: function () {
  447. },
  448. /**
  449. * 页面上拉触底事件的处理函数
  450. */
  451. onReachBottom: function () {
  452. },
  453. /**
  454. * 用户点击右上角分享
  455. */
  456. onShareAppMessage: function () {
  457. },
  458. })