util.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. var utils=require("./http");
  2. const app=getApp();
  3. module.exports = {
  4. goTop:goTop,
  5. schemefun:schemefun,
  6. toolfun:toolfun,
  7. dayDiff:dayDiff,
  8. nowdayDiff:nowdayDiff
  9. }
  10. function schemefun(path,query,id,type,version){
  11. let that=this;
  12. utils.$post({
  13. url: app.globalData.webUrl + 'api/share/urlscheme',
  14. header: {
  15. 'Authorization':'bearer '+app.globalData.token
  16. },
  17. data:{
  18. query:query,
  19. path:path,
  20. env_version:version,
  21. id:id,
  22. type:type,
  23. user_id:app.globalData.personMsg.id
  24. },
  25. success: function (res) {
  26. if(res.data.code=='0'){
  27. wx.setClipboardData({
  28. data: res.data.data,
  29. success (res) {
  30. }
  31. })
  32. }
  33. },
  34. complete(res) {
  35. wx.hideLoading()
  36. }
  37. })
  38. }
  39. function toolfun(type){
  40. utils.$post({
  41. url: app.globalData.webUrl + 'client/index/toolAll',
  42. header: {
  43. 'Authorization': 'bearer ' + app.globalData.token
  44. },
  45. data: {
  46. type: type
  47. },
  48. success: function (res) {
  49. if (res.data.code == 0) {
  50. }
  51. }
  52. })
  53. }
  54. function goTop() { 
  55. if (wx.pageScrollTo) {
  56.   wx.pageScrollTo({
  57.     scrollTop: 0,
  58. duration:50
  59.   })
  60. }
  61. }
  62. function nowdayDiff(date1) {
  63. let date=new Date();
  64. let str=date.getFullYear()+'/'+(date.getMonth()*1+1)+'/'+date.getDate();
  65. let num = Math.ceil((new Date(str).getTime() - new Date(date1).getTime()) / 86400000);
  66. return num;
  67. }
  68. function dayDiff(date1, date2) {
  69. let num = Math.ceil((date1.getTime() - date2.getTime()) / 86400000);
  70. return num;
  71. }