DetailsOfRefund.js 9.9 KB

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