refund-page.js 6.3 KB

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