my.js 12 KB

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