index.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940
  1. // pages/repair/repair.js
  2. const app = getApp();
  3. var orgId = 0;
  4. var depId = 0;
  5. var mode = 0;
  6. var filescount = 0;
  7. var files = [];
  8. var uploadFlag = 0; //1=上传出错 0=正常
  9. var filesindex = 0;
  10. var phone = '';
  11. var ysconfig = 0;
  12. //创建录音管理
  13. const recorderManager = wx.getRecorderManager();
  14. //创建播放管理器
  15. const innerAudioContext = wx.createInnerAudioContext();
  16. innerAudioContext.autoplay = false;
  17. Page({
  18. /**
  19. * 页面的初始数据
  20. */
  21. data: {
  22. taskContent: {
  23. title: '任务内容',
  24. showImg: '/images/icons/recording.png',
  25. playImg: '/images/icons/play.png',
  26. blImg: '/images/icons/bl.png',
  27. readingImg: '/images/icons/recording.png',
  28. luyinzhongImg: '/images/icons/luyinzhong.png',
  29. stopPlayImg: '/images/icons/zanting.png',
  30. delimg: '/images/icons/newdel.png',
  31. taskRadioType: '1',
  32. radioUrl: '',
  33. second: 10,
  34. // mode: 0
  35. },
  36. // repairType: {
  37. // title: '报修类型'
  38. // },
  39. conveyType: {
  40. list: {},
  41. title: '运送类型',
  42. text: ''
  43. },
  44. conveyTime: {
  45. hour: 0,
  46. min: 0,
  47. title: '运送时间',
  48. text: '立即'
  49. },
  50. conveyAddr: {
  51. title: '运送路线',
  52. startAddr: '',
  53. startId: 0,
  54. finishAddr: '',
  55. finishId: 0
  56. },
  57. image: {
  58. title: '图片'
  59. },
  60. video: {
  61. title: '视频'
  62. },
  63. repairTypeImage: '/images/icons/toRight.png',
  64. imagesAdd: '/images/icons/camera.png',
  65. form:{
  66. images: [],
  67. videos: [],
  68. voices: []
  69. },
  70. images:[],
  71. videos:[],
  72. voices:'',
  73. content:'',
  74. mode: 3,
  75. hide: 0,
  76. conveyTimePicker:{
  77. multiArray:[],
  78. objectMultiArray:[],
  79. multiIndex: [0, 0]
  80. },
  81. deptcontent: '',
  82. showFileSheet: false,
  83. choosefinish: false,
  84. choosefinishline: false,
  85. label:'',
  86. selectLabel:[],
  87. depId:0,
  88. depName:"",
  89. wyPhone:"",
  90. conveyTypeId: 0,
  91. conveyTypeName: '',
  92. conveyStart: 0,
  93. conveyStartName: '',
  94. conveyEnd: 0,
  95. conveyEndName: '',
  96. conveyDevice: 0,
  97. conveyDeviceName: '',
  98. conveyTypeCate:0,
  99. priority:0,
  100. priorityName:'',
  101. is_back:0,
  102. name:"",
  103. phone:"",
  104. ch:"",
  105. bName:"",
  106. bah:"",
  107. gender:1,
  108. xqTime:"",
  109. ywcTime:"",
  110. sex:[{
  111. name:'男',value:1,checked:"true"
  112. },{
  113. name:'女',value:2
  114. }]
  115. },
  116. radioChange: function (e) {
  117. this.setData({
  118. gender:e.detail.value
  119. })
  120. },
  121. wyConfig(){
  122. app.ajax({
  123. url: app.globalData.serverUrl + '/org/queryConfig',
  124. type: 'POST',
  125. apiname: 'wyConfig',
  126. data: {
  127. }
  128. });
  129. },
  130. name(e){
  131. this.setData({
  132. name:e.detail.value
  133. })
  134. },
  135. phone(e){
  136. this.setData({
  137. phone:e.detail.value
  138. })
  139. },
  140. ch(e){
  141. this.setData({
  142. ch:e.detail.value
  143. })
  144. },
  145. bName(e){
  146. this.setData({
  147. bName:e.detail.value
  148. })
  149. },
  150. bah(e){
  151. this.setData({
  152. bah:e.detail.value
  153. })
  154. },
  155. gotopage: function(e){
  156. var url = e.currentTarget.dataset.url;
  157. var type = e.currentTarget.dataset.type;
  158. var title = e.currentTarget.dataset.title;
  159. app.gotopage(url, { title: title, type: type });
  160. },
  161. onLoad: function(){
  162. var that = this;
  163. //初始化时间选中器
  164. var hours = [];
  165. var hourdatas = [];
  166. for(let i = 0;i <= 12; i++){
  167. let title,val;
  168. if(i == 0){
  169. title = '立即';
  170. }else{
  171. title = i + '小时';
  172. }
  173. hours.push(title);
  174. hourdatas.push({title:title,val:i});
  175. }
  176. var mins = [];
  177. var mindatas = [];
  178. for (let i = 0; i < 60; i++) {
  179. let title, val;
  180. if (i == 0) {
  181. title = '立即';
  182. } else {
  183. title = i + '分钟';
  184. }
  185. mins.push(title);
  186. mindatas.push({ title: title, val: i });
  187. }
  188. var conveyTimePicker = {
  189. multiArray: [hours, mins],
  190. objectMultiArray: [hourdatas, mindatas],
  191. multiIndex: [0, 0]
  192. }
  193. this.setData({
  194. conveyTimePicker: conveyTimePicker
  195. });
  196. recorderManager.onStart(() => {
  197. var taskContent = that.data.taskContent;
  198. taskContent.showImg = taskContent.luyinzhongImg;
  199. taskContent.taskRadioType = '2';
  200. that.setData({
  201. taskContent: taskContent
  202. })
  203. })
  204. recorderManager.onPause(() => {
  205. })
  206. recorderManager.onStop((res) => {
  207. var path = res.tempFilePath;
  208. var task = that.data.taskContent;
  209. task.taskRadioType = '3';
  210. task.showImg = task.playImg;
  211. task.second = Math.ceil(res.duration / 1000);
  212. that.setData({
  213. voices: path,
  214. taskContent: task
  215. });
  216. // const { tempFilePath } = res
  217. })
  218. recorderManager.onError((res) => {
  219. wx.showToast({
  220. title: '录音失败',
  221. icon: 'none',
  222. duration: 2000
  223. });
  224. var task = that.data.taskContent;
  225. task.taskRadioType = '1';
  226. task.showImg = task.readingImg;
  227. that.setData({
  228. voices: '',
  229. taskContent: task
  230. });
  231. });
  232. this.getUserInfo();
  233. },
  234. checkboxChange: function(e){
  235. var data = e.detail.value;
  236. if(data.length >0){
  237. this.setData({
  238. is_back:1
  239. })
  240. }else {
  241. this.setData({
  242. is_back:0
  243. })
  244. }
  245. },
  246. callPhone(){
  247. var that = this;
  248. if(!that.data.wyPhone){
  249. wx.showToast({
  250. title: '未设置物业电话',
  251. icon: 'none',
  252. duration: 2000
  253. });
  254. return false;
  255. }
  256. wx.makePhoneCall({
  257. phoneNumber: that.data.wyPhone,
  258. })
  259. },
  260. onShow: function(){
  261. var that = this;
  262. app.ajaxReadyCallback = res => {
  263. var apiname = res.data.apiname;
  264. if (apiname == 'ysconfig'){
  265. let ysll = res.data.data;
  266. if(ysll.length > 0){
  267. ysconfig = parseInt(ysll[0].value)
  268. }
  269. }else if(apiname == 'wyConfig'){
  270. that.setData({
  271. wyPhone:res.data.data.orgPhone
  272. })
  273. ysconfig = res.data.data.orgScanQrcode;
  274. } else if(apiname == 'orderAdd'){
  275. wx.showToast({
  276. title: '提交成功',
  277. icon: 'success',
  278. duration: 1500
  279. });
  280. setTimeout(function () {
  281. wx.navigateBack({ delta: 1 });
  282. }, 1500);
  283. }else if(apiname == 'userInfo') {
  284. that.setData({
  285. depId:res.data.data.depId,
  286. depName:res.data.data.depName,
  287. })
  288. }else {
  289. // wx.showToast({
  290. // title: '提交成功',
  291. // icon: 'success',
  292. // duration: 1500
  293. // });
  294. // setTimeout(function () {
  295. // wx.navigateBack({ delta: 1 });
  296. // }, 1500);
  297. }
  298. };
  299. this.wyConfig();
  300. },
  301. onTouchstartRadio: function(event) {
  302. var radioType = this.data.taskContent.taskRadioType;
  303. if (radioType == 1) {
  304. //开始录音
  305. var options = {
  306. duration: 15000,
  307. sampleRate: 44100,
  308. numberOfChannels: 1,
  309. encodeBitRate: 192000,
  310. format: 'mp3',
  311. frameSize: 50
  312. }
  313. recorderManager.start(options);
  314. }
  315. },
  316. onTouchendRadio: function(event) {
  317. var radioType = this.data.taskContent.taskRadioType;
  318. var that = this;
  319. if (radioType == 2) {
  320. recorderManager.stop();
  321. }
  322. },
  323. //播放录音
  324. playRadio: function(event) {
  325. var taskContent = this.data.taskContent;
  326. var radioType = taskContent.taskRadioType;
  327. if (radioType == 3) {
  328. var radioUrl = this.data.voices;
  329. innerAudioContext.src = radioUrl;
  330. innerAudioContext.play();
  331. innerAudioContext.onPlay(() => {
  332. taskContent.taskRadioType = 4;
  333. taskContent.showImg = taskContent.stopPlayImg;
  334. this.setData({
  335. taskContent: taskContent
  336. })
  337. });
  338. innerAudioContext.onError((res) => {
  339. // console.log(res)
  340. });
  341. //监听音频自然播放至结束的事件
  342. innerAudioContext.onEnded((res) => {
  343. taskContent.taskRadioType = 3;
  344. taskContent.showImg = taskContent.playImg;
  345. this.setData({
  346. taskContent: taskContent
  347. })
  348. });
  349. } else if (radioType == 4) {
  350. innerAudioContext.stop();
  351. //监听音频停止事件
  352. innerAudioContext.onStop((res) => {
  353. taskContent.taskRadioType = 3;
  354. taskContent.showImg = taskContent.playImg;
  355. this.setData({
  356. taskContent: taskContent
  357. })
  358. });
  359. }
  360. },
  361. choosefile : function(){
  362. let that = this;
  363. wx.showActionSheet({
  364. itemList: ['选择图片','选择视频'],
  365. success(res) {
  366. if (res.tapIndex == 0){
  367. if (that.data.images.length >= 3){
  368. wx.showToast({
  369. title: '图片最多只能上传3张',
  370. icon: 'none',
  371. duration: 2000
  372. });
  373. }else{
  374. that.chooseImg();
  375. }
  376. } else if (res.tapIndex == 1){
  377. if (that.data.videos.length >= 1) {
  378. wx.showToast({
  379. title: '视频最多只能上传1个',
  380. icon: 'none',
  381. duration: 2000
  382. });
  383. } else {
  384. that.chooseVideo();
  385. }
  386. }
  387. },
  388. fail(res) {
  389. // console.log('fail')
  390. },
  391. })
  392. },
  393. chooseImg: function(){
  394. var imgs = this.data.images;
  395. var that = this;
  396. var count = 3 - imgs.length;
  397. wx.chooseImage({
  398. count: count,
  399. sizeType: ['compressed'],
  400. sourceType: ['album', 'camera'],
  401. success(res) {
  402. var files = res.tempFilePaths;
  403. imgs = imgs.concat(files);
  404. that.setData({
  405. images: imgs
  406. });
  407. that.checkfiles();
  408. }
  409. })
  410. },
  411. checkfiles: function(){
  412. if (this.data.videos.length >= 1 && this.data.images.length >= 3) {
  413. this.setData({
  414. choosefinish: true,
  415. });
  416. }else{
  417. this.setData({
  418. choosefinish: false,
  419. });
  420. }
  421. if (this.data.videos.length >= 1 || this.data.images.length >= 1){
  422. this.setData({
  423. choosefinishline: true
  424. });
  425. }else{
  426. this.setData({
  427. choosefinishline: false
  428. });
  429. }
  430. },
  431. chooseVideo: function () {
  432. var that = this;
  433. let maxDuration = 15;
  434. wx.chooseVideo({
  435. sourceType: ['album', 'camera'],
  436. compressed: true,
  437. maxDuration: maxDuration,
  438. camera: 'back',
  439. success(res) {
  440. if (res.duration > maxDuration){
  441. wx.showToast({
  442. title: '视频时长不能超过' + maxDuration +'秒',
  443. icon: 'none',
  444. duration: 2000
  445. });
  446. return false;
  447. }
  448. let videos = [];
  449. videos.push(res.tempFilePath);
  450. that.setData({
  451. videos: videos
  452. });
  453. that.checkfiles();
  454. }
  455. })
  456. },
  457. uploadFiles: function(){
  458. var that = this;
  459. if (files.length > 0){
  460. wx.uploadFile({
  461. url: app.globalData.uploadServerUrl + 'upload/upfile',
  462. filePath: files[filesindex].path,
  463. name: 'uploadFile',
  464. formData: {
  465. // 'ttype': mode,
  466. // 'orgId': orgId
  467. },
  468. success(res) {
  469. var data =JSON.parse(res.data);
  470. if (data.code != 0) {
  471. wx.hideLoading();
  472. wx.showToast({
  473. title: '文件上传失败1',
  474. icon: 'none',
  475. duration: 2000
  476. });
  477. that.setData({
  478. form:{
  479. images:[],
  480. voices:[],
  481. videos:[]
  482. }
  483. })
  484. return false;
  485. }else{
  486. var form = that.data.form;
  487. if (files[filesindex].type == 'image'){
  488. form.images.push(data.data.path);
  489. } else if (files[filesindex].type == 'video'){
  490. form.videos.push(data.data.path);
  491. }else{
  492. form.voices.push(data.data.path);
  493. }
  494. filescount--;
  495. if(filescount == 0){ //提交表单
  496. that.addorder();
  497. }else{ //继续上传
  498. filesindex++;
  499. that.uploadFiles();
  500. }
  501. }
  502. },
  503. fail(res){
  504. wx.hideLoading();
  505. wx.showToast({
  506. title: '文件上传失败',
  507. icon: 'none',
  508. duration: 2000
  509. });
  510. that.setData({
  511. form: {
  512. images: [],
  513. voices: [],
  514. videos: []
  515. }
  516. })
  517. return false;
  518. }
  519. })
  520. }
  521. },
  522. delfile: function(e){
  523. var type = e.currentTarget.dataset.type;
  524. var path = e.currentTarget.dataset.path;
  525. if(type == 'image'){
  526. var imgs = this.data.images;
  527. var newsimgs = [];
  528. for(var i in imgs){
  529. if (imgs[i] == path){
  530. continue;
  531. }
  532. newsimgs.push(imgs[i]);
  533. }
  534. this.setData({
  535. images: newsimgs
  536. });
  537. this.checkfiles();
  538. }else if(type == 'video'){
  539. var videos = this.data.videos;
  540. var newvideos = [];
  541. for (var i in videos) {
  542. if (videos[i] == path) {
  543. continue;
  544. }
  545. newvideos.push(videos[i]);
  546. }
  547. this.setData({
  548. videos: newvideos
  549. });
  550. this.checkfiles();
  551. }else{
  552. var task = this.data.taskContent;
  553. task.showImg = task.readingImg;
  554. task.taskRadioType = '1';
  555. this.setData({
  556. voices: '',
  557. taskContent: task
  558. });
  559. }
  560. },
  561. btnsubmit: function(e){
  562. //数据初始化
  563. files = [];
  564. filescount = 0;
  565. uploadFlag = 0;
  566. filesindex = 0;
  567. if (!this.data.content && !this.data.voices && this.data.videos.length == 0) {
  568. wx.showToast({
  569. title: '请填写任务内容',
  570. icon: 'none',
  571. duration: 2000
  572. });
  573. return false;
  574. }
  575. if (ysconfig == 1){ //强制扫码,地点必须选择
  576. if(this.data.conveyStart <= 0){
  577. wx.showToast({
  578. title: '未选择收件地点',
  579. icon: 'none',
  580. duration: 2000
  581. });
  582. return false;
  583. }
  584. if (this.data.conveyEnd <= 0) {
  585. wx.showToast({
  586. title: '未选择送达地点',
  587. icon: 'none',
  588. duration: 2000
  589. });
  590. return false;
  591. }
  592. }
  593. if (this.data.conveyStart > 0 && this.data.conveyEnd > 0 && this.data.conveyStart == this.data.conveyEnd){
  594. wx.showToast({
  595. title: '收件地点与送达地点不能相同',
  596. icon: 'none',
  597. duration: 2000
  598. });
  599. return false;
  600. }
  601. if (this.data.conveyTypeId <= 0) {
  602. wx.showToast({
  603. title: '请选择运送类型',
  604. icon: 'none',
  605. duration: 2000
  606. });
  607. return false;
  608. }
  609. if (!this.data.xqTime) {
  610. wx.showToast({
  611. title: '需求时间不能为空',
  612. icon: 'none',
  613. duration: 2000
  614. });
  615. return false;
  616. }
  617. if (!this.data.ywcTime) {
  618. wx.showToast({
  619. title: '完成时间不能为空',
  620. icon: 'none',
  621. duration: 2000
  622. });
  623. return false;
  624. }
  625. if (this.data.depId==0) {
  626. wx.showToast({
  627. title: '请选择部门',
  628. icon: 'none',
  629. duration: 2000
  630. });
  631. return false;
  632. }
  633. var formdata = {
  634. images: this.data.images,
  635. voices: this.data.voices?[this.data.voices]:[],
  636. videos: this.data.videos,
  637. }
  638. if (formdata.voices.length > 0) {
  639. for (var i in formdata.voices){
  640. var file = {
  641. path: formdata.voices[i],
  642. type: 'voice'
  643. }
  644. files.push(file);
  645. }
  646. }
  647. if (formdata.images.length > 0) {
  648. for (var i in formdata.images) {
  649. var file = {
  650. path: formdata.images[i],
  651. type: 'image'
  652. }
  653. files.push(file);
  654. }
  655. }
  656. if (formdata.videos.length > 0) {
  657. for (var i in formdata.videos) {
  658. var file = {
  659. path: formdata.videos[i],
  660. type: 'video'
  661. }
  662. files.push(file);
  663. }
  664. }
  665. //上传文件
  666. if(files.length > 0){
  667. filescount = files.length;
  668. wx.showLoading({
  669. title: '提交中',
  670. mask: true
  671. });
  672. this.uploadFiles();
  673. }else{
  674. this.addorder();
  675. }
  676. },
  677. onPickerChange3: function (e) {
  678. this.setData({
  679. xqTime: e.detail.dateString
  680. })
  681. },
  682. onPickerChange4: function (e) {
  683. console.log(e);
  684. this.setData({
  685. ywcTime: e.detail.dateString
  686. })
  687. },
  688. addorder: function(){
  689. var that = this;
  690. var form = that.data.form;
  691. var formimages = '';
  692. if (form.images.length > 0) {
  693. formimages = form.images.join(",");
  694. }
  695. var formvoices = '';
  696. if (form.voices.length > 0) {
  697. formvoices = form.voices.join(",");
  698. }
  699. var formvideos = '';
  700. if (form.videos.length > 0) {
  701. formvideos = form.videos.join(",");
  702. }
  703. var url = app.globalData.serverUrl + '/orders/add';
  704. app.ajax({
  705. url: url,
  706. apiname:"orderAdd",
  707. type: 'POST',
  708. data: {
  709. depId: that.data.depId,
  710. content: that.data.content,
  711. images: formimages,
  712. voices: formvoices,
  713. videos: formvideos,
  714. workTypeMode: 3,
  715. start: that.data.conveyStart,
  716. end: that.data.conveyEnd,
  717. xqTime: that.data.xqTime,
  718. ywcTime: that.data.ywcTime,
  719. type: that.data.conveyTypeId,
  720. name: that.data.name,
  721. phone: that.data.phone,
  722. deviceId: that.data.conveyDevice,
  723. priority: that.data.priority,
  724. pName: that.data.bName,
  725. bedNumber: that.data.ch,
  726. baNumber: that.data.bah,
  727. gender: that.data.gender,
  728. back: that.data.is_back,
  729. }
  730. });
  731. },
  732. previewImage: function (e) {
  733. var current = e.target.dataset.src;
  734. wx.previewImage({
  735. current: current, // 当前显示图片的http链接
  736. urls: this.data.images, // 需要预览的图片http链接列表
  737. success: function (e) {}
  738. })
  739. },
  740. videotap: function (e) {
  741. var video = e.target.dataset.video;
  742. app.gotopage('/pages/video/index', { video: video });
  743. // wx.navigateTo({
  744. // url: '/pages/video/index',
  745. // success: function (res) {
  746. // res.eventChannel.emit('acceptDataFromOpenerPage', { video: video })
  747. // }
  748. // })
  749. },
  750. contentChange: function (e) {
  751. this.setData({
  752. content: e.detail.value
  753. })
  754. },
  755. hideChange: function(e) {
  756. var hide = this.data.hide == 1?0:1;
  757. this.setData({
  758. hide: hide
  759. })
  760. },
  761. bindMultiPickerChange: function (e) {
  762. let hour = e.detail.value[0];
  763. let min = e.detail.value[1];
  764. let conveyTime = this.data.conveyTime;
  765. if(hour == 0 && min == 0){
  766. conveyTime.text = '立即';
  767. } else if (hour == 0){
  768. conveyTime.text = min + '分钟后送达';
  769. }else{
  770. if (min == 0){
  771. conveyTime.text = hour + '小时后送达';
  772. }else{
  773. conveyTime.text = hour + '小时' + min + '分钟后送达';
  774. }
  775. }
  776. conveyTime.hour = hour;
  777. conveyTime.min = min;
  778. this.setData({
  779. conveyTime: conveyTime
  780. });
  781. },
  782. goSelect(e){
  783. let that = this;
  784. let type = e.currentTarget.dataset.type;
  785. wx.navigateTo({
  786. url: '/pages/meeting/select/index',
  787. events: {
  788. // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  789. acceptDataFromOpenedPage: function(data) {
  790. console.log(data)
  791. let a = [];
  792. if(data.select.length > 2){
  793. a.push(data.select[0]);
  794. a.push(data.select[1]);
  795. }else{
  796. data.select.forEach((item) => {
  797. a.push(item);
  798. });
  799. }
  800. if(data.type == 1){
  801. let strs = [];
  802. a.forEach((item) => {
  803. strs.push(item.stimetext+'~'+item.etimetext);
  804. });
  805. let str = strs.join(',');
  806. if(data.select.length > 2){
  807. str += '...';
  808. }
  809. that.setData({
  810. selectTimes: data.select,
  811. timesLabel: str
  812. });
  813. }else if(data.type == 2){
  814. let strs = [];
  815. a.forEach((item) => {
  816. strs.push(item.realName);
  817. });
  818. let str = strs.join(',');
  819. if(data.select.length > 2){
  820. str += '...';
  821. }
  822. that.setData({
  823. selectUser: data.select,
  824. userLabel: str
  825. });
  826. }else if(data.type == 3){
  827. let strs = [];
  828. a.forEach((item) => {
  829. strs.push(item.title);
  830. });
  831. let str = strs.join(',');
  832. if(data.select.length > 2){
  833. str += '...';
  834. }
  835. that.setData({
  836. selectDevice: data.select,
  837. deviceLabel: str
  838. });
  839. }else if(data.type == 4){
  840. let strs = [];
  841. a.forEach((item) => {
  842. strs.push(item.name);
  843. });
  844. let str = strs.join(',');
  845. if(data.select.length > 2){
  846. str += '...';
  847. }
  848. that.setData({
  849. selectLabel: data.select,
  850. label: str
  851. });
  852. }
  853. }
  854. },
  855. success: function(res) {
  856. // 通过eventChannel向被打开页面传送数据
  857. if(type == 1){
  858. res.eventChannel.emit('acceptDataFromOpenerPage', {
  859. type: type,
  860. list: that.data.info.times,
  861. select:that.data.selectTimes
  862. });
  863. } else if (type == 2){
  864. res.eventChannel.emit('acceptDataFromOpenerPage', {
  865. type: type,
  866. list: [],
  867. select:that.data.selectUser
  868. });
  869. } else if (type == 3){
  870. res.eventChannel.emit('acceptDataFromOpenerPage', {
  871. type: type,
  872. list: that.data.info.devices,
  873. select:that.data.selectDevice
  874. });
  875. }else if (type == 4){
  876. res.eventChannel.emit('acceptDataFromOpenerPage', {
  877. type: type,
  878. list: [],
  879. select:that.data.selectLabel
  880. });
  881. }
  882. }
  883. })
  884. },
  885. getUserInfo(){
  886. app.ajax({
  887. url: app.globalData.serverUrl + '/User/info',
  888. type: 'POST',
  889. apiname:'userInfo',
  890. data: {
  891. }
  892. });
  893. },
  894. })