selectRider.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. var app = getApp();
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. order_id: {
  8. type: String,
  9. value: 0
  10. },
  11. show: {
  12. type: Boolean,
  13. value: false
  14. }
  15. },
  16. /**
  17. * 组件的初始数据
  18. */
  19. data: {
  20. list: []
  21. },
  22. attached() {
  23. this.initFn()
  24. },
  25. /**
  26. * 组件的方法列表
  27. */
  28. methods: {
  29. initFn: function(keyword=''){
  30. this.page = 1;
  31. this.keyword = keyword;
  32. this.setData({
  33. list: [],
  34. loadText: "加载中...",
  35. noData: 0,
  36. loadMore: true,
  37. },()=>{
  38. this.getData();
  39. })
  40. },
  41. goResult: function(e) {
  42. let keyword = e.detail.value.replace(/\s+/g, '');
  43. this.initFn(keyword);
  44. },
  45. getData: function () {
  46. let that = this;
  47. let token = wx.getStorageSync('token');
  48. let order_id = this.data.order_id;
  49. let keyword = this.keyword;
  50. wx.showLoading();
  51. app.util.request({
  52. url: 'entry/wxapp/index',
  53. data: {
  54. controller: 'order.choosemember',
  55. token,
  56. is_supply: 1,
  57. order_id,
  58. page: this.page,
  59. keyword
  60. },
  61. dataType: 'json',
  62. success: function (res) {
  63. if (res.data.code == 0) {
  64. let h = {};
  65. let list = res.data.data;
  66. if (list.length < 10) h.noMore = true;
  67. let oldList = that.data.list;
  68. list = oldList.concat(list);
  69. that.page++;
  70. that.setData({ list, ...h })
  71. } else if(res.data.code==2) {
  72. app.util.message(res.data.msg, 'switchTo:/lionfish_comshop/pages/user/me', 'error');
  73. } else {
  74. let h = {};
  75. if(that.page==1) h.noData = 1;
  76. h.loadMore = false;
  77. h.noMore = false;
  78. h.loadText = "没有更多记录了~";
  79. that.setData( h )
  80. }
  81. wx.hideLoading();
  82. }
  83. })
  84. },
  85. toLower: function() {
  86. if (!this.data.loadMore) return false;
  87. this.getData();
  88. },
  89. selectItem: function(e) {
  90. let distribution_id = e.currentTarget.dataset.id || '';
  91. let order_id = this.data.order_id;
  92. let token = wx.getStorageSync('token');
  93. wx.showLoading();
  94. order_id && app.util.ProReq('order.sub_orderchoose_distribution', {token, order_id, distribution_id, is_supply: 1}).then(res=>{
  95. wx.showToast({ title: '设置成功' })
  96. setTimeout(()=>{
  97. this.triggerEvent('update');
  98. }, 1500)
  99. }).catch(err=>{
  100. this.triggerEvent('update');
  101. app.util.message(err.msg, '', 'error');
  102. })
  103. },
  104. close: function() {
  105. this.triggerEvent('close');
  106. }
  107. }
  108. })