confirm.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. import * as API from '@/apis/buytickets.js'
  2. export default {
  3. data() {
  4. return {
  5. noback:true,
  6. id: '',
  7. num: 0,
  8. pic: '',
  9. list: [],
  10. selectList: [],
  11. subForm: {
  12. pageIndex: 1,
  13. pageSize: 20,
  14. totalPage: 1
  15. }
  16. }
  17. },
  18. methods: {
  19. gotoHome(){
  20. uni.switchTab({
  21. url: '/pages/index/index'
  22. });
  23. },
  24. submit() {
  25. var obj = this.carhelp.get("form");
  26. obj.oplist = []
  27. for (var i in this.list) {
  28. if (this.list[i].ck) {
  29. obj.oplist.push(this.list[i]);
  30. }
  31. }
  32. this.carhelp.set("form", obj);
  33. uni.navigateTo({
  34. url: '/pages/buytickets/selectSite?id=' + this.id
  35. })
  36. },
  37. ckBtn(item) {
  38. item.ck = !item.ck;
  39. if (item.ck) {
  40. var bl=true
  41. for (var i = 0; i < this.selectList.length; i++) {
  42. if (this.selectList[i].upStationId != item.upStationId) {
  43. bl=false;
  44. }
  45. break;
  46. }
  47. if(!bl){
  48. item.ck = !item.ck;
  49. this.$refs.common.alert("所选乘客上车站点不一致,请重新选择。");
  50. return;
  51. }
  52. this.num++;
  53. this.selectList.push(item);
  54. } else {
  55. this.num--;
  56. for (var i = 0; i < this.selectList.length; i++) {
  57. if (this.selectList[i].id == item.id) {
  58. this.selectList.splice(i, 1);
  59. }
  60. }
  61. }
  62. console.log(this.selectList)
  63. },
  64. getPassengerInfo() {
  65. var thisform = {
  66. id: this.id,
  67. openId: this.carhelp.getOpenId()
  68. }
  69. this.$refs.common.showLoading()
  70. API.getPassengerInfo(thisform).then((response) => {
  71. if (!response.result) {
  72. this.$refs.common.goError(response.message)
  73. return
  74. }
  75. this.passengerInfo = response.data
  76. var obj = this.carhelp.get("form");
  77. if(!obj){
  78. obj={}
  79. }
  80. obj.list = this.passengerInfo.list;
  81. obj.name= 'buytickets';
  82. obj.id= this.id;
  83. this.carhelp.set("form", obj);
  84. if (response.data.supply) {
  85. //this.$refs.common.goError(response.message)
  86. this.$refs.common.setFnc(()=>{
  87. uni.switchTab({
  88. url: '/pages/news/index'
  89. });
  90. },()=>{
  91. if (!response.data.id) {
  92. uni.redirectTo({
  93. url: '/pages/buytickets/index?id=' + this.id+'&back=true'
  94. })
  95. } else {
  96. this.getShiftInfo()
  97. }
  98. })
  99. this.$refs.common.confirm('存在需要补票的订单,是否前去查看?')
  100. return;
  101. }
  102. if (!response.data.id) {
  103. uni.redirectTo({
  104. url: '/pages/buytickets/index?id=' + this.id+'&back=true'
  105. })
  106. } else {
  107. this.upBusNoTicketList();
  108. }
  109. }).catch(error => {
  110. if (error) {
  111. this.$refs.common.goError(error)
  112. return
  113. }
  114. //this.$refs.common.showLoading(false,error)
  115. })
  116. },
  117. upBusNoTicketList() {
  118. this.$refs.common.showLoading();
  119. this.subForm.id = this.id;
  120. var obj = this.carhelp.get("form")
  121. this.list = [];
  122. API.upBusNoTicketList(this.subForm).then((res) => {
  123. var list = res.data.data;
  124. if(!list.length){
  125. this.$refs.common.alert2("无照片,请上车刷脸或联系司机");
  126. return;
  127. }
  128. for (var i in list) {
  129. list[i].show = true;
  130. list[i].ck = false;
  131. for (var j in obj.list) {
  132. if (obj.list[j].id == list[i].id) {
  133. list[i].show = false;
  134. break;
  135. }
  136. }
  137. if (list[i].show) {
  138. this.list.push(list[i]);
  139. }
  140. }
  141. this.selectList=[];//清空选中
  142. if (this.list.length != 0) {
  143. this.$refs.common.showLoading(false, "刷新成功");
  144. } else {
  145. this.$refs.common.showLoading(false);
  146. }
  147. }).catch(error => {
  148. this.$refs.common.showLoading(false, error);
  149. })
  150. }
  151. },
  152. onLoad(op) {
  153. if(op.back){
  154. this.noback=!op.back
  155. }
  156. this.id = op.id
  157. },
  158. onReady() {
  159. if (!this.id) {
  160. this.$refs.common.goError()
  161. }
  162. var obj = this.carhelp.get("form")
  163. if (obj && obj.name == 'buytickets' && obj.id == this.id) {
  164. //不创建新订单
  165. } else {
  166. this.carhelp.set("form", {
  167. name: 'buytickets',
  168. id: this.id,
  169. oplist: [], //当前添加的2人
  170. list: [] // 一共添加的人
  171. });
  172. }
  173. if (false&&!this.carhelp.getPersonInfo()) {
  174. this.$refs.common.setFnc(this.confirmBtn)
  175. this.$refs.common.alert2('您还不是车信达用户,注册后再购买车票。', '前往注册', '尚未注册')
  176. } else {
  177. }
  178. this.getPassengerInfo()
  179. }
  180. }