You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

exchangeDetail.js 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. import Api from "../../../api/index.js"
  2. import { requestFnc } from "../../../utils/request.js"
  3. import { getStore, formatDate, dateFtt } from "../../../utils/index.js"
  4. import {
  5. orderStatusMap,
  6. afterTypeMap,
  7. courierCompanyList,
  8. vehicleTypeMap,
  9. plateColorToColorMap,
  10. afterSalesTypeMap,
  11. } from "../../../utils/systemConstant"
  12. Page({
  13. data: {
  14. current: 1,
  15. showReback: false,
  16. courierNo: "",
  17. company: "",
  18. courierCompany: "",
  19. showCompany: false,
  20. companyList: courierCompanyList,
  21. orderType: "", // 新办、售后
  22. afterType: "", // 退、换、补
  23. orderStatus: "", //
  24. reasonText: "",
  25. isLoading: false,
  26. sendType: "1",
  27. expressName: "线上快递邮寄",
  28. showNetWork: false,
  29. selectAddr: false,
  30. branchNoDetail: "",
  31. branchName: "",
  32. branchAddress: "",
  33. latitude: "",
  34. longitude: "",
  35. branchNo: "",
  36. branchWorktime: "",
  37. branchLinkPhone: "",
  38. branchLabel: "",
  39. netWorkArea: {},
  40. },
  41. onLoad: function (options) {
  42. const afterType = getStore("afterType")
  43. const orderStatus = getStore("orderStatus")
  44. let orderTypeText = orderStatusMap.get(orderStatus + "")
  45. let showTip = false
  46. let statusTag = "1"
  47. let current = 1
  48. if (
  49. orderStatus == "1" ||
  50. orderStatus == "7" ||
  51. orderStatus == "8" ||
  52. orderStatus == "9"
  53. ) {
  54. current = 2
  55. } else if (
  56. orderStatus == "2" ||
  57. orderStatus == "3" ||
  58. orderStatus == "10"
  59. ) {
  60. current = 3
  61. } else if (orderStatus == "11" || orderStatus == "4") {
  62. current = 4
  63. } else if (
  64. orderStatus == "12" ||
  65. orderStatus == "13" ||
  66. orderStatus == "14" ||
  67. orderStatus == "6" ||
  68. orderStatus == "15"
  69. ) {
  70. current = 6
  71. statusTag = "3"
  72. }
  73. if (orderStatus == "3") {
  74. // 审核不通过
  75. showTip = true
  76. statusTag = "2"
  77. }
  78. console.log("当前 current ---", current, orderStatus)
  79. let btnName = "返回首页"
  80. if (
  81. (afterType == "7" && orderStatus == "13") ||
  82. (afterType == "9" && orderStatus == "14")
  83. ) {
  84. // 换补完成
  85. btnName = "激活"
  86. }
  87. const businessType = afterTypeMap.get(afterType) + "申请"
  88. const afterOrderType = afterSalesTypeMap.get(getStore("afterOrderType"))
  89. console.log("设备类型 ----", afterOrderType)
  90. this.setData({
  91. orderType: getStore("orderType"),
  92. orderStatus,
  93. afterType,
  94. current,
  95. orderTypeText,
  96. showTip,
  97. statusTag,
  98. btnName,
  99. businessType,
  100. afterOrderType,
  101. })
  102. if ((afterType == "7" || afterType == "8") && orderStatus == "10") {
  103. this.setData({
  104. showReback: true,
  105. })
  106. this.getRebackAddress()
  107. }
  108. this.getOrderDetail()
  109. },
  110. // 打开腾讯地图
  111. goMap() {
  112. let params = {
  113. branchName: this.data.branchName,
  114. branchAddress: this.data.branchAddress,
  115. branchWorktime: this.data.branchWorktime,
  116. branchLinkPhone: this.data.branchLinkPhone,
  117. branchLabel: this.data.branchLabel,
  118. latitude: Number(this.data.latitude),
  119. longitude: Number(this.data.longitude),
  120. }
  121. wx.navigateTo({
  122. url: "plugin://issuer-plugin/map?params=" + JSON.stringify(params),
  123. })
  124. },
  125. // 选择网点
  126. selectNetWork(e) {
  127. let { network = {}, address = {} } = e.detail
  128. this.setData({
  129. branchName: network.branchName,
  130. branchAddress: network.addr,
  131. latitude: network.latitude,
  132. longitude: network.longitude,
  133. branchNo: network.branchNo,
  134. branchWorktime: network.branchTime,
  135. branchLinkPhone: network.branchPhone,
  136. branchLabel: network.label,
  137. showNetWork: false,
  138. selectAddr: true,
  139. netWorkArea: address,
  140. })
  141. },
  142. deleteImg(event) {
  143. const index = event.detail.index
  144. const files = Object.assign(this.data.fileList)
  145. files.splice(index, 1)
  146. console.log("删除图片 ---", event, index, files)
  147. this.setData({
  148. fileList: files,
  149. })
  150. },
  151. tap() {
  152. this.setData({
  153. showCompany: true,
  154. })
  155. },
  156. onCancel() {
  157. this.setData({
  158. showCompany: false,
  159. })
  160. },
  161. onConfirm(e) {
  162. console.log("确认公司 --", e)
  163. this.setData({
  164. showCompany: false,
  165. company: e.detail.value.text,
  166. courierCompany: e.detail.value.value,
  167. })
  168. },
  169. getRebackAddress() {
  170. let params = {
  171. filename: Api.getRebackAddress.filename,
  172. data: {
  173. openId: getStore("openId"),
  174. plateNum: getStore("plateNum"),
  175. plateColor: getStore("plateColor"),
  176. },
  177. }
  178. requestFnc(Api.getRebackAddress.url, params, (res) => {
  179. console.log("获取地址 ---", res)
  180. this.setData({
  181. rebackAddress:
  182. res.provinceName +
  183. res.cityName +
  184. res.areaName +
  185. res.address,
  186. reLinkPhone: res.linkPhone,
  187. reLinkman: res.linkman,
  188. })
  189. cb && cb()
  190. })
  191. },
  192. getOrderDetail() {
  193. let params = {
  194. filename: Api.getOrderDetail.filename,
  195. data: {
  196. accessToken: getStore("accessToken"),
  197. accountId: getStore("accountId"),
  198. priOrderNo: getStore("appOrderNo"),
  199. },
  200. }
  201. requestFnc(Api.getOrderDetail.url, params, (res) => {
  202. console.log("获取订单详情 ---", res)
  203. const {
  204. plateNum,
  205. plateColor,
  206. address,
  207. auditRemark,
  208. linkman,
  209. linkName,
  210. linkPhone,
  211. orderNo,
  212. orderTime,
  213. orderDealReasonDesc,
  214. orderDealReason,
  215. branchNo,
  216. orderSendType,
  217. } = res
  218. this.setData({
  219. plateNum,
  220. plateColor,
  221. plateCar:
  222. plateNum +
  223. " 【" +
  224. plateColorToColorMap.get(plateColor + "") +
  225. "】",
  226. address,
  227. auditRemark,
  228. linkman: linkman || linkName,
  229. linkPhone,
  230. orderNo,
  231. orderTime: orderTime.replace("T", " "),
  232. orderDealReasonDesc,
  233. orderDealReason,
  234. branchNoDetail: branchNo,
  235. expressName:
  236. orderSendType == "1" ? "线上快递邮寄" : "线下网点自提",
  237. sendType: `${orderSendType}`,
  238. })
  239. this.getReason()
  240. })
  241. },
  242. getReason() {
  243. const afterType = getStore("afterType")
  244. let type = ""
  245. if (afterType == "7") {
  246. // 换货申请
  247. type = 3
  248. } else if (afterType == "8") {
  249. // 退货申请
  250. type = 2
  251. } else if (afterType == "9") {
  252. // 补货申请
  253. type = 4
  254. }
  255. let params = {
  256. filename: Api.getOffReason.filename,
  257. data: {
  258. accountId: getStore("accountId"),
  259. type,
  260. },
  261. }
  262. requestFnc(Api.getOffReason.url, params, (res) => {
  263. console.log("获取原因 ---", res, this.data.orderDealReason)
  264. let reasonText = res.find(
  265. (e) => e.code == this.data.orderDealReason
  266. )
  267. ? res.find((e) => e.code == this.data.orderDealReason).name
  268. : ""
  269. this.data.orderDealReason
  270. this.setData({
  271. reasonText,
  272. })
  273. })
  274. },
  275. submitAction() {
  276. const {
  277. remark,
  278. linkman,
  279. linkPhone,
  280. address,
  281. orderType,
  282. afterType,
  283. courierNo,
  284. courierCompany,
  285. afterOrderType,
  286. } = this.data
  287. if (!courierNo) {
  288. return wx.showToast({
  289. title: "请输入快递单号",
  290. icon: "none",
  291. duration: 2000,
  292. })
  293. }
  294. if (!courierCompany) {
  295. return wx.showToast({
  296. title: "请选择快递公司",
  297. icon: "none",
  298. duration: 2000,
  299. })
  300. }
  301. this.setData({
  302. isLoading: true,
  303. })
  304. let maintainType = ""
  305. if (afterType == "7") {
  306. // 换货
  307. maintainType = 6
  308. } else if (afterType == "8") {
  309. // 退货
  310. maintainType = 5
  311. } else if (afterType == "9") {
  312. // // 补货
  313. maintainType = 7
  314. }
  315. const para = {
  316. openId: getStore("wxOpenId"),
  317. accountId: getStore("accountId"),
  318. orderNo: getStore("orderNo"),
  319. maintainType,
  320. courierNo,
  321. courierCompany,
  322. }
  323. // wx.navigateTo({
  324. // url: "plugin://issuer-plugin/exchangeResult",
  325. // })
  326. // return
  327. if (orderType == "1") {
  328. // 新办
  329. let params = {
  330. filename: Api.maintainSaleOrder.filename,
  331. data: para,
  332. }
  333. requestFnc(
  334. Api.maintainSaleOrder.url,
  335. params,
  336. (res) => {
  337. console.log("新办工单维护 --- 接口返回 --", res)
  338. this.setData({
  339. isLoading: false,
  340. })
  341. wx.showModal({
  342. title: "提示",
  343. content:
  344. `${afterTypeMap.get(afterType)}完成` ||
  345. "" + "提交成功",
  346. showCancel: false,
  347. success: (res) => {
  348. if (res.confirm) {
  349. wx.reLaunch({
  350. url: getStore("redirectUrl"),
  351. })
  352. }
  353. },
  354. })
  355. },
  356. (msg) => {
  357. this.setData({
  358. isLoading: false,
  359. })
  360. }
  361. )
  362. } else if (orderType == "2") {
  363. // 售后
  364. let params = {
  365. filename: Api.maintainAfterSaleOrder.filename,
  366. data: para,
  367. }
  368. requestFnc(
  369. Api.maintainAfterSaleOrder.url,
  370. params,
  371. (res) => {
  372. console.log("售后工单维护 ---接口返回 --", res)
  373. this.setData({
  374. isLoading: false,
  375. })
  376. wx.showModal({
  377. title: "提示",
  378. content: afterTypeMap.get(afterType) || "" + "提交成功",
  379. showCancel: false,
  380. success: (res) => {
  381. if (res.confirm) {
  382. wx.reLaunch({
  383. url: getStore("redirectUrl"),
  384. })
  385. }
  386. },
  387. })
  388. },
  389. (msg) => {
  390. this.setData({
  391. isLoading: false,
  392. })
  393. }
  394. )
  395. }
  396. },
  397. backHome() {
  398. const { afterType, orderStatus } = this.data
  399. if (
  400. (afterType == "7" && orderStatus == "13") ||
  401. (afterType == "9" && orderStatus == "14")
  402. ) {
  403. // 换补完成
  404. wx.navigateTo({
  405. url: "plugin://issuer-plugin/device-act-guidance?type=afterSale",
  406. })
  407. } else {
  408. wx.reLaunch({
  409. url: getStore("redirectUrl"),
  410. })
  411. }
  412. },
  413. })