refund-page.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. // pages/refund-page/refund-page.js
  2. var app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. url: app.globalData.urlImages,
  9. index: 0,
  10. orderId:'',
  11. dataimg:[],
  12. hidden:false,
  13. array: ["请选择", "招商银行实打实打算", "建设银行实打实大苏打", "农业银行实打实大苏打"],
  14. order:[]
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. app.setBarColor();
  21. app.setUserInfo();
  22. if (options.orderId){
  23. this.setData({
  24. orderId: options.orderId
  25. })
  26. this.getOrderContent();
  27. this.getRefundReason();
  28. } else {
  29. wx.showToast({
  30. title: '参数错误',
  31. icon: 'none',
  32. duration: 1000
  33. })
  34. setTimeout(function () {
  35. wx.navigateBack({ changed: true });
  36. }, 1200)
  37. }
  38. },
  39. getRefundReason:function(){
  40. var that = this;
  41. wx.request({
  42. url: app.globalData.url + '/routine/auth_api/get_refund_reason?uid=' + app.globalData.uid,
  43. method: 'get',
  44. success: function (res) {
  45. that.setData({
  46. array: res.data.data
  47. });
  48. },
  49. fail: function (res) {
  50. console.log('submit fail');
  51. },
  52. complete: function (res) {
  53. console.log('submit complete');
  54. }
  55. });
  56. },
  57. getOrderContent:function(){
  58. var that = this;
  59. wx.request({
  60. url: app.globalData.url + '/routine/auth_api/get_order?uid=' + app.globalData.uid,
  61. data: { uni: that.data.orderId },
  62. method: 'get',
  63. success: function (res) {
  64. wx.hideLoading();
  65. that.setData({
  66. order: res.data.data
  67. });
  68. },
  69. fail: function (res) {
  70. console.log('submit fail');
  71. },
  72. complete: function (res) {
  73. console.log('submit complete');
  74. }
  75. });
  76. },
  77. uploadpic: function (e) {
  78. var that = this;
  79. wx.chooseImage({
  80. count: 1, //最多可以选择的图片总数
  81. sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
  82. sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
  83. success: function (res) {
  84. // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
  85. var tempFilePaths = res.tempFilePaths;
  86. //启动上传等待中...
  87. wx.showLoading({
  88. title: '图片上传中',
  89. })
  90. var len = tempFilePaths.length;
  91. for (var i = 0; i < len; i++) {
  92. wx.uploadFile({
  93. url: app.globalData.url + '/routine/auth_api/upload?uid=' + app.globalData.uid,
  94. filePath: tempFilePaths[i],
  95. name: 'refund',
  96. formData: {
  97. 'filename': 'refund'
  98. },
  99. header: {
  100. "Content-Type": "multipart/form-data"
  101. },
  102. success: function (res) {
  103. wx.hideLoading();
  104. var data = JSON.parse(res.data);
  105. if (data.code == 200) {
  106. that.data.dataimg.push(app.globalData.url+data.data.url);
  107. }
  108. that.setData({
  109. dataimg: that.data.dataimg
  110. });
  111. var len2 = that.data.dataimg.length;
  112. if (len2 >= 3) {
  113. that.setData({
  114. hidden: true
  115. });
  116. }
  117. },
  118. fail: function (res) {
  119. wx.showToast({
  120. title: '上传图片失败',
  121. icon: 'none',
  122. duration: 2000
  123. })
  124. }
  125. });
  126. }
  127. }
  128. });
  129. },
  130. delImg:function(e){
  131. var that = this;
  132. that.data.dataimg.splice(e.target.dataset.index, 1);
  133. if (that.data.dataimg.length < 3) {
  134. that.setData({
  135. dataimg: that.data.dataimg,
  136. hidden: false
  137. })
  138. } else {
  139. that.setData({
  140. dataimg: that.data.dataimg
  141. })
  142. }
  143. wx.showToast({
  144. title: '删除成功',
  145. icon: 'success',
  146. duration: 2000
  147. })
  148. },
  149. subRefund:function(e){
  150. var that = this;
  151. wx.request({
  152. url: app.globalData.url + '/routine/auth_api/get_form_id?uid=' + app.globalData.uid,
  153. method: 'GET',
  154. data: {
  155. formId: e.detail.formId
  156. },
  157. success: function (res) { }
  158. })
  159. if (!that.data.index) {
  160. wx.showToast({
  161. title: '请选择退款原因',
  162. icon: 'none',
  163. duration: 2000
  164. })
  165. }else{
  166. var header = {
  167. 'content-type': 'application/x-www-form-urlencoded'
  168. };
  169. wx.request({
  170. url: app.globalData.url + '/routine/auth_api/apply_order_refund?uid=' + app.globalData.uid + '&uni=' + that.data.orderId,
  171. data: {
  172. text: that.data.array[that.data.index],
  173. refund_reason_wap_explain: e.detail.value.refund_reason_wap_explain,
  174. refund_reason_wap_img: that.data.dataimg
  175. },
  176. method: 'POST',
  177. header: header,
  178. success: function (res) {
  179. if (res.data.code == 200) {
  180. wx.showToast({
  181. title: '申请成功',
  182. icon: 'success',
  183. duration: 2000
  184. })
  185. setTimeout(function(){
  186. wx.navigateTo({
  187. url: '/pages/orders-con/orders-con?order_id=' + that.data.orderId
  188. })
  189. },1500)
  190. }else{
  191. wx.showToast({
  192. title: res.data.msg,
  193. icon: 'none',
  194. duration: 2000
  195. })
  196. }
  197. },
  198. fail: function (res) {
  199. console.log('submit fail');
  200. }
  201. });
  202. }
  203. },
  204. /**
  205. * 生命周期函数--监听页面初次渲染完成
  206. */
  207. onReady: function () {
  208. },
  209. bindPickerChange: function (e) {
  210. this.setData({
  211. index: e.detail.value
  212. })
  213. },
  214. /**
  215. * 生命周期函数--监听页面显示
  216. */
  217. onShow: function () {
  218. },
  219. /**
  220. * 生命周期函数--监听页面隐藏
  221. */
  222. onHide: function () {
  223. },
  224. /**
  225. * 生命周期函数--监听页面卸载
  226. */
  227. onUnload: function () {
  228. },
  229. /**
  230. * 页面相关事件处理函数--监听用户下拉动作
  231. */
  232. onPullDownRefresh: function () {
  233. },
  234. /**
  235. * 页面上拉触底事件的处理函数
  236. */
  237. onReachBottom: function () {
  238. },
  239. /**
  240. * 用户点击右上角分享
  241. */
  242. onShareAppMessage: function () {
  243. }
  244. })