confirmrefund.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. // pages/confirmrefund/confirmrefund.js
  2. const app = getApp();
  3. const api = require('../../api/api');
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. navbarData: {
  10. showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
  11. title: '退款申请', //导航栏 中间的标题
  12. capsuleMode: 'navBack', //显示模式(navBack:返回上一页;navHome:返回首页)
  13. },
  14. id: 0, //订单id
  15. billdata: {},
  16. show: false,
  17. refund_reason: '', //退款原因
  18. refund_voucher: '', //凭证
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad(options) {
  24. this.setData({
  25. id: Number(options.id)
  26. })
  27. },
  28. /**
  29. * 生命周期函数--监听页面初次渲染完成
  30. */
  31. onReady() {
  32. },
  33. /**
  34. * 生命周期函数--监听页面显示
  35. */
  36. onShow() {
  37. let that = this;
  38. wx.showLoading({
  39. title: '加载中',
  40. mask: true
  41. })
  42. wx.request({
  43. url: api.ReturnGoods_info,
  44. header: {
  45. 'Authorization': wx.getStorageSync('token')
  46. },
  47. data: {
  48. id: that.data.id
  49. },
  50. method: 'POST',
  51. success(res) {
  52. console.log(res);
  53. if (res.data.code === 1) {
  54. that.setData({
  55. billdata: res.data.data
  56. })
  57. } else {
  58. wx.showToast({
  59. title: res.data.msg,
  60. mask: true,
  61. icon: 'none'
  62. })
  63. }
  64. },
  65. fail(err) {
  66. wx.showToast({
  67. title: '发起网络请求失败',
  68. icon: 'none',
  69. mask: true
  70. })
  71. },
  72. complete() {
  73. wx.hideLoading()
  74. }
  75. })
  76. },
  77. /**
  78. * 生命周期函数--监听页面隐藏
  79. */
  80. onHide() {
  81. },
  82. /**
  83. * 生命周期函数--监听页面卸载
  84. */
  85. onUnload() {
  86. },
  87. /**
  88. * 页面相关事件处理函数--监听用户下拉动作
  89. */
  90. onPullDownRefresh() {
  91. },
  92. /**
  93. * 页面上拉触底事件的处理函数
  94. */
  95. onReachBottom() {
  96. },
  97. /**
  98. * 用户点击右上角分享
  99. */
  100. onShareAppMessage() {
  101. },
  102. // 撤销退款
  103. cheXiaoApply() {
  104. let that = this;
  105. wx.showLoading({
  106. title: '加载中',
  107. mask: true
  108. })
  109. wx.request({
  110. url: api.Order_refund_revoke,
  111. header: {
  112. 'Authorization': wx.getStorageSync('token')
  113. },
  114. data: {
  115. id: that.data.id
  116. },
  117. method: 'POST',
  118. success(res) {
  119. console.log(res);
  120. wx.hideLoading()
  121. if (res.data.code === 1) {
  122. wx.showToast({
  123. title: '操作成功',
  124. mask: true,
  125. success() {
  126. setTimeout(() => {
  127. wx.reLaunch({
  128. url: '/pages/index/index',
  129. })
  130. }, 1500)
  131. }
  132. })
  133. } else {
  134. wx.showToast({
  135. title: res.data.msg,
  136. mask: true,
  137. icon: 'none'
  138. })
  139. }
  140. },
  141. fail(err) {
  142. wx.hideLoading()
  143. wx.showToast({
  144. title: '发起网络请求失败',
  145. icon: 'none',
  146. mask: true
  147. })
  148. },
  149. complete() {
  150. // wx.hideLoading()
  151. }
  152. })
  153. },
  154. copy() {
  155. wx.setClipboardData({
  156. data: this.data.billdata.refund_number,
  157. })
  158. },
  159. callHead() {
  160. wx.makePhoneCall({
  161. phoneNumber: this.data.billdata.phone,
  162. })
  163. },
  164. // 修改申请
  165. modifyApply() {
  166. this.setData({
  167. show: true
  168. })
  169. },
  170. onClose() {
  171. this.setData({
  172. show: false
  173. })
  174. },
  175. // 输入退款原因
  176. inputReason(e) {
  177. this.setData({
  178. refund_reason: e.detail.value
  179. })
  180. },
  181. // 上传退款凭证
  182. uploadVoucher() {
  183. let that = this;
  184. // wx.showLoading({
  185. // title: '文件上传中',
  186. // mask: true
  187. // })
  188. wx.request({
  189. url: api.getSignedUrl,
  190. data: {
  191. type: 'image'
  192. },
  193. success: (oss) => {
  194. console.log(oss);
  195. wx.chooseMedia({
  196. count: 1,
  197. mediaType: ['image'],
  198. success: (img) => {
  199. console.log(img);
  200. let key = "image/" + new Date().getTime() + Math.floor(Math.random() * 150) + '.png';
  201. wx.showLoading({
  202. title: '文件上传中',
  203. mask: true
  204. })
  205. wx.uploadFile({
  206. filePath: img.tempFiles[0].tempFilePath,
  207. name: 'file',
  208. url: 'https://' + oss.data.data.host, //输入你的bucketname.endpoint
  209. formData: {
  210. key: key,
  211. policy: oss.data.data.policy, // 输入你获取的的policy
  212. OSSAccessKeyId: oss.data.data.OSSAccessKeyId, // 输入你的AccessKeyId
  213. success_action_status: '200', // 让服务端返回200,不然,默认会返回204
  214. signature: oss.data.data.Signature, // 输入你获取的的signature
  215. },
  216. success: (res) => {
  217. if (res.statusCode == 200) {
  218. let src = 'https://' + oss.data.data.host + '/' + key;
  219. that.setData({
  220. refund_voucher: src
  221. })
  222. }
  223. },
  224. fail: (err) => {
  225. console.log(err);
  226. },
  227. complete: () => {
  228. wx.hideLoading()
  229. }
  230. })
  231. },
  232. fail: (err) => {
  233. wx.hideLoading()
  234. }
  235. })
  236. },
  237. fail: (err) => {
  238. console.log(err);
  239. }
  240. })
  241. },
  242. // 确认修改
  243. confirmModify() {
  244. let that = this;
  245. wx.showLoading({
  246. title: '加载中',
  247. mask: true
  248. })
  249. wx.request({
  250. url: api.Order_edit_refund,
  251. header: {
  252. 'Authorization': wx.getStorageSync('token')
  253. },
  254. method: 'POST',
  255. data: {
  256. id: that.data.billdata.id,
  257. refund_reason: that.data.refund_reason,
  258. refund_voucher: that.data.refund_voucher
  259. },
  260. success(res) {
  261. wx.hideLoading()
  262. console.log(res);
  263. if (res.data.code === 1) {
  264. wx.showToast({
  265. title: '修改成功',
  266. mask: true,
  267. success() {
  268. setTimeout(()=>{
  269. wx.reLaunch({
  270. url: '/pages/index/index',
  271. })
  272. }, 1500)
  273. }
  274. })
  275. } else {
  276. wx.showToast({
  277. title: res.data.msg,
  278. mask: true,
  279. icon: 'none'
  280. })
  281. }
  282. },
  283. fail(err) {
  284. wx.hideLoading()
  285. wx.showToast({
  286. title: '发起网络请求失败',
  287. icon: 'none',
  288. mask: true
  289. })
  290. },
  291. complete() {
  292. // wx.hideLoading()
  293. }
  294. })
  295. }
  296. })