my.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  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. },
  289. goMessage() {
  290. wx.navigateTo({
  291. url: '/pages/upgrade/messageList/messageList'
  292. })
  293. },
  294. goSalaryDetail(e) { //查询工资明细
  295. // const {
  296. // year,
  297. // month
  298. // } = calendar.getCurrentYM();
  299. // let m = '11';
  300. // if (m < 10) m = '0' + String(m);
  301. // let year='2022-';
  302. let month = moment(new Date()).format('YYYY-MM');
  303. let type = e.currentTarget.dataset.type;
  304. let total = (type == 1 ? this.data.homeInfo.salary : this.data.homeInfo.total);
  305. //servantType 表示服务者身份99是临时服务者 明细页可以显示提现按钮
  306. wx.navigateTo({
  307. url: '/pages/servant/salary/detail/detail?month=' + month + '&total=' + total + '&type=' + type + '&servantType=' + '' + '&blance=' + this.data.homeInfo.salary
  308. });
  309. },
  310. goNucleicList() {
  311. wx.navigateTo({
  312. url: '/pages/servant/nucleic/list'
  313. })
  314. },
  315. copyNum() {
  316. wx.setClipboardData({
  317. data: this.data.homeInfo.workerShareCode,
  318. success: function (res) {
  319. console.log(res);
  320. wx.showToast({
  321. title: '复制成功',
  322. icon: 'none',
  323. duration: 2000
  324. });
  325. }
  326. })
  327. },
  328. goLearnCenter() {
  329. wx.navigateTo({
  330. url: '/pages/upgrade/learnCenter/learnCenter',
  331. })
  332. },
  333. closeModal() {
  334. this.setData({
  335. modalShow: false
  336. });
  337. },
  338. /**
  339. * 生命周期函数--监听页面初次渲染完成
  340. */
  341. onReady: function () {
  342. },
  343. /**
  344. * 生命周期函数--监听页面显示
  345. */
  346. onShow: function () {
  347. let week = util.getWeek(this.data.currentDate);
  348. let userInfo = wx.getStorageSync('userInfo');
  349. this.setData({
  350. currentWeek: week,
  351. userInfo: userInfo
  352. });
  353. if (userInfo && userInfo.id < 0) {
  354. // 未入职状态
  355. this.setData({
  356. interviewShow: true
  357. });
  358. this.getInterview();
  359. this.getHomeInfo();
  360. return;
  361. }
  362. // setInterval(this.messageScroll,2000);
  363. this.getRebuyInfo();
  364. this.isNewYearReport();
  365. this.getHomeInfo();
  366. this.getMsgCenter();
  367. //是否测试环境
  368. // if(api.WxApiRoot.indexOf("uat")){
  369. // this.setData({
  370. // isUat:true
  371. // })
  372. // }
  373. this.setData({
  374. isUat: wx.getStorageSync('isUat')
  375. })
  376. },
  377. getMsgCenter() {
  378. let userInfo = wx.getStorageSync('userInfo');
  379. util.request(api.getMsgCenter, {
  380. workerNo: userInfo.workerNo,
  381. }, 'GET').then(res => {
  382. if (res.errno === 0) {
  383. this.setData({
  384. unReadSize: res.data.unReadSize > 99 ? 99 : res.data.unReadSize,
  385. workerNotice: res.data.workerNotice,
  386. workerNoticeAlert: res.data.workerNoticeAlert,
  387. modalShow: res.data.workerNoticeAlert.length > 0 ? true : false,
  388. alertNoticeInfo: res.data.workerNoticeAlert.length > 0 ? res.data.workerNoticeAlert[0] : {}
  389. });
  390. }
  391. });
  392. },
  393. goMaster(){
  394. // util.request(api.transferIntroductionQrCode, {
  395. // }, 'POST').then(res=> {
  396. // if (res.errno === 0) {
  397. // let url=res.data;
  398. // wx.previewImage({
  399. // current: url, // 当前显示图片的http链接
  400. // urls: [url] // 需要预览的图片http链接列表
  401. // })
  402. // }else{
  403. // wx.showToast({
  404. // title: res.errmsg,
  405. // icon:'none'
  406. // })
  407. // }
  408. // });
  409. // meetZzy 1有资格 0没资格
  410. // pauseZzy 1暂停 0没有暂停
  411. let meetZzy=this.data.homeInfo.workerInfo.meetZzy;
  412. let pauseZzy=this.data.homeInfo.workerInfo.pauseZzy;
  413. if(meetZzy==0){
  414. wx.navigateTo({
  415. url: '/pages/master/joinGain/joinGain',
  416. });
  417. }else if(meetZzy==1&&pauseZzy==1){
  418. // 已暂停
  419. wx.navigateTo({
  420. url: '/pages/master/pauseMaster/pauseMaster',
  421. })
  422. }else{
  423. wx.navigateTo({
  424. url: '/pages/master/shareMaster/shareMaster?rid='+this.data.userInfo.id,
  425. });
  426. }
  427. },
  428. onHide: function () {
  429. },
  430. onUnload: function () {
  431. },
  432. /**
  433. * 页面相关事件处理函数--监听用户下拉动作
  434. */
  435. onPullDownRefresh: function () {
  436. },
  437. /**
  438. * 页面上拉触底事件的处理函数
  439. */
  440. onReachBottom: function () {
  441. },
  442. /**
  443. * 用户点击右上角分享
  444. */
  445. onShareAppMessage: function () {
  446. },
  447. })