pendingDeliveryOrders.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. // lionfish_comshop/pages/groupCenter/pendingDeliveryOrders.js
  2. var app = getApp();
  3. var util = require('../../utils/util.js');
  4. var memberId = "";
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. checkedAll: true,
  11. checkedCount: 0,
  12. is_check_all: false,
  13. needAuth: false,
  14. memberId: 0,
  15. order: [],
  16. param: [],
  17. isIpx: false
  18. },
  19. /**
  20. * 生命周期函数--监听页面加载
  21. */
  22. onLoad: function(options) {
  23. app.globalData.isIpx && this.setData({
  24. isIpx: true
  25. });
  26. if (options.scene != undefined) {
  27. var scene = decodeURIComponent(options.scene);
  28. if (scene != 'undefined') {
  29. options.memberId = scene;
  30. }
  31. }
  32. memberId = options.memberId;
  33. this.setData({
  34. memberId: memberId
  35. })
  36. if (!util.check_login()) {
  37. this.setData({
  38. needAuth: true
  39. })
  40. } else {
  41. console.log('peding login in ');
  42. this.getData();
  43. }
  44. },
  45. /**
  46. * 授权成功回调
  47. */
  48. authSuccess: function() {
  49. this.setData({
  50. needAuth: false
  51. })
  52. this.getData();
  53. },
  54. /**
  55. * 获取数据
  56. */
  57. getData: function() {
  58. wx.showLoading({
  59. title: "加载中...",
  60. mask: true
  61. });
  62. var that = this;
  63. var token = wx.getStorageSync('token');
  64. //currentTab
  65. app.util.request({
  66. 'url': 'entry/wxapp/index',
  67. 'data': {
  68. controller: 'community.get_member_ziti_order',
  69. memberId: that.data.memberId,
  70. token: token
  71. },
  72. dataType: 'json',
  73. success: function(res) {
  74. if (res.data.code == 0) {
  75. let rushList = that.data.order.concat(res.data.data);
  76. var order = rushList.filter(function (item) {
  77. return item.delivery != 'express';
  78. });
  79. if (order.length>0){
  80. that.setData({
  81. order: order,
  82. checkedCount: order.length,
  83. checkedAll: true,
  84. is_check_all: true
  85. });
  86. }
  87. } else if (res.data.code == 1) {
  88. that.setData({
  89. order: []
  90. });
  91. } else if (res.data.code == 2) {
  92. // no login
  93. }
  94. wx.hideLoading();
  95. }
  96. })
  97. // 成功
  98. },
  99. /**
  100. * 状态改变
  101. */
  102. transformOrderStatus: function(e) {
  103. switch (Number(e)) {
  104. case 1:
  105. return "待提货";
  106. case 4:
  107. return "待配送";
  108. default:
  109. return "";
  110. }
  111. },
  112. /**
  113. * 勾选
  114. */
  115. checkboxChange: function(e) {
  116. var t = e.currentTarget.dataset.type,
  117. o = e.currentTarget.dataset.index,
  118. n = this.data.order,
  119. a = [],
  120. i = e.detail.value,
  121. r = this.data.checkedAll,
  122. s = false,
  123. c = 0;
  124. var is_check_all = this.data.is_check_all;
  125. if ("all" === t) {
  126. if (is_check_all) {
  127. n.forEach(function(e) {
  128. e.checked = 0;
  129. })
  130. } else {
  131. n.forEach(function(e) {
  132. e.checked = 1;
  133. })
  134. }
  135. this.setData({
  136. checkedCount: n.length,
  137. order: n,
  138. is_check_all: !is_check_all,
  139. checkedAll: !is_check_all
  140. })
  141. } else if ("order" === t) {
  142. n.forEach(function(e, t) {
  143. // e.checked = 0;
  144. if (o == t) {
  145. if (e.checked) {
  146. e.checked = 0
  147. } else {
  148. e.checked = 1
  149. }
  150. }
  151. })
  152. var ck = 0;
  153. n.forEach(function(e) {
  154. if (e.checked) {
  155. ck++;
  156. }
  157. })
  158. this.setData({
  159. checkedCount: ck,
  160. order: n,
  161. is_check_all: ck == n.length ? true : false,
  162. checkedAll: ck == n.length ? true : false
  163. })
  164. }
  165. },
  166. /**
  167. * 商品提货确认
  168. */
  169. sign: function(e) {
  170. var t = this;
  171. var orderno = e.target.dataset.orderno,
  172. orderskuid = e.target.dataset.orderskuid;
  173. wx.showModal({
  174. title: "商品提货确认",
  175. content: "请确认买家已收到货,再进行提货确认哦!",
  176. confirmText: "确定",
  177. confirmColor: "#FF673F",
  178. success: function(e) {
  179. if (e.confirm) {
  180. wx.showLoading({
  181. title: "加载中...",
  182. mask: true
  183. });
  184. var data = {
  185. orderNo: orderno,
  186. orderSkuId: orderskuid
  187. }
  188. // 发送请求
  189. //成功
  190. t.getData();
  191. wx.showToast({
  192. title: "商品提货成功",
  193. icon: "none"
  194. });
  195. } else {
  196. wx.hideLoading();
  197. }
  198. }
  199. });
  200. },
  201. /**
  202. * 订单提货确认
  203. */
  204. signOrder: function(e) {
  205. var t = this;
  206. wx.showLoading({
  207. title: "加载中...",
  208. mask: true
  209. });
  210. var that = this;
  211. var orderid = e.target.dataset.orderid;
  212. wx.showModal({
  213. title: "订单提货确认",
  214. content: "请确认买家已收改订单的所有商品,再进行提货确认哦!",
  215. confirmText: "确定",
  216. confirmColor: "#FF673F",
  217. success: function(e) {
  218. if (e.confirm) {
  219. wx.hideLoading();
  220. let data = {
  221. orderId: orderid
  222. }
  223. // 发送请求
  224. // 成功
  225. that.getData();
  226. wx.showToast({
  227. title: "订单提货成功",
  228. icon: "none"
  229. });
  230. } else {
  231. wx.hideLoading();
  232. }
  233. }
  234. });
  235. },
  236. /**
  237. * 批量订单提货确认
  238. */
  239. signAll: function() {
  240. var that = this;
  241. var n = this.data.order;
  242. var sub_order_arr = [];
  243. n.forEach(function(e) {
  244. if (e.checked) {
  245. sub_order_arr.push(e.order_id)
  246. }
  247. })
  248. if (sub_order_arr.length <= 0) {
  249. wx.showToast({
  250. title: '请选择签收商品',
  251. })
  252. return false;
  253. }
  254. var token = wx.getStorageSync('token');
  255. wx.showModal({
  256. title: "订单提货确认",
  257. content: "请确认买家已收选中的商品,再进行提货确认哦!",
  258. confirmText: "确定",
  259. confirmColor: "#FF673F",
  260. success: function(t) {
  261. if (t.confirm) {
  262. wx.showLoading({
  263. title: "加载中...",
  264. mask: true
  265. });
  266. // 请求成功
  267. app.util.request({
  268. 'url': 'entry/wxapp/index',
  269. 'data': {
  270. controller: 'order.receive_order_list',
  271. order_data: sub_order_arr,
  272. token: token
  273. },
  274. method: 'post',
  275. dataType: 'json',
  276. success: function(res) {
  277. wx.hideLoading();
  278. if (res.data.code == 0) {
  279. that.setData({
  280. order: []
  281. })
  282. that.getData();
  283. console.log('iniinin');
  284. wx.showToast({
  285. title: "订单提货成功",
  286. icon: "none"
  287. });
  288. } else {
  289. wx.showToast({
  290. title: "订单提货失败",
  291. icon: "none"
  292. });
  293. }
  294. }
  295. })
  296. }
  297. }
  298. });
  299. },
  300. /**
  301. * 复制信息
  302. */
  303. copyGoodsMsg: function() {
  304. if (0 !== this.data.checkedCount) {
  305. var info = "";
  306. this.data.list.forEach(function(items) {
  307. items.skuRspS.forEach(function(item) {
  308. item.checked && (info += ",【" + item.skuName + "】" + item.spec + "*" + item.skuNum);
  309. });
  310. }),
  311. wx.setClipboardData({
  312. data: info.substring(1),
  313. success: function() {
  314. wx.showToast({
  315. title: "复制成功",
  316. icon: "none"
  317. });
  318. },
  319. fail: function(error) {
  320. wx.showToast({
  321. title: "复制失败,请重试",
  322. icon: "none"
  323. }), console.log(error);
  324. }
  325. });
  326. } else {
  327. wx.showToast({
  328. title: "请选择商品",
  329. icon: "none"
  330. });
  331. }
  332. }
  333. })