writeReturnLogistics.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. // pages/writeReturnLogistics/writeReturnLogistics.js
  2. var http = require('../../utils/http.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. // 物流公司选择
  9. deliveryList:[],
  10. expressId: 0, //物流公司id
  11. expressName: '', //物流公司名称
  12. expressNo: '', //物流单号
  13. imgs: [], //图片凭证
  14. mobile: '', //手机号码
  15. refundSn: '', //退款编号名称
  16. senderRemarks: '', //备注信息
  17. },
  18. /**
  19. * 选择物流公司
  20. */
  21. chooseLogisticsCompany: function (e) {
  22. console.log('快递公司',e.detail.value)
  23. this.setData({
  24. expressId: e.detail.value
  25. })
  26. },
  27. onExpressNoInput:function(e){
  28. this.setData({
  29. expressNo:e.detail.value
  30. });
  31. },
  32. onSenderRemarksInput: function (e) {
  33. this.setData({
  34. senderRemarks: e.detail.value
  35. });
  36. },
  37. /**
  38. * 填写&提交物流信息
  39. */
  40. writeLogisticsMsg: function (e) {
  41. wx.showLoading();
  42. if (this.data.expressNo.length == 0) {
  43. wx.showToast({
  44. icon: 'none',
  45. title: '请填写物流单号',
  46. })
  47. } else {
  48. var pics = '';
  49. this.data.imgs.forEach(function (item) {
  50. pics += item.path + ',';
  51. });
  52. if (pics != '') {
  53. pics = pics.substring(0, pics.length - 1)
  54. }
  55. var parmas = {
  56. url: "/p/orderRefund/submitExpress",
  57. method: "POST",
  58. data: {
  59. expressId: this.data.deliveryList[this.data.expressId].dvyId, //物流公司id
  60. expressName: this.data.deliveryList[this.data.expressId].dvyName, //物流公司名称
  61. expressNo: this.data.expressNo, //物流单号
  62. imgs: pics, //图片凭证
  63. mobile: this.data.mobile, //手机号码
  64. refundSn: this.data.refundSn, //退款编号名称
  65. senderRemarks: this.data.senderRemarks, //备注信息
  66. },
  67. callBack: (res) => {
  68. wx.hideLoading();
  69. // 物流填写跳转页面
  70. wx.navigateTo({
  71. url: '/pages/DetailsOfRefund/DetailsOfRefund?refundSn=' + this.data.refundSn,
  72. })
  73. }
  74. };
  75. http.request(parmas);
  76. }
  77. },
  78. /**
  79. * 上传图片
  80. */
  81. getUploadImg: function (e) {
  82. const idx = e.target.dataset.idx
  83. console.log(idx);
  84. var ths = this;
  85. wx.chooseImage({
  86. count: 1, // 默认9
  87. sizeType: ['compressed'],
  88. sourceType: ['album', 'camera'],
  89. success: function (res) {
  90. // 图片的本地临时文件路径列表
  91. var tempFilePaths = res.tempFilePaths;
  92. wx.showLoading({
  93. mask: true
  94. })
  95. var params = {
  96. url: "/p/file/upload",
  97. filePath: tempFilePaths[0],
  98. name: 'file',
  99. callBack: function (res2) {
  100. wx.hideLoading();
  101. var img = {};
  102. img.path = JSON.parse(res2).filePath;
  103. img.url = JSON.parse(res2).resourcesUrl + JSON.parse(res2).filePath;
  104. var imgs = ths.data.imgs;
  105. imgs.push(img);
  106. ths.setData({
  107. imgs: imgs
  108. })
  109. }
  110. };
  111. http.upload(params);
  112. }
  113. })
  114. },
  115. /**
  116. * 删除图片
  117. */
  118. removeImage: function (e) {
  119. // const index = e.target.dataset.index
  120. // const idx = e.target.dataset.idx;
  121. var idx = e.currentTarget.dataset.idx;
  122. var imgs = this.data.imgs;
  123. imgs.splice(idx, 1)
  124. this.setData({
  125. imgs: imgs
  126. });
  127. console.log('删除图片')
  128. },
  129. /**
  130. * 生命周期函数--监听页面加载
  131. */
  132. onLoad: function (options) {
  133. this.setData({
  134. refundSn: options.refundSn
  135. });
  136. this.loadDeliveryData();
  137. },
  138. loadDeliveryData(){
  139. wx.showLoading();
  140. http.request({
  141. url:"/p/delivery/list",
  142. method: "get",
  143. data: {},
  144. callBack: (res) => {
  145. wx.hideLoading();
  146. this.setData({
  147. deliveryList:res
  148. });
  149. console.log(res)
  150. }
  151. });
  152. console.log(this.data.deliveryList)
  153. },
  154. /**
  155. * 生命周期函数--监听页面初次渲染完成
  156. */
  157. onReady: function () {
  158. },
  159. /**
  160. * 生命周期函数--监听页面显示
  161. */
  162. onShow: function () {
  163. },
  164. /**
  165. * 生命周期函数--监听页面隐藏
  166. */
  167. onHide: function () {
  168. },
  169. /**
  170. * 生命周期函数--监听页面卸载
  171. */
  172. onUnload: function () {
  173. },
  174. /**
  175. * 页面相关事件处理函数--监听用户下拉动作
  176. */
  177. onPullDownRefresh: function () {
  178. },
  179. /**
  180. * 页面上拉触底事件的处理函数
  181. */
  182. onReachBottom: function () {
  183. },
  184. /**
  185. * 用户点击右上角分享
  186. */
  187. onShareAppMessage: function () {
  188. }
  189. })