refund-page.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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. console.log(data);
  105. if (data.code == 200) {
  106. that.data.dataimg.push(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. }else{
  186. wx.showToast({
  187. title: res.data.msg,
  188. icon: 'none',
  189. duration: 2000
  190. })
  191. }
  192. },
  193. fail: function (res) {
  194. console.log('submit fail');
  195. }
  196. });
  197. }
  198. },
  199. /**
  200. * 生命周期函数--监听页面初次渲染完成
  201. */
  202. onReady: function () {
  203. },
  204. bindPickerChange: function (e) {
  205. this.setData({
  206. index: e.detail.value
  207. })
  208. },
  209. /**
  210. * 生命周期函数--监听页面显示
  211. */
  212. onShow: function () {
  213. },
  214. /**
  215. * 生命周期函数--监听页面隐藏
  216. */
  217. onHide: function () {
  218. },
  219. /**
  220. * 生命周期函数--监听页面卸载
  221. */
  222. onUnload: function () {
  223. },
  224. /**
  225. * 页面相关事件处理函数--监听用户下拉动作
  226. */
  227. onPullDownRefresh: function () {
  228. },
  229. /**
  230. * 页面上拉触底事件的处理函数
  231. */
  232. onReachBottom: function () {
  233. },
  234. /**
  235. * 用户点击右上角分享
  236. */
  237. onShareAppMessage: function () {
  238. }
  239. })