index.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. // pages/project/index.js
  2. import http from '../../utils/http'
  3. import util from '../../utils/util'
  4. import api from '../../utils/api'
  5. var app = getApp()
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. id: -1,
  12. userInfo: {},
  13. device_rent_menus: [{
  14. img: 'http://t18.9026.com/mini/create-order.png',
  15. title: '创建订单',
  16. desc: '创建外部设备租赁订单',
  17. url: '/pages/create-order/index'
  18. }, {
  19. img: 'http://t18.9026.com/mini/rent-check.png',
  20. title: '租赁审核',
  21. desc: '设备租赁订单审核',
  22. url: '/pages/order/index?type=check'
  23. }, {
  24. img: 'http://t18.9026.com/mini/error-handle.png',
  25. title: '异常处理',
  26. desc: '订单流程变更审核处理',
  27. url: '/pages/order/index?index=4'
  28. }, {
  29. img: 'http://t18.9026.com/mini/all-order.png',
  30. title: '所有订单',
  31. desc: '查看全部设备租赁订单',
  32. url: '/pages/order/index'
  33. }],
  34. device_use_menus: [{
  35. img: 'http://t18.9026.com/mini/use-apply.png',
  36. title: '调用申请',
  37. desc: '机电负责人调用设备',
  38. url: '/pages/create-order-inner/index'
  39. }, {
  40. img: 'http://t18.9026.com/mini/rent-check.png',
  41. title: '调用审核',
  42. desc: '设备调用订单审核',
  43. url: '/pages/order-inner/index?type=check'
  44. }, {
  45. img: 'http://t18.9026.com/mini/error-handle.png',
  46. title: '异常处理',
  47. desc: '订单流程变更审核处理',
  48. url: '/pages/order-inner/index?index=4'
  49. }, {
  50. img: 'http://t18.9026.com/mini/all-order.png',
  51. title: '所有订单',
  52. desc: '查看全部设备调用订单',
  53. url: '/pages/order-inner/index'
  54. }],
  55. device_depot_menus: [{
  56. img: 'http://t18.9026.com/mini/all-order.png',
  57. title: '所有设备',
  58. desc: '查看仓库所有设备',
  59. url: '/pages/device-inner/index'
  60. }, {
  61. img: 'http://t18.9026.com/mini/rent-check.png',
  62. title: '维修上报',
  63. desc: '设备维修上报',
  64. url: '/pages/repair/index'
  65. }],
  66. right: null
  67. },
  68. /**
  69. * 生命周期函数--监听页面加载
  70. */
  71. onLoad: function (options) {
  72. var id = options.id ? options.id : 1
  73. this.setData({
  74. id: id,
  75. userInfo: app.globalData.userInfo
  76. })
  77. api.getByName(this, 'getUserInfo', 'userInfo', {}, function(res) {
  78. app.updateUserInfo(res);
  79. });
  80. api.getByName(this, 'users/getRight', 'right', {id: id});
  81. wx.setStorageSync('sg-added-devices', [])
  82. },
  83. navigate: function(e) {
  84. var url = e.currentTarget.dataset.url
  85. var right = this.data.right
  86. var id = this.data.id
  87. if(url == '/pages/device-inner/index?id=' + this.data.id) {
  88. app.resetFilter();
  89. }
  90. if(url == '/pages/create-order/index?id=' + id && (!right || !right.createOut)) {
  91. util.error('没有权限')
  92. return false;
  93. }
  94. if(url == '/pages/create-order-inner/index?id=' + id && (!right || !right.createInner)) {
  95. util.error('没有权限')
  96. return false;
  97. }
  98. wx.navigateTo({
  99. url: url,
  100. })
  101. },
  102. getProject() {
  103. var that = this
  104. http({
  105. url: 'projects/detail',
  106. data: {
  107. id: this.data.id
  108. },
  109. success: function(res) {
  110. if(res.code == 0) {
  111. that.setData({
  112. project: res.data
  113. })
  114. wx.setNavigationBarTitle({
  115. title: res.data.name,
  116. })
  117. }
  118. }
  119. })
  120. },
  121. /**
  122. * 生命周期函数--监听页面初次渲染完成
  123. */
  124. onReady: function () {
  125. },
  126. /**
  127. * 生命周期函数--监听页面显示
  128. */
  129. onShow: function () {
  130. this.getProject()
  131. },
  132. /**
  133. * 生命周期函数--监听页面隐藏
  134. */
  135. onHide: function () {
  136. },
  137. /**
  138. * 生命周期函数--监听页面卸载
  139. */
  140. onUnload: function () {
  141. },
  142. /**
  143. * 页面相关事件处理函数--监听用户下拉动作
  144. */
  145. onPullDownRefresh: function () {
  146. },
  147. /**
  148. * 页面上拉触底事件的处理函数
  149. */
  150. onReachBottom: function () {
  151. },
  152. /**
  153. * 用户点击右上角分享
  154. */
  155. onShareAppMessage: function () {
  156. }
  157. })