groupList.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. var app = getApp();
  2. var status = require('../../utils/index.js');
  3. Page({
  4. data: {
  5. currentTab: 0,
  6. pageSize: 10,
  7. navList: [{
  8. name: "全部",
  9. id: "0"
  10. }, {
  11. name: "待配送",
  12. id: "1"
  13. },
  14. {
  15. name: "待签收",
  16. id: "2"
  17. },
  18. {
  19. name: "待提货",
  20. id: "3"
  21. }, {
  22. name: "已完成",
  23. id: "4"
  24. }
  25. ],
  26. loadText: "",
  27. disUserId: "",
  28. no_order: 0,
  29. page: 1,
  30. hide_tip: true,
  31. order: [],
  32. tip: '正在加载',
  33. searchfield: [
  34. {
  35. field: 'ordersn',
  36. name: '订单号'
  37. },
  38. {
  39. field: 'member',
  40. name: '会员昵称'
  41. },
  42. {
  43. field: 'address',
  44. name: '配送联系人'
  45. },
  46. {
  47. field: 'mobile',
  48. name: '下单手机号'
  49. },
  50. {
  51. field: 'location',
  52. name: '配送地址'
  53. },
  54. {
  55. field: 'goodstitle',
  56. name: '商品标题'
  57. }
  58. ],
  59. fieldIdx: 0,
  60. groupInfo: {
  61. group_name: '社区',
  62. owner_name: '团长'
  63. }
  64. },
  65. searchOBj: {},
  66. /**
  67. * 生命周期函数--监听页面加载
  68. */
  69. onLoad: function (options) {
  70. let that = this;
  71. status.setGroupInfo().then((groupInfo) => {
  72. that.setData({ groupInfo })
  73. });
  74. var currentTab = 0;
  75. if (options != undefined) {
  76. currentTab = options.tab;
  77. }
  78. this.setData({
  79. currentTab: currentTab
  80. });
  81. this.getData(currentTab);
  82. },
  83. /**
  84. * 生命周期函数--监听页面显示
  85. */
  86. onShow: function () {
  87. // todo
  88. },
  89. bindFiledChange: function (e) {
  90. this.setData({
  91. fieldIdx: e.detail.value
  92. })
  93. },
  94. searchByKey: function (e) {
  95. let that = this;
  96. let { searchfield, fieldIdx } = this.data;
  97. let field = searchfield[fieldIdx].field;
  98. let keyword = e.detail.value || '';
  99. this.searchOBj = { keyword, searchfield: field };
  100. this.setData({
  101. page: 1,
  102. order: []
  103. },()=>{
  104. that.getData();
  105. });
  106. },
  107. callPhone: function(e){
  108. var that = this;
  109. var phoneNumber = e.currentTarget.dataset.phone;
  110. phoneNumber && wx.makePhoneCall({
  111. phoneNumber: phoneNumber
  112. });
  113. },
  114. /**
  115. * 导航切换
  116. */
  117. switchNav: function (t) {
  118. if (this.data.currentTab === 1 * t.currentTarget.dataset.id) return false;
  119. this.setData({
  120. currentTab: 1 * t.currentTarget.dataset.id,
  121. page: 1,
  122. order: []
  123. });
  124. this.getData();
  125. },
  126. /**
  127. * 获取数据
  128. */
  129. getData: function () {
  130. wx.showLoading({
  131. title: "加载中...",
  132. mask: true
  133. });
  134. this.setData({
  135. isHideLoadMore: true
  136. })
  137. this.data.no_order = 1
  138. let that = this;
  139. var token = wx.getStorageSync('token');
  140. var currentTab = this.data.currentTab;
  141. var order_status = -1;
  142. if (currentTab == 1) {
  143. order_status = 1;
  144. } else if (currentTab == 2) {
  145. order_status = 14;
  146. } else if (currentTab == 3) {
  147. order_status = 4;
  148. } else if (currentTab == 4) {
  149. order_status = 6;
  150. }
  151. //currentTab
  152. app.util.request({
  153. url: 'entry/wxapp/index',
  154. data: {
  155. controller: 'order.orderlist',
  156. is_tuanz: 1,
  157. token: token,
  158. page: that.data.page,
  159. order_status: order_status,
  160. ...this.searchOBj
  161. },
  162. dataType: 'json',
  163. success: function (res) {
  164. let { open_aftersale, open_aftersale_time } = res.data;
  165. let h = { open_aftersale, open_aftersale_time };
  166. if (res.data.code == 0) {
  167. console.log(that.data.page);
  168. let data = res.data.data;
  169. let rushList = that.data.order.concat(data);
  170. that.setData({
  171. order: rushList,
  172. hide_tip: true,
  173. no_order: 0,
  174. ...h
  175. });
  176. wx.hideLoading();
  177. } else {
  178. that.setData({
  179. isHideLoadMore: true,
  180. ...h
  181. })
  182. wx.hideLoading();
  183. return false;
  184. }
  185. }
  186. })
  187. },
  188. sign_one: function (e) {
  189. var that = this;
  190. var order_id = e.currentTarget.dataset.order_id;
  191. var token = wx.getStorageSync('token');
  192. wx.showModal({
  193. title: '提示',
  194. content: '确认提货',
  195. confirmColor: '#F75451',
  196. success(res) {
  197. if (res.confirm) {
  198. app.util.request({
  199. 'url': 'entry/wxapp/index',
  200. 'data': {
  201. controller: 'order.sign_dan_order',
  202. token: token,
  203. order_id: order_id
  204. },
  205. dataType: 'json',
  206. success: function (res) {
  207. wx.showToast({
  208. title: '签收成功',
  209. duration: 1000
  210. })
  211. var order = that.data.order;
  212. var new_order = [];
  213. for (var i in order) {
  214. if (order[i].order_id != order_id) {
  215. new_order.push(order[i]);
  216. }
  217. }
  218. that.setData({
  219. order: new_order
  220. })
  221. }
  222. })
  223. }
  224. }
  225. })
  226. },
  227. /**
  228. * 跳转订单详情
  229. */
  230. goOrderDetail: function (t) {
  231. var a = t.currentTarget.dataset.order_id;
  232. wx.navigateTo({
  233. url: "/lionfish_comshop/moduleA/groupCenter/groupDetail?groupOrderId=" + a
  234. });
  235. },
  236. onReachBottom: function () {
  237. if (this.data.no_order == 1) return false;
  238. this.data.page += 1;
  239. this.getData();
  240. this.setData({
  241. isHideLoadMore: false
  242. })
  243. },
  244. handleTipDialog: function(e){
  245. let fen_type = e.currentTarget.dataset.type || 0;
  246. this.setData({
  247. showTipDialog: !this.data.showTipDialog,
  248. fen_type
  249. })
  250. }
  251. })