index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import * as API from '@/apis/remind.js'
  2. import * as API_index from '@/apis/index.js'
  3. export default {
  4. data() {
  5. return {
  6. readyBl:false,
  7. list: [
  8. {
  9. name: '提前1站',
  10. isRemind: "1",
  11. },
  12. {
  13. name: '提前2站',
  14. isRemind: "2",
  15. }
  16. ],
  17. upList:[],
  18. downList:[],
  19. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  20. value: 'orange',
  21. }
  22. },
  23. methods: {
  24. passengerRemindList(){
  25. this.$refs.common.showLoading()
  26. var obj={
  27. openId:this.carhelp.getOpenId()
  28. }
  29. API.passengerRemindList(obj).then((response) => {
  30. var list= response.data;
  31. for(var i in list){
  32. var item=list[i];
  33. if(item.remindType=="1"){
  34. this.upList.push(item);
  35. }else{
  36. this.downList.push(item);
  37. }
  38. }
  39. this.$refs.common.showLoading(false)
  40. }).catch(error => {
  41. this.$refs.common.showLoading(false,error)
  42. })
  43. },
  44. // 选中某个单选框时,由radio时触发
  45. radioChange(e) {
  46. console.log(e);
  47. },
  48. // 选中任一radio时,由radio-group触发
  49. radioGroupChange(item) {
  50. var obj={
  51. id:item.id,
  52. num:item.stopInAdvance
  53. }
  54. API.updateStationNum(obj).then((res) => {
  55. this.$refs.common.alert( "设置成功");
  56. }).catch(error => {
  57. this.$refs.common.alert( error);
  58. })
  59. },del(id){
  60. API_index.cancelRemind(id).then((res) => {
  61. this.$refs.common.alert( "设置成功");
  62. }).catch(error => {
  63. this.$refs.common.alert( error);
  64. })
  65. },
  66. add(){
  67. var item= this.remindInfo
  68. var obj={
  69. startStationId:item.startStationId,
  70. remindStationId :item.ticketDownStationId,
  71. stopInAdvance:item.isRemind,
  72. remindType:"2",
  73. vehicleShiftId:item.vehicleShiftId,
  74. openId:this.carhelp.getOpenId()
  75. }
  76. API_index.saveRemind(obj).then((res) => {
  77. item.remindId=res.data.id
  78. this.$refs.common.alert( "设置成功");
  79. }).catch(error => {
  80. this.$refs.common.alert( error);
  81. })
  82. },
  83. delBtn(item){
  84. this.$refs.common.setFnc(()=>{
  85. item.del=true;
  86. this.del(item.id);
  87. this.$forceUpdate()
  88. })
  89. this.$refs.common.confirm('是否删除当前提醒?')
  90. },
  91. },onReady(){
  92. this.readyBl=true;
  93. this.passengerRemindList();
  94. },onShow(){
  95. if(this.readyBl){
  96. this.upList=[];
  97. this.downList=[];
  98. this.passengerRemindList();
  99. }
  100. }
  101. }