shenhe.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. // pages/shenhe/shenhe.js
  2. var app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. userInfo: wx.getStorageSync('userInfo'),
  9. roleShow: false,
  10. pageHide: false,
  11. statusAdminList: [{
  12. id: '',
  13. name: "全部"
  14. }, {
  15. id: 0,
  16. name: "待审核"
  17. },
  18. {
  19. id: 1,
  20. name: "审核通过"
  21. },
  22. {
  23. id: 2,
  24. name: "已终止"
  25. },
  26. {
  27. id: 3,
  28. name: "超时自动取消"
  29. },
  30. {
  31. id: 4,
  32. name: "人工取消"
  33. }
  34. ],
  35. queryList: [{
  36. column: "checkNumber",
  37. name: "订单编号",
  38. text: "请输入订单编号"
  39. },
  40. {
  41. column: "dvyFlowId",
  42. name: "快递单号",
  43. text: "请输入快递单号"
  44. },
  45. {
  46. column: "picTitle",
  47. name: "商品名称",
  48. text: "请输入商品名称"
  49. },
  50. {
  51. column: "createTime",
  52. name: "下单时间",
  53. text: "开始日期 - 结束日期",
  54. type: 1
  55. },
  56. ],
  57. valueText: "",
  58. queryIndex: 3,
  59. queryShow: false,
  60. skuCode: "", //商品编码SKU
  61. checkStatus: 0, //订单状态
  62. checkNumber: "", //订单编号
  63. dvyFlowId: "", //快递单号
  64. picTitle: "", //商品名称
  65. orderTimeStart: "",
  66. orderTimeEnd: "",
  67. current: 0,
  68. orderList: [],
  69. current: 0,
  70. pages: null,
  71. loading: true,
  72. pageHide: false,
  73. isStraumann: false
  74. },
  75. /**
  76. * 生命周期函数--监听页面加载
  77. */
  78. async onLoad(options) {
  79. this.setData({
  80. checkStatus: options.status || 0
  81. })
  82. },
  83. /**
  84. * 生命周期函数--监听页面初次渲染完成
  85. */
  86. onReady() {
  87. },
  88. /**
  89. * 生命周期函数--监听页面显示
  90. */
  91. async onShow() {
  92. setTimeout(() => {
  93. wx.setNavigationBarTitle({
  94. title: app.globalData.tabbar.list[1].text,
  95. });
  96. }, 500);
  97. let userInfo = wx.getStorageSync('userInfo');
  98. if (typeof this.getTabBar === 'function' && this.getTabBar()) {
  99. // let userInfo = wx.getStorageSync('userInfo');
  100. // if (userInfo && userInfo.userId) {
  101. // app.globalData.tabbar.list[0].show = false;
  102. // } else {
  103. // app.globalData.tabbar.list[0].show = true;
  104. // }
  105. setTimeout(() => {
  106. this.getTabBar().setData({
  107. selectIndex: 1,
  108. tabbar: app.globalData.tabbar
  109. })
  110. }, 500);
  111. }
  112. this.setData({
  113. isStraumann: wx.getStorageSync('isStraumann')
  114. })
  115. // if (this.data.pageHide) {
  116. // this.setData({
  117. // current: 0,
  118. // orderList: [],
  119. // pages: null
  120. // });
  121. // }
  122. this.setData({
  123. current: 0,
  124. loading: false,
  125. orderList: [],
  126. userInfo
  127. })
  128. if (!userInfo || !userInfo.userId) {
  129. return;
  130. }
  131. let roleList = wx.getStorageSync('roleList');
  132. let role = roleList.find(v => v.roleCode == 'ROLE_ORDER_AUDIT' || v.roleCode == 'SZMAdmin');
  133. if (this.data.isStraumann) {
  134. this.setData({
  135. roleShow: true
  136. })
  137. } else if (role) {
  138. this.setData({
  139. roleShow: true
  140. })
  141. } else if (!role) {
  142. this.setData({
  143. roleShow: false
  144. })
  145. return;
  146. }
  147. if (!wx.getStorageSync('companyName')) {
  148. wx.showToast({
  149. title: '请选择货主',
  150. icon: 'error'
  151. });
  152. return;
  153. }
  154. await this.initData({
  155. current: 0
  156. });
  157. this.setData({
  158. loading: false
  159. })
  160. },
  161. async initData(d) {
  162. if (!this.data.roleShow) {
  163. return;
  164. }
  165. let userInfo = wx.getStorageSync('userInfo');
  166. this.setData({
  167. current: this.data.current + 1,
  168. loadding: true
  169. });
  170. let {
  171. data
  172. } = await app.ajax.get({
  173. url: `/admin/bxdordercheck/queryByMini`,
  174. data: {
  175. checkUserId: userInfo.userId,
  176. checkStatus: this.data.statusAdminList[this.data.checkStatus].id,
  177. checkNumber: this.data.checkNumber,
  178. orderTimeStart: this.data.orderTimeStart ? this.data.orderTimeStart + ' 00:00:00' : '',
  179. orderTimeEnd: this.data.orderTimeEnd ? this.data.orderTimeEnd + ' 23:59:59' : '',
  180. current: d && d.current != undefined ? d.current : this.data.current,
  181. size: 20,
  182. }
  183. });
  184. this.setData({
  185. current: this.data.current,
  186. orderList: this.data.orderList.concat(data.data.records),
  187. pages: data.data.pages || null,
  188. loadding: false
  189. })
  190. // admin/bxdorder/query?activityImgs=&companyId=56&companyName=HZRCS&createTime=&current=1&desc=create_time&mobile=&orderCheckNumber=&orderNumber=&orderSaleName&receiverName=&size=10&status=
  191. },
  192. async queryData(e) {
  193. this.setData({
  194. orderList: [],
  195. checkStatus: 0
  196. })
  197. await this.initData({
  198. current: 0
  199. });
  200. },
  201. chooseQuery(e) {
  202. if (this.data.queryIndex == e.currentTarget.dataset.index) {
  203. return;
  204. }
  205. this.setData({
  206. checkNumber: "", //订单编号
  207. dvyFlowId: "", //快递单号
  208. picTitle: "", //商品名称
  209. orderTimeStart: "",
  210. orderTimeEnd: "",
  211. valueText: "",
  212. })
  213. this.setData({
  214. queryShow: !this.data.queryShow
  215. })
  216. },
  217. chooseQueryItem(e) {
  218. if (this.data.queryIndex == e.currentTarget.dataset.index) {
  219. return;
  220. }
  221. this.setData({
  222. checkNumber: "", //订单编号
  223. dvyFlowId: "", //快递单号
  224. picTitle: "", //商品名称
  225. orderTimeStart: "",
  226. orderTimeEnd: "",
  227. valueText: "",
  228. })
  229. this.setData({
  230. queryShow: !this.data.queryShow,
  231. queryIndex: e.currentTarget.dataset.index
  232. })
  233. },
  234. async changeTabbar(e, a) {
  235. if (this.data.checkStatus == e.detail.index) {
  236. return;
  237. }
  238. this.setData({
  239. orderList: [],
  240. current: 0,
  241. checkStatus: e.detail.index
  242. })
  243. await this.initData(0);
  244. },
  245. bindinputchange(e) {
  246. this.setData({
  247. valueText: e.detail.value,
  248. [e.currentTarget.dataset.name]: e.detail.value
  249. })
  250. },
  251. bindchange1(e) {
  252. this.setData({
  253. orderTimeStart: e.detail.value
  254. })
  255. },
  256. bindchange2(e) {
  257. this.setData({
  258. orderTimeEnd: e.detail.value
  259. })
  260. },
  261. cleanDate(e) {
  262. this.setData({
  263. checkNumber: "", //订单编号
  264. dvyFlowId: "", //快递单号
  265. picTitle: "", //商品名称
  266. orderTimeStart: "",
  267. orderTimeEnd: "",
  268. valueText: "",
  269. })
  270. },
  271. async approve(e) {
  272. let row = e.currentTarget.dataset.item;
  273. await app.ajax.post({
  274. url: "/admin/bxdordercheck/audit",
  275. data: {
  276. checkId: row.checkId,
  277. checkReason: "小程序端快速审核通过",
  278. checkStatus: 1,
  279. companyId: row.companyId,
  280. companyName: row.companyName,
  281. }
  282. });
  283. setTimeout(async () => {
  284. wx.showToast({
  285. title: '审核通过成功',
  286. });
  287. }, 200);
  288. this.setData({
  289. orderList: [],
  290. current: 0
  291. })
  292. let that = this;
  293. setTimeout(async () => {
  294. await that.initData();
  295. }, 1000);
  296. },
  297. async approve2(e) {
  298. let row = e.currentTarget.dataset.item;
  299. let that = this;
  300. wx.showModal({
  301. // title: '提示',
  302. title: `确认终止订单(${row.checkNumber})吗?`,
  303. editable: true,
  304. placeholderText: "请输入终止订单原因",
  305. complete: async (res) => {
  306. if (res.confirm) {
  307. if (!res.content) {
  308. wx.showToast({
  309. title: '请填写终止订单原因!',
  310. icon: "none"
  311. })
  312. return;
  313. }
  314. await app.ajax.post({
  315. url: "/admin/bxdordercheck/audit",
  316. data: {
  317. checkId: row.checkId,
  318. checkReason: res.content,
  319. checkStatus: 2,
  320. }
  321. });
  322. setTimeout(async () => {
  323. wx.showToast({
  324. title: '中止订单成功',
  325. });
  326. }, 200);
  327. that.setData({
  328. orderList: [],
  329. current: 0
  330. })
  331. setTimeout(async () => {
  332. await that.initData();
  333. }, 1000);
  334. }
  335. }
  336. })
  337. },
  338. toLogin() {
  339. wx.navigateTo({
  340. url: '/pages/login/login',
  341. })
  342. },
  343. /**
  344. * 生命周期函数--监听页面隐藏
  345. */
  346. onHide() {
  347. this.setData({
  348. pageHide: true
  349. })
  350. },
  351. /**
  352. * 生命周期函数--监听页面卸载
  353. */
  354. onUnload() {
  355. this.setData({
  356. pageHide: false
  357. })
  358. },
  359. /**
  360. * 页面相关事件处理函数--监听用户下拉动作
  361. */
  362. onPullDownRefresh() {
  363. },
  364. /**
  365. * 页面上拉触底事件的处理函数
  366. */
  367. onReachBottom() {
  368. },
  369. /**
  370. * 用户点击右上角分享
  371. */
  372. onShareAppMessage() {
  373. }
  374. })