index.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. //index.js
  2. //获取应用实例
  3. const app = getApp()
  4. let listData = [];
  5. Page({
  6. data: {
  7. list: [],
  8. selectId: 0,
  9. type: ''
  10. },
  11. onLoad: function (options) {
  12. var that = this;
  13. if(options.hasOwnProperty('type')){
  14. that.setData({
  15. type:options.type
  16. })
  17. }
  18. wx.getStorage({ //获取页面传递过来的数据
  19. key: 'gotopage',
  20. success(res) {
  21. wx.setNavigationBarTitle({
  22. title: res.data.title
  23. });
  24. that.setData({
  25. type: res.data.type
  26. });
  27. console.log(res.data)
  28. var pages = getCurrentPages();
  29. var prevPage = pages[pages.length - 2]; //上一个页面
  30. if(res.data.type=='dep'){
  31. var id = prevPage.data.depId;
  32. }else if(res.data.type=='conveyType'){
  33. var id = prevPage.data.conveyTypeId;
  34. }else if(res.data.type=='conveyAddrStart'){
  35. var id = prevPage.data.conveyStart;
  36. }else if(res.data.type=='conveyAddrEnd'){
  37. var id = prevPage.data.conveyEnd;
  38. }else if(res.data.type=='conveyDevice'){
  39. var id = prevPage.data.conveyDevice;
  40. }else if(res.data.type=='priority'){
  41. var id = prevPage.data.priority;
  42. }else if(res.data.type=='repairPriority'){
  43. var id = prevPage.data.repairPriority;
  44. }
  45. that.setData({
  46. selectId: id
  47. });
  48. },
  49. fail(res) {
  50. wx.navigateBack({ delta: 1 });
  51. return false;
  52. }
  53. });
  54. },
  55. onShow:function(){
  56. var that = this;
  57. console.log(that.data.type)
  58. app.ajaxReadyCallback = res => {
  59. that.setData({
  60. list: res.data.data
  61. });
  62. listData = res.data.data;
  63. }
  64. this.showData();
  65. },
  66. showData: function () {
  67. var org = app.globalData.userinfo.org;
  68. console.log(this.data.type)
  69. if(this.data.type=='dep'){
  70. app.ajax({
  71. url: app.globalData.serverUrl + 'orders/getDep',
  72. type: 'POST',
  73. data: {
  74. }
  75. });
  76. }else if(this.data.type=='conveyType'){
  77. app.ajax({
  78. url: app.globalData.serverUrl + 'OrderConveyType/getCate',
  79. type: 'POST',
  80. data: {
  81. }
  82. });
  83. }else if(this.data.type=='conveyAddrStart'){
  84. app.ajax({
  85. url: app.globalData.serverUrl + 'OrderConveyType/getAddress',
  86. type: 'POST',
  87. data: {
  88. }
  89. });
  90. }else if(this.data.type=='conveyAddrEnd'){
  91. app.ajax({
  92. url: app.globalData.serverUrl + 'OrderConveyType/getAddress',
  93. type: 'POST',
  94. data: {
  95. }
  96. });
  97. }else if(this.data.type=='conveyDevice'){
  98. app.ajax({
  99. url: app.globalData.serverUrl + 'OrderConveyType/getDevice',
  100. type: 'POST',
  101. data: {
  102. }
  103. });
  104. }else if(this.data.type=='priority'){
  105. app.ajax({
  106. url: app.globalData.serverUrl + 'OrderConveyType/priority',
  107. type: 'POST',
  108. data: {
  109. }
  110. });
  111. }else if(this.data.type=='repairPriority'){
  112. app.ajax({
  113. url: app.globalData.serverUrl + 'Orders/repair_priority',
  114. type: 'POST',
  115. data: {
  116. }
  117. });
  118. }
  119. },
  120. selectBtn: function(e){
  121. var that = this;
  122. var id = e.currentTarget.dataset.id;
  123. var title = e.currentTarget.dataset.title;
  124. var cate = e.currentTarget.dataset.cate;
  125. var info = e.currentTarget.dataset.info;
  126. this.setData({
  127. selectId: id
  128. });
  129. var pages = getCurrentPages();
  130. var prevPage = pages[pages.length - 2]; //上一个页面
  131. wx.navigateBack({
  132. delta: 1,
  133. success: function (res) {
  134. if(that.data.type=='dep'){
  135. prevPage.setData({
  136. depId: id,
  137. depName: title
  138. });
  139. }else if(that.data.type=='conveyType'){
  140. prevPage.setData({
  141. conveyTypeId: id,
  142. conveyTypeName: title,
  143. conveyTypeCate: cate,
  144. priority: info.priority,
  145. priorityName: info.priorityName,
  146. xqTime: info.xqTime,
  147. ywcTime: info.ywcTime,
  148. });
  149. if(info.ends!=null){
  150. prevPage.setData({
  151. conveyEnd: info.ends[0].id,
  152. conveyEndName: info.ends[0].title,
  153. });
  154. }
  155. }else if(that.data.type=='conveyAddrStart'){
  156. prevPage.setData({
  157. conveyStart: id,
  158. conveyStartName: title
  159. });
  160. }else if(that.data.type=='conveyAddrEnd'){
  161. prevPage.setData({
  162. conveyEnd: id,
  163. conveyEndName: title
  164. });
  165. }else if(that.data.type=='conveyDevice'){
  166. prevPage.setData({
  167. conveyDevice: id,
  168. conveyDeviceName: title
  169. });
  170. }else if(that.data.type=='priority'){
  171. prevPage.setData({
  172. priority: id,
  173. priorityName: title
  174. });
  175. }else if(that.data.type=='repairPriority'){
  176. prevPage.setData({
  177. repairPriority: id,
  178. repairPriorityName: title
  179. });
  180. }
  181. }
  182. })
  183. },
  184. showInput: function () {
  185. this.setData({
  186. inputShowed: true
  187. });
  188. },
  189. hideInput: function () {
  190. this.setData({
  191. inputVal: "",
  192. inputShowed: false,
  193. list: listData
  194. });
  195. },
  196. clearInput: function () {
  197. this.setData({
  198. inputVal: "",
  199. list: listData
  200. });
  201. },
  202. inputTyping: function (e) {
  203. //搜索数据
  204. this.setData({
  205. inputVal: e.detail.value
  206. });
  207. if (e.detail.value == '') {
  208. this.setData({
  209. list: listData
  210. });
  211. return '';
  212. }
  213. let arr = [];
  214. for(var i in listData) {
  215. if (listData[i].title.indexOf( e.detail.value) > -1) {
  216. arr.push(listData[i]);
  217. }
  218. }
  219. this.setData({
  220. list: arr
  221. })
  222. }
  223. })