my.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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. labelName:[],
  10. homeInfo:{
  11. onPositionYear:'',
  12. salary:'',
  13. total:'',
  14. unReadSize:"",
  15. workerInfo:{},
  16. workerNotice:[],
  17. stationAdminName:'',
  18. stationAdminTel:''
  19. },
  20. salary:{
  21. salary:'',
  22. total:''
  23. },
  24. hasLogin:true,
  25. currentDate:moment(new Date()).format('YYYY-MM-DD'),
  26. currentWeek:'',
  27. myRebuyInfo:{
  28. looseOrderRebuy:0,
  29. looseOrder:0,
  30. cycleOrderRebuy:0,
  31. cycleOrder:0,
  32. looseOrderRebuyRate:0,
  33. cycleOrderRebuyRate:0
  34. },
  35. animate:false,
  36. msgList:[
  37. {
  38. text:'工单1:产生【差评】工单,请及时关注!'
  39. },
  40. {
  41. text:'工单2:产生【差评】工单,请及时关注!'
  42. },
  43. {
  44. text:'工单3:产生【差评】工单,请及时关注!'
  45. }
  46. ]
  47. },
  48. /**
  49. * 生命周期函数--监听页面加载
  50. */
  51. onLoad: function (options) {
  52. // setInterval(this.messageScroll,2000);
  53. // let week=util.getWeek(this.data.currentDate);
  54. // this.setData({
  55. // currentWeek:week
  56. // });
  57. // this.getRebuyInfo();
  58. // this.isNewYearReport();
  59. // this.getHomeInfo()
  60. },
  61. isNewYearReport() { //是否新年报备
  62. util.request(api.NewYearReported).then(res => {
  63. if (res.data) {
  64. wx.showModal({
  65. title: '返乡调查',
  66. content: '新年返乡调查已开始,是否现在去报备?',
  67. success: function (sm) {
  68. if (sm.confirm) {
  69. wx.navigateTo({
  70. url: '/pages/servant/gohome/report',
  71. })
  72. }
  73. }
  74. });
  75. }
  76. })
  77. },
  78. lastWeek(){
  79. let current=moment(new Date((new Date(this.data.currentDate)).getTime()-7*24*60*60*1000)).format('YYYY-MM-DD');
  80. console.log(current);
  81. let week=util.getWeek(current);
  82. this.setData({
  83. currentDate:current,
  84. currentWeek:week
  85. });
  86. this.getRebuyInfo();
  87. },
  88. nextWeek(){
  89. let current=moment(new Date((new Date(this.data.currentDate)).getTime()+7*24*60*60*1000)).format('YYYY-MM-DD');
  90. console.log(current);
  91. let week=util.getWeek(current);
  92. this.setData({
  93. currentDate:current,
  94. currentWeek:week
  95. });
  96. this.getRebuyInfo();
  97. },
  98. getRebuyInfo(){
  99. util.request(api.myRebuyInfo, {
  100. date: this.data.currentDate,
  101. }, 'GET').then(res=> {
  102. if (res.errno === 0) {
  103. this.setData({
  104. myRebuyInfo:res.data
  105. });
  106. }
  107. });
  108. },
  109. messageScroll(){
  110. this.setData({
  111. animate:true
  112. });
  113. setTimeout(()=>{
  114. let list=this.data.msgList;
  115. list.push(list[0]);
  116. this.setData({
  117. msgList:list
  118. });
  119. list.shift();
  120. this.setData({
  121. msgList:list,
  122. animate:false
  123. });
  124. },3000);
  125. },
  126. makeCall(e){
  127. let mobile = e.currentTarget.dataset.mobile;
  128. wx.makePhoneCall({
  129. phoneNumber: mobile,
  130. })
  131. },
  132. exitLogin: function () {
  133. wx.showModal({
  134. title: '',
  135. confirmColor: '#b4282d',
  136. content: '退出登录?',
  137. success: function (res) {
  138. if (!res.confirm) {
  139. return;
  140. }
  141. util.request(api.AuthLogout, {}, 'POST');
  142. app.globalData.hasLogin = false;
  143. wx.removeStorageSync('token');
  144. wx.removeStorageSync('userInfo');
  145. wx.navigateTo({
  146. url: '/pages/index/index'
  147. });
  148. }
  149. })
  150. },
  151. getHomeInfo(){
  152. util.request(api.homeInfo, {}, 'GET').then(res=> {
  153. console.log(res);
  154. if (res.errno === 0) {
  155. console.log(res.data.workerInfo.labelNames);
  156. console.log(res.data.workerInfo.labelNames.split(','));
  157. this.setData({
  158. homeInfo:res.data,
  159. labelName:res.data.workerInfo.labelNames==""?[]:res.data.workerInfo.labelNames.split(','),
  160. 'homeInfo.unReadSize':res.data.unReadSize>99?99:res.data.unReadSize
  161. });
  162. }
  163. });
  164. },
  165. goLeave(){//请假
  166. wx.navigateTo({
  167. url: '/pages/servant/leave/leave',
  168. });
  169. // wx.showModal({
  170. // title: '提醒',
  171. // content: '暂未开通,敬请期待',
  172. // showCancel: false
  173. // });
  174. },
  175. goHouse(){
  176. wx.showModal({
  177. title: '提醒',
  178. content: '暂未开通,敬请期待',
  179. showCancel: false
  180. })
  181. },
  182. getPerfect(){
  183. wx.navigateTo({
  184. url: '/pages/servant/perfect/perfectWorkerInfo'
  185. })
  186. },
  187. goBookIndex(e) {
  188. if (this.data.hasLogin) {
  189. let tab = e.currentTarget.dataset.index
  190. let route = e.currentTarget.dataset.route
  191. try {
  192. wx.setStorageSync('tab', tab);
  193. } catch (e) {
  194. }
  195. wx.navigateTo({
  196. url: route,
  197. })
  198. } else {
  199. wx.navigateTo({
  200. url: "/pages/index/index"
  201. });
  202. };
  203. },
  204. goNucleicList() {
  205. wx.navigateTo({
  206. url: '/pages/servant/nucleic/list'
  207. });
  208. },
  209. goMessage(){
  210. wx.navigateTo({
  211. url: '/pages/upgrade/messageList/messageList'
  212. })
  213. },
  214. goSalaryDetail(e) { //查询工资明细
  215. // const {
  216. // year,
  217. // month
  218. // } = calendar.getCurrentYM();
  219. // let m = '11';
  220. // if (m < 10) m = '0' + String(m);
  221. // let year='2022-';
  222. let month=moment(new Date()).format('YYYY-MM');
  223. let type = e.currentTarget.dataset.type;
  224. let total = (type == 1 ? this.data.homeInfo.salary : this.data.homeInfo.total);
  225. //servantType 表示服务者身份99是临时服务者 明细页可以显示提现按钮
  226. wx.navigateTo({
  227. url: '/pages/servant/salary/detail/detail?month=' + month + '&total=' + total + '&type=' + type+'&servantType='+''+'&blance='+this.data.homeInfo.salary
  228. });
  229. },
  230. goNucleicList() {
  231. wx.navigateTo({
  232. url: '/pages/servant/nucleic/list'
  233. })
  234. },
  235. copyNum(){
  236. wx.setClipboardData({
  237. data: this.data.homeInfo.workerShareCode,
  238. success: function (res) {
  239. console.log(res);
  240. wx.showToast({
  241. title: '复制成功',
  242. icon: 'none',
  243. duration: 2000
  244. });
  245. }
  246. })
  247. },
  248. /**
  249. * 生命周期函数--监听页面初次渲染完成
  250. */
  251. onReady: function () {
  252. },
  253. /**
  254. * 生命周期函数--监听页面显示
  255. */
  256. onShow: function () {
  257. // setInterval(this.messageScroll,2000);
  258. let week=util.getWeek(this.data.currentDate);
  259. this.setData({
  260. currentWeek:week
  261. });
  262. this.getRebuyInfo();
  263. this.isNewYearReport();
  264. this.getHomeInfo()
  265. },
  266. onHide: function () {
  267. },
  268. onUnload: function () {
  269. },
  270. /**
  271. * 页面相关事件处理函数--监听用户下拉动作
  272. */
  273. onPullDownRefresh: function () {
  274. },
  275. /**
  276. * 页面上拉触底事件的处理函数
  277. */
  278. onReachBottom: function () {
  279. },
  280. /**
  281. * 用户点击右上角分享
  282. */
  283. onShareAppMessage: function () {
  284. },
  285. })