123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- //index.js
- //获取应用实例
- const app = getApp()
- let listData = [];
- Page({
- data: {
- list: [],
- selectId: 0,
- type: ''
- },
- onLoad: function (options) {
- var that = this;
- if(options.hasOwnProperty('type')){
- that.setData({
- type:options.type
- })
- }
- wx.getStorage({ //获取页面传递过来的数据
- key: 'gotopage',
- success(res) {
- wx.setNavigationBarTitle({
- title: res.data.title
- });
- that.setData({
- type: res.data.type
- });
- console.log(res.data)
- var pages = getCurrentPages();
- var prevPage = pages[pages.length - 2]; //上一个页面
- if(res.data.type=='dep'){
- var id = prevPage.data.depId;
- }else if(res.data.type=='conveyType'){
- var id = prevPage.data.conveyTypeId;
- }else if(res.data.type=='conveyAddrStart'){
- var id = prevPage.data.conveyStart;
- }else if(res.data.type=='conveyAddrEnd'){
- var id = prevPage.data.conveyEnd;
- }else if(res.data.type=='conveyDevice'){
- var id = prevPage.data.conveyDevice;
- }else if(res.data.type=='priority'){
- var id = prevPage.data.priority;
- }else if(res.data.type=='repairPriority'){
- var id = prevPage.data.repairPriority;
- }
- that.setData({
- selectId: id
- });
- },
- fail(res) {
- wx.navigateBack({ delta: 1 });
- return false;
- }
- });
- },
-
- onShow:function(){
- var that = this;
- console.log(that.data.type)
- app.ajaxReadyCallback = res => {
- that.setData({
- list: res.data.data
- });
- listData = res.data.data;
- }
- this.showData();
- },
- showData: function () {
- var org = app.globalData.userinfo.org;
- console.log(this.data.type)
- if(this.data.type=='dep'){
- app.ajax({
- url: app.globalData.serverUrl + 'orders/getDep',
- type: 'POST',
- data: {
- }
- });
- }else if(this.data.type=='conveyType'){
- app.ajax({
- url: app.globalData.serverUrl + 'OrderConveyType/getCate',
- type: 'POST',
- data: {
- }
- });
- }else if(this.data.type=='conveyAddrStart'){
- app.ajax({
- url: app.globalData.serverUrl + 'OrderConveyType/getAddress',
- type: 'POST',
- data: {
- }
- });
- }else if(this.data.type=='conveyAddrEnd'){
- app.ajax({
- url: app.globalData.serverUrl + 'OrderConveyType/getAddress',
- type: 'POST',
- data: {
- }
- });
- }else if(this.data.type=='conveyDevice'){
- app.ajax({
- url: app.globalData.serverUrl + 'OrderConveyType/getDevice',
- type: 'POST',
- data: {
- }
- });
- }else if(this.data.type=='priority'){
- app.ajax({
- url: app.globalData.serverUrl + 'OrderConveyType/priority',
- type: 'POST',
- data: {
- }
- });
- }else if(this.data.type=='repairPriority'){
- app.ajax({
- url: app.globalData.serverUrl + 'Orders/repair_priority',
- type: 'POST',
- data: {
- }
- });
- }
- },
- selectBtn: function(e){
- var that = this;
- var id = e.currentTarget.dataset.id;
- var title = e.currentTarget.dataset.title;
- var cate = e.currentTarget.dataset.cate;
- var info = e.currentTarget.dataset.info;
- this.setData({
- selectId: id
- });
- var pages = getCurrentPages();
- var prevPage = pages[pages.length - 2]; //上一个页面
- wx.navigateBack({
- delta: 1,
- success: function (res) {
- if(that.data.type=='dep'){
- prevPage.setData({
- depId: id,
- depName: title
- });
- }else if(that.data.type=='conveyType'){
- prevPage.setData({
- conveyTypeId: id,
- conveyTypeName: title,
- conveyTypeCate: cate,
- priority: info.priority,
- priorityName: info.priorityName,
- xqTime: info.xqTime,
- ywcTime: info.ywcTime,
- });
- if(info.ends!=null){
- prevPage.setData({
- conveyEnd: info.ends[0].id,
- conveyEndName: info.ends[0].title,
- });
- }
- }else if(that.data.type=='conveyAddrStart'){
- prevPage.setData({
- conveyStart: id,
- conveyStartName: title
- });
- }else if(that.data.type=='conveyAddrEnd'){
- prevPage.setData({
- conveyEnd: id,
- conveyEndName: title
- });
- }else if(that.data.type=='conveyDevice'){
- prevPage.setData({
- conveyDevice: id,
- conveyDeviceName: title
- });
- }else if(that.data.type=='priority'){
- prevPage.setData({
- priority: id,
- priorityName: title
- });
- }else if(that.data.type=='repairPriority'){
- prevPage.setData({
- repairPriority: id,
- repairPriorityName: title
- });
- }
- }
- })
- },
- showInput: function () {
- this.setData({
- inputShowed: true
- });
- },
- hideInput: function () {
- this.setData({
- inputVal: "",
- inputShowed: false,
- list: listData
- });
- },
- clearInput: function () {
- this.setData({
- inputVal: "",
- list: listData
- });
- },
- inputTyping: function (e) {
- //搜索数据
- this.setData({
- inputVal: e.detail.value
- });
- if (e.detail.value == '') {
- this.setData({
- list: listData
- });
- return '';
- }
- let arr = [];
- for(var i in listData) {
- if (listData[i].title.indexOf( e.detail.value) > -1) {
- arr.push(listData[i]);
- }
- }
- this.setData({
- list: arr
- })
- }
-
- })
|