initiate_refund.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. // pages/initiate_refund/initiate_refund.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. refundMsg:'',
  9. yesUrl: '../../assets/yes-copy@2x.png',
  10. noUrl: '../../assets/class_progress_yellow@3x.png',
  11. puzzleList: [
  12. {
  13. yesUrl: '../../assets/yes-copy@2x.png',
  14. noUrl: '../../assets/class_progress_yellow@3x.png',
  15. text: '家长发起退款',
  16. time: '17:00',
  17. noSend: ''
  18. },
  19. {
  20. yesUrl: '../../assets/yes-copy@2x.png',
  21. noUrl: '../../assets/class_progress_yellow@3x.png',
  22. text: '校长审核订单',
  23. time: '17:30',
  24. noSend: '待审核'
  25. },
  26. {
  27. yesUrl: '../../assets/yes-copy@2x.png',
  28. noUrl: '../../assets/class_progress_yellow@3x.png',
  29. text: '退款',
  30. time: '17:55',
  31. noSend: '未退款'
  32. },
  33. ],
  34. reasonList:[
  35. {
  36. txt:'辅导没达到预期效果'
  37. },
  38. {
  39. txt: '老师不适合'
  40. },
  41. {
  42. txt: '学生有其他安排,不上了'
  43. },
  44. {
  45. txt: '学校补课,没时间安排'
  46. },
  47. {
  48. txt: '其他'
  49. },
  50. ]
  51. },
  52. /**
  53. * 生命周期函数--监听页面加载
  54. */
  55. onLoad: function (options) {
  56. this.setData(options);
  57. },
  58. /**
  59. * 生命周期函数--监听页面初次渲染完成
  60. */
  61. onReady: function () {
  62. },
  63. /**
  64. * 生命周期函数--监听页面显示
  65. */
  66. onShow: function () {
  67. this.drawback();
  68. },
  69. /**
  70. * 生命周期函数--监听页面隐藏
  71. */
  72. onHide: function () {
  73. },
  74. /**
  75. * 生命周期函数--监听页面卸载
  76. */
  77. onUnload: function () {
  78. },
  79. /**
  80. * 页面相关事件处理函数--监听用户下拉动作
  81. */
  82. onPullDownRefresh: function () {
  83. },
  84. /**
  85. * 页面上拉触底事件的处理函数
  86. */
  87. onReachBottom: function () {
  88. },
  89. /**
  90. * 用户点击右上角分享
  91. */
  92. onShareAppMessage: function () {
  93. },
  94. // 退款信息
  95. drawback:function(){
  96. const { orderNo } = this.data;
  97. const postData = { fn: this.drawback, param: { ...arguments } }
  98. app.post('/api/parents/parents/applyOrderRefund', { orderNo }, 0, postData).then(res => {
  99. const { courseName, grade, refundPrice, totalCount, finishCount, totalPrice, costMoney, refundReason}=res.data
  100. this.setData({ courseName, grade, refundPrice, totalCount, finishCount, totalPrice, costMoney, refundReason})
  101. })
  102. },
  103. // 选择退款理由
  104. selectReason: function (e) {
  105. const { index, value } = e.currentTarget.dataset;
  106. this.setData({
  107. idx: index,
  108. refundMsg: value
  109. })
  110. },
  111. // 持卡人姓名
  112. cardName:function(e){
  113. const { value } = e.detail;
  114. if (value != '') {
  115. this.setData({ cardName: value })
  116. } else {
  117. wx.showToast({
  118. title: '姓名不能为空',
  119. icon: 'none'
  120. })
  121. return
  122. }
  123. },
  124. // 支行名
  125. subbranch:function(e){
  126. const { value } = e.detail;
  127. if (value != '') {
  128. this.setData({ subbranch: value })
  129. } else {
  130. wx.showToast({
  131. title: '支行名不能为空',
  132. icon: 'none'
  133. })
  134. return
  135. }
  136. },
  137. // 银行卡号码
  138. cardNum:function(e){
  139. // /^([1-9]{1})(\d{14}|\d{18})$/;
  140. const cardExp = /^\d{15,20}$/
  141. const { value } = e.detail;
  142. if (value != '') {
  143. if (!cardExp.test(value)) {
  144. wx.showToast({
  145. title: '银行卡位数不对',
  146. icon: 'none'
  147. })
  148. this.setData({ cardNum: value })
  149. return
  150. }else{
  151. this.setData({cardNum: value })
  152. return
  153. }
  154. }else{
  155. wx.showToast({
  156. title: '银行卡号不能为空',
  157. icon: 'none'
  158. })
  159. }
  160. },
  161. // 开户行信息
  162. cardBank:function(e){
  163. const { value } = e.detail;
  164. if (value != '') {
  165. this.setData({ cardBank: value })
  166. } else {
  167. wx.showToast({
  168. title: '开户行信息不能为空',
  169. icon: 'none'
  170. })
  171. return
  172. }
  173. },
  174. // 预留手机号码
  175. bankPhone:function(e){
  176. const mobileExp = /^1\d{10}$/;
  177. const { value } = e.detail;
  178. if (value!= '') {
  179. if (!mobileExp.test(value)) {
  180. wx.showToast({
  181. title: '预留手机号位数不对',
  182. icon: 'none'
  183. })
  184. this.setData({ bankPhone: value })
  185. return
  186. }else{
  187. this.setData({ bankPhone: value })
  188. return
  189. }
  190. }
  191. },
  192. // 提交退款信息
  193. submitRefund:function(){
  194. const postData = { fn: this.submitRefund, param: { ...arguments } }
  195. const { refundMsg, orderNo, cardName, cardNum, cardBank, bankPhone,subbranch}=this.data;
  196. console.log(refundMsg, orderNo, cardName, cardNum, cardBank, bankPhone, subbranch);
  197. if (!refundMsg) {
  198. wx.showToast({
  199. title: '请选择退款理由',
  200. icon: 'none'
  201. })
  202. return
  203. }
  204. if (!cardName) {
  205. wx.showToast({
  206. title: '请填写姓名',
  207. icon: 'none'
  208. })
  209. return
  210. }
  211. if (!cardNum) {
  212. wx.showToast({
  213. title: '请收入银行卡号',
  214. icon: 'none'
  215. })
  216. return
  217. }
  218. if (!cardBank) {
  219. wx.showToast({
  220. title: '请填写开户行信息',
  221. icon: 'none'
  222. })
  223. return
  224. }
  225. if (!subbranch) {
  226. wx.showToast({
  227. title: '请填写支行名',
  228. icon: 'none'
  229. })
  230. return
  231. }
  232. app.post('/api/parents/parents/confirmOrderRefund', {
  233. orderNo,
  234. cardName,
  235. cardNum,
  236. cardBank,
  237. bankPhone,
  238. refundMsg,
  239. subbranch
  240. }, 0, postData).then(res => {
  241. wx.showToast({
  242. title: '成功提交退款信息',
  243. icon:'success',
  244. duration:1000
  245. })
  246. setTimeout((function callback() {
  247. wx.navigateBack({});
  248. }).bind(this), 2000);
  249. })
  250. }
  251. })