pendingDeliveryOrders.js 7.9 KB

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