refundApply.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. const WXAPI = require('apifm-wxapi')
  2. Page({
  3. data: {
  4. autosize: {
  5. minHeight: 100
  6. },
  7. orderId: 1,
  8. amount: 999.00,
  9. refundApplyDetail: undefined,
  10. type: '0',
  11. typeItems: [
  12. { name: '我要退款(无需退货)', value: '0', checked: true },
  13. { name: '我要退货退款', value: '1' },
  14. { name: '我要换货', value: '2' },
  15. ],
  16. logisticsStatus:'0',
  17. logisticsStatusItems: [
  18. { name: '未收到货', value: '0', checked: true },
  19. { name: '已收到货', value: '1' }
  20. ],
  21. reason: '不喜欢/不想要',
  22. reasons: [
  23. "不喜欢/不想要",
  24. "空包裹",
  25. "未按约定时间发货",
  26. "快递/物流一直未送达",
  27. "货物破损已拒签",
  28. "退运费",
  29. "规格尺寸与商品页面描述不符",
  30. "功能/效果不符",
  31. "质量问题",
  32. "少件/漏发",
  33. "包装/商品破损",
  34. "发票问题",
  35. ],
  36. reasonIndex: 0,
  37. files: [],
  38. pics: []
  39. },
  40. onLoad: function (e) {
  41. this.setData({
  42. orderId: e.id,
  43. amount: e.amount
  44. });
  45. },
  46. onShow(){
  47. const _this = this
  48. WXAPI.refundApplyDetail(wx.getStorageSync('token'), _this.data.orderId).then(res => {
  49. if (res.code == 0) {
  50. _this.setData({
  51. refundApplyDetail: res.data[0] // baseInfo, pics
  52. })
  53. }
  54. })
  55. },
  56. refundApplyCancel(){
  57. const _this = this
  58. WXAPI.refundApplyCancel(wx.getStorageSync('token'), _this.data.orderId).then(res => {
  59. if (res.code == 0) {
  60. wx.navigateTo({
  61. url: "/pages/order-list/index"
  62. })
  63. }
  64. })
  65. },
  66. typeChange(event) {
  67. this.setData({
  68. type: event.detail,
  69. });
  70. },
  71. typeClick(event) {
  72. const { name } = event.currentTarget.dataset;
  73. this.setData({
  74. type: name,
  75. });
  76. },
  77. logisticsStatusChange(event) {
  78. this.setData({
  79. logisticsStatus: event.detail,
  80. });
  81. },
  82. logisticsStatusClick(event) {
  83. const { name } = event.currentTarget.dataset;
  84. this.setData({
  85. logisticsStatus: name,
  86. });
  87. },
  88. reasonChange(event) {
  89. this.setData({
  90. reason: event.detail,
  91. });
  92. },
  93. reasonClick(event) {
  94. const { name } = event.currentTarget.dataset;
  95. this.setData({
  96. reason: name,
  97. });
  98. },
  99. reasonChange: function (e) {
  100. this.setData({
  101. reasonIndex: e.detail.value
  102. })
  103. },
  104. afterPicRead(e) {
  105. let picsList = this.data.picsList
  106. if (!picsList) {
  107. picsList = []
  108. }
  109. picsList = picsList.concat(e.detail.file)
  110. this.setData({
  111. picsList
  112. })
  113. },
  114. afterPicDel(e) {
  115. let picsList = this.data.picsList
  116. picsList.splice(e.detail.index, 1)
  117. this.setData({
  118. picsList
  119. })
  120. },
  121. previewImage: function (e) {
  122. const that = this;
  123. wx.previewImage({
  124. current: e.currentTarget.id, // 当前显示图片的http链接
  125. urls: that.data.files // 需要预览的图片http链接列表
  126. })
  127. },
  128. async uploadPics(){
  129. // 批量上传附件
  130. if (this.data.picsList) {
  131. for (let index = 0; index < this.data.picsList.length; index++) {
  132. const pic = this.data.picsList[index];
  133. const res = await WXAPI.uploadFile(wx.getStorageSync('token'), pic.url)
  134. if (res.code == 0) {
  135. this.data.pics.push(res.data.url)
  136. }
  137. }
  138. }
  139. },
  140. async bindSave (e) {
  141. // 提交保存
  142. const _this = this;
  143. // _this.data.orderId
  144. // _this.data.type
  145. // _this.data.logisticsStatus
  146. // _this.data.reasons[_this.data.reasonIndex]
  147. let amount = this.data.amount;
  148. if (_this.data.type == 2) {
  149. amount = 0.00
  150. }
  151. let remark = this.data.remark;
  152. if (!remark) {
  153. remark = ''
  154. }
  155. // 上传图片
  156. await _this.uploadPics()
  157. // _this.data.pics
  158. WXAPI.refundApply({
  159. token: wx.getStorageSync('token'),
  160. orderId: _this.data.orderId,
  161. type: _this.data.type,
  162. logisticsStatus: _this.data.logisticsStatus,
  163. reason: _this.data.reason,
  164. amount,
  165. remark,
  166. pic: _this.data.pics.join()
  167. }).then(res => {
  168. if (res.code == 0) {
  169. wx.showModal({
  170. title: '成功',
  171. content: '提交成功,请耐心等待我们处理!',
  172. showCancel: false,
  173. confirmText: '我知道了',
  174. success(res) {
  175. wx.navigateTo({
  176. url: "/pages/order-list/index"
  177. })
  178. }
  179. })
  180. } else {
  181. wx.showModal({
  182. title: '失败',
  183. content: res.msg,
  184. showCancel: false,
  185. confirmText: '我知道了',
  186. success(res) {
  187. wx.navigateTo({
  188. url: "/pages/order-list/index"
  189. })
  190. }
  191. })
  192. }
  193. })
  194. }
  195. });