DetailsOfRefund.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. // pages/DetailsOfRefund/DetailsOfRefund.js
  2. var http = require('../../utils/http.js');
  3. var util = require('../../utils/util.js');
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. showView: true, //隐藏是展示
  10. applyTime: '', //申请时间
  11. applyType: 1, //申请类型:1,仅退款,2退款退货
  12. dvyType: 1, //配送类型 1:快递 2:自提 3:及时配送
  13. isReturnLogistics: false, //配送类型 1:快递 2:自提 3:及时配送
  14. goodsNum: '', //退货数量
  15. handelTime: '', //卖家处理时间
  16. orderAmount: '', //订单总金额
  17. orderItems: {}, //订单项
  18. refundAmount: '', //退款金额
  19. goodsTotal:0,
  20. records:[],//退款流程
  21. offsetPoints:0,//退还积分
  22. refundExpiredScore:0,//过期积分
  23. freightAmount:0,
  24. refundStatusObj:{
  25. 1:'申请原因',
  26. 2:'商家待审核',
  27. 3:'审核通过',
  28. 4:'驳回',
  29. 5:'退款成功',
  30. },
  31. refundDelivery: [], //收货地址对象
  32. refundId: '', //记录ID
  33. refundTime: '', //退款时间
  34. returnMoneySts: 1, //处理退款状态:(1.买家申请 2.卖家接受 3.买家发货 4.卖家收货 5.退款成功 6.买家撤回申请 7.商家拒绝 -1.退款关闭)
  35. updateTime: '', //更新时间
  36. refundSn: '', //退款编号
  37. rejectMessage: '', //拒绝理由
  38. buyerReason: '', //退款原因
  39. shopName: '', //店铺名称
  40. refundScore: 0, // 退款积分
  41. photoFiles:[],
  42. refundPhotoFiles:[],//退货物流图片
  43. addCarshow: false,
  44. selectTimeshow: false,
  45. flowShow: false,
  46. userAddrDto: {},
  47. payer: '',
  48. sendPay:'',
  49. sts: 0,
  50. nomDay: '',
  51. tomorrowDay: '',
  52. timeIntervals: [],
  53. columns: [],
  54. selectTimeshow: false,
  55. time: '',//取件时间
  56. userAddr: '',//取件地址
  57. sendInfo: {},
  58. currentSelectedIndex: -1, // 初始没有选中项,索引设为 -1
  59. cancelPay: false,
  60. remainingTime: '',
  61. timeFormat: '',
  62. orderNumSend:'',
  63. countdown_hours:'',
  64. countdown_minutes:'',
  65. statusObj:{
  66. 10:{
  67. title:'待审核',
  68. desc:'等待商家处理申请'
  69. },
  70. 20:{
  71. title:'处理中',
  72. desc:'申请通过后,将退回至原账户'
  73. },
  74. 30:{
  75. title:'驳回退款',
  76. desc:'您的申请已被商家拒绝'
  77. },
  78. 40:{
  79. title:'撤销退款',
  80. desc:'您已主动取消退款申请,如有需要可再次申请。'
  81. },
  82. 60:{
  83. title:'待退货',
  84. desc:''
  85. },
  86. 65:{
  87. title:'待确认收货',
  88. desc:'待商家收到商品,并确认不影响二次销售后,将为您退款'
  89. },
  90. 70:{
  91. title:'退款完成',
  92. desc:'申请已通过,已退回至原账户'
  93. },
  94. }
  95. },
  96. /**
  97. * 生命周期函数--监听页面加载
  98. */
  99. onLoad(options) {
  100. this.setData({
  101. orderNumSend:options.orderNumber
  102. })
  103. this.setData({
  104. refundSn: options.refundSn,
  105. });
  106. if(options.userAddrDto){
  107. this.setData({
  108. userAddrDto: JSON.parse(options.userAddrDto)
  109. })
  110. }
  111. //获取退款申请详情
  112. this.getRefundDetail()
  113. },
  114. /**
  115. * 获取退款申请详情
  116. */
  117. getRefundDetail: function (e) {
  118. var ths = this;
  119. // wx.showLoading({})
  120. var params = {
  121. url: "/p/orderRefund/info",
  122. method: "GET",
  123. data: {
  124. refundSn: this.data.refundSn //退款编号
  125. },
  126. callBack: function (res) {
  127. let img=''
  128. res.orderItems.map(item=>{
  129. img=item.pic.split(',')
  130. item.pic=img[0]
  131. })
  132. let photoFiles = []
  133. let refundPhotoFiles = []
  134. if(res.photoFiles){
  135. photoFiles = res.photoFiles.split(',')
  136. }
  137. if(res.refundDelivery.imgs){
  138. refundPhotoFiles = res.refundDelivery.imgs.split(',')
  139. }
  140. ths.setData({
  141. applyTime: res.applyTime, //申请时间
  142. applyType: res.applyType, //申请类型:1,仅退款,2退款退货
  143. dvyType: res.dvyType, //配送类型 1:快递 2:自提 3:及时配送
  144. isReturnLogistics: res.isReturnLogistics, //配送类型 1:快递 2:自提 3:及时配送
  145. goodsNum: res.goodsNum, //退货数量
  146. handelTime: res.handelTime, //卖家处理时间
  147. orderAmount: res.orderAmount, //订单总金额
  148. orderItems: res.orderItems, //订单项
  149. orderNumber: res.orderNumber, //订单项
  150. refundSn: res.refundSn, //退款编号
  151. refundAmount: res.refundAmount, //实际退款金额
  152. goodsTotal:res.goodsTotal,//总共退款价值
  153. records:res.records,//退款流程
  154. offsetPoints:res.offsetPoints,//退还积分
  155. refundExpiredScore:res.refundExpiredScore,//过期积分
  156. freightAmount:res.freightAmount,
  157. refundDelivery: res.refundDelivery, //收货地址对象
  158. refundId: res.refundId, //记录ID
  159. refundTime: res.refundTime, //退款时间
  160. returnMoneySts: res.returnMoneySts, //处理退款状态:(1.买家申请 2.卖家接受 3.买家发货 4.卖家收货 5.退款成功 6.买家撤回申请 7.商家拒绝 -1.退款关闭)
  161. updateTime: res.updateTime, //更新时间
  162. rejectMessage: res.rejectMessage, //拒绝理由
  163. buyerReason: res.buyerReason, //退款原因
  164. photoFiles, //图片
  165. refundPhotoFiles,//退款图片
  166. shopName: res.shopName,
  167. refundScore: res.refundScore, // 退款积分
  168. payer: res.refundDelivery.payer,//运费承担方
  169. sendPay:res.refundDelivery.deyNu //物流编号,判断是否提交成功
  170. })
  171. wx.hideLoading();
  172. ths.get_countDown()
  173. }
  174. };
  175. http.request(params);
  176. },
  177. // 一键复制事件
  178. copyBtn: function(e) {
  179. let data = e.currentTarget.dataset.value
  180. wx.setClipboardData({
  181. //准备复制的数据
  182. data,
  183. success: function(res) {
  184. wx.showToast({
  185. title: '复制成功',
  186. });
  187. }
  188. })
  189. },
  190. /**
  191. * 选择时间和地址
  192. */
  193. choose(e){
  194. let type = e.currentTarget.dataset.type
  195. if(type == 'time'){
  196. this.getDayTime()
  197. this.getTime()
  198. let day = []
  199. day.push({
  200. id: 1,
  201. text: this.data.nomDay
  202. }, {
  203. id: 2,
  204. text: this.data.tomorrowDay
  205. })
  206. let data = []
  207. data.push({
  208. values: day,
  209. className: 'column1',
  210. }, {
  211. values: this.data.timeIntervals,
  212. defaultIndex: 2,
  213. className: 'column2',
  214. })
  215. this.setData({
  216. selectTimeshow: true,
  217. columns: data
  218. })
  219. }else{//选择地址
  220. wx.navigateTo({
  221. url: '/pages/delivery-address/delivery-address?order=write',
  222. })
  223. }
  224. },
  225. onCancel: function () {
  226. this.setData({
  227. selectTimeshow: false
  228. })
  229. },
  230. onConfirm(event) {
  231. const {
  232. picker,
  233. value,
  234. index
  235. } = event.detail;
  236. var currentDate = new Date();
  237. var currentYear = currentDate.getFullYear();
  238. if (value.length >= 2) {
  239. const text1 = value[0].text; //text1为12月25日
  240. const text2 = value[1].text.slice(0, 5); //text2为15:00
  241. const month = ("0" + (parseInt(text1.split("月")[0]))).slice(-2); // 将中文月格式转换为数字(注意要减1,因为月份是从0开始计数),并补0
  242. const day = text1.split("月")[1].split("日")[0];
  243. const hour = text2.split(":")[0];
  244. const minute = text2.split(":")[1];
  245. const combinedText = `${currentYear}-${month}-${day} ${hour}:${minute}:00`;
  246. let dateObj = new Date(combinedText);
  247. let timestamp = Math.floor(dateObj.getTime() / 1000);
  248. // 获取配送费
  249. let that = this
  250. console.log(combinedText);
  251. this.setData({
  252. time: combinedText,
  253. selectTimeshow: false
  254. });
  255. }
  256. },
  257. // 获取今明天并转换
  258. getDayTime: function () {
  259. const today = new Date();
  260. const month = (today.getMonth() + 1).toString().padStart(2, '0');
  261. const day = today.getDate().toString().padStart(2, '0');
  262. const todayFormat = `${month}月${day}日(今天)`;
  263. const tomorrow = new Date(today.getTime() + 24 * 60 * 60 * 1000);
  264. const tomorrowMonth = (tomorrow.getMonth() + 1).toString().padStart(2, '0');
  265. const tomorrowDay = tomorrow.getDate().toString().padStart(2, '0');
  266. const tomorrowFormat = `${tomorrowMonth}月${tomorrowDay}日(明天)`;
  267. this.setData({
  268. nomDay: todayFormat,
  269. tomorrowDay: tomorrowFormat
  270. })
  271. },
  272. // 时间段转换
  273. getTime: function (selectedDate) {
  274. const timeIntervals = [];
  275. // 如果没有传入日期参数(首次加载等情况),则使用当前日期
  276. const now = selectedDate ? new Date(selectedDate) : new Date();
  277. if (isNaN(now.getTime())) {
  278. console.error('传入的日期格式不正确,无法解析为有效日期');
  279. return;
  280. }
  281. const currentTimeStamp = now.getTime();
  282. for (let hour = 0; hour < 23; hour++) {
  283. const start = hour.toString().padStart(2, '0') + ':00';
  284. const end = (hour + 1).toString().padStart(2, '0') + ':00';
  285. const interval = start + '~' + end;
  286. // 创建对应时间段开始时间的日期对象
  287. const startDate = new Date(now);
  288. startDate.setHours(hour, 0, 0, 0);
  289. const startTimestamp = startDate.getTime();
  290. // 通过比较时间戳来判断时间段是否已过去
  291. const hidden = startTimestamp < currentTimeStamp;
  292. timeIntervals.push({
  293. text: interval,
  294. disabled: hidden
  295. });
  296. }
  297. this.setData({
  298. timeIntervals
  299. });
  300. },
  301. // 日期转换方法
  302. convertDateToNumber: function (dateStr) {
  303. if (!dateStr) {
  304. throw new Error('日期字符串不能为空');
  305. }
  306. dateStr = dateStr.trim();
  307. let parts = dateStr.match(/(\d+)月(\d+)日/);
  308. if (!parts) {
  309. throw new Error('日期格式不正确,请按照XX月XX日的格式输入');
  310. }
  311. return new Date(2024, parseInt(parts[1]) - 1, parseInt(parts[2]));
  312. },
  313. /**
  314. * 填写快递信息
  315. */
  316. writeInfo(e){
  317. var refundSn = e.currentTarget.dataset.refundsn;
  318. var type = e.currentTarget.dataset.type;
  319. wx.navigateTo({
  320. url: `/pages/writeReturnLogistics/writeReturnLogistics?refundSn=${refundSn}&shopId=${this.data.refundDelivery.shopId}&type=${type}`,
  321. })
  322. },
  323. /**
  324. * 生命周期函数--监听页面初次渲染完成
  325. */
  326. onReady() {
  327. },
  328. /**
  329. * 生命周期函数--监听页面显示
  330. */
  331. onShow() {
  332. },
  333. /**
  334. * 生命周期函数--监听页面隐藏
  335. */
  336. onHide() {
  337. },
  338. /**
  339. * 生命周期函数--监听页面卸载
  340. */
  341. onUnload() {
  342. },
  343. /**
  344. * 页面相关事件处理函数--监听用户下拉动作
  345. */
  346. onPullDownRefresh() {
  347. },
  348. /**
  349. * 页面上拉触底事件的处理函数
  350. */
  351. onReachBottom() {
  352. },
  353. /**
  354. * 用户点击右上角分享
  355. */
  356. onShareAppMessage() {
  357. }
  358. })