You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

263 lines
5.8 KiB

  1. const config = require('../../config/config.js')
  2. const Http = require('../../utils/HttpBasics.js')
  3. const util = require('../../utils/util.js')
  4. const app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. receiptUrl: "",
  11. courierInput: "",
  12. expressageIdInput: "",
  13. orderNo: '',
  14. orderMoney: '',
  15. cusName: '',
  16. phone: '',
  17. address: '',
  18. paramData: null,
  19. detailData: null,
  20. auditRemark: '',
  21. disabled: false,
  22. btnText: '提交',
  23. auditRemarkShow: false,
  24. disabledDetail: false,
  25. recordExtends: [{
  26. remark: ''
  27. }]
  28. },
  29. inputauditRemark(e) {
  30. this.setData({
  31. auditRemark: e.detail.value
  32. })
  33. },
  34. inputorderNo(e) {
  35. this.setData({
  36. orderNo: e.detail.value
  37. })
  38. },
  39. inputorderMoney(e) {
  40. this.setData({
  41. orderMoney: e.detail.value
  42. })
  43. },
  44. inputcusName(e) {
  45. this.setData({
  46. cusName: e.detail.value
  47. })
  48. },
  49. inputphone(e) {
  50. this.setData({
  51. phone: e.detail.value
  52. })
  53. },
  54. inputaddress(e) {
  55. this.setData({
  56. address: e.detail.value
  57. })
  58. },
  59. inputRemark(e) {
  60. let recordExtends = this.data.recordExtends
  61. recordExtends[e.target.dataset.index].remark = e.detail.value
  62. this.setData({
  63. recordExtends: recordExtends
  64. })
  65. },
  66. addRemark() {
  67. let recordExtends = this.data.recordExtends
  68. recordExtends.push({remark: ''})
  69. this.setData({
  70. recordExtends: recordExtends
  71. })
  72. },
  73. delRemark(e) {
  74. let recordExtends = this.data.recordExtends
  75. recordExtends.splice(e.target.dataset.index, 1)
  76. this.setData({
  77. recordExtends: recordExtends
  78. })
  79. },
  80. goBack() {
  81. wx.navigateBack({
  82. delta: 1
  83. })
  84. },
  85. submit() {
  86. if(this.data.paramData.tag == 'detail' && this.data.detailData?.auditStatus !== 0) {
  87. wx.navigateBack({
  88. delta: 1
  89. })
  90. return
  91. }
  92. if (this.data.auditRemark == "" && this.data.detailData?.auditStatus == 2) {
  93. wx.showToast({
  94. title: '请输入驳回意见',
  95. icon: "none"
  96. })
  97. return
  98. }
  99. if (this.data.orderNo == "") {
  100. wx.showToast({
  101. title: '请输入订单号',
  102. icon: "none"
  103. })
  104. return
  105. }
  106. if (this.data.orderMoney == "") {
  107. wx.showToast({
  108. title: '请输入订单金额',
  109. icon: "none"
  110. })
  111. return
  112. }
  113. if (this.data.cusName == "") {
  114. wx.showToast({
  115. title: '请输入客户姓名',
  116. icon: "none"
  117. })
  118. return
  119. }
  120. if (this.data.phone == "") {
  121. wx.showToast({
  122. title: '请输入客户电话',
  123. icon: "none"
  124. })
  125. return
  126. }
  127. if (this.data.address == "") {
  128. wx.showToast({
  129. title: '请输入客户地址',
  130. icon: "none"
  131. })
  132. return
  133. }
  134. Http.post({
  135. url: config.api.raffleSaveOrUpdateRecord,
  136. data: {
  137. id: this.data.paramData.tag === 'add' ? '' : this.data.detailData.id,
  138. activityId: this.data.paramData.tag === 'add' ? this.data.paramData.activityId : this.data.detailData.activityId,
  139. orderNo: this.data.orderNo,
  140. orderMoney: this.data.orderMoney,
  141. cusName: this.data.cusName,
  142. phone: this.data.phone,
  143. address: this.data.address,
  144. auditStatus: this.data.paramData.tag !== 'add' && this.data.detailData.auditStatus === 2 ? 0 : undefined,
  145. recordExtends: this.data.recordExtends
  146. }
  147. }).then(res=>{
  148. wx.showToast({
  149. title: '提交成功!',
  150. icon:"none"
  151. })
  152. wx.navigateBack({
  153. delta: 1
  154. })
  155. }).catch(err=>{
  156. wx.showToast({
  157. title: err.message?err.message:err.data,
  158. icon: "none"
  159. })
  160. })
  161. },
  162. /**
  163. * 生命周期函数--监听页面加载
  164. */
  165. onLoad: function(options) {
  166. this.setData({
  167. id: options.id,
  168. paramData: options,
  169. disabled: false,// options.tag !== 'add' ? true : false,
  170. disabledDetail: options.tag == 'detail' ,
  171. btnText: options.tag == 'add' ? '提交' : options.tag == 'detail' ? '已完成' : '修改'
  172. })
  173. options.tag !== 'add' && this.getData()
  174. },
  175. getData() {
  176. Http.get({
  177. url: config.api.raffleRecordInfo,
  178. data: {
  179. id: this.data.id
  180. }
  181. }).then(res => {
  182. res.data.cashRate = res.data.cashRate + '%'
  183. res.data.mallRate = res.data.mallRate + '%'
  184. res.data.merchantRate = res.data.merchantRate + '%'
  185. this.setData({
  186. detailData: res.data
  187. })
  188. this.setData({
  189. orderNo: res.data.orderNo,
  190. orderMoney:res.data.orderMoney,
  191. cusName: res.data.cusName,
  192. phone: res.data.phone,
  193. address: res.data.address,
  194. auditRemark: res.data.auditRemark,
  195. auditRemarkShow: res.data.auditStatus === 2,
  196. recordExtends: res.data.recordExtends
  197. })
  198. if(res.data.auditStatus === 0) {
  199. this.setData({
  200. disabled: false,
  201. disabledDetail: false,
  202. btnText: '提交'
  203. })
  204. }
  205. }).catch(err => {
  206. wx.showToast({
  207. title: err.message ? err.message : err.data,
  208. })
  209. })
  210. },
  211. /**
  212. * 生命周期函数--监听页面初次渲染完成
  213. */
  214. onReady: function() {
  215. },
  216. /**
  217. * 生命周期函数--监听页面显示
  218. */
  219. onShow: function() {
  220. },
  221. /**
  222. * 生命周期函数--监听页面隐藏
  223. */
  224. onHide: function() {
  225. },
  226. /**
  227. * 生命周期函数--监听页面卸载
  228. */
  229. onUnload: function() {
  230. },
  231. /**
  232. * 页面相关事件处理函数--监听用户下拉动作
  233. */
  234. onPullDownRefresh: function() {
  235. },
  236. /**
  237. * 页面上拉触底事件的处理函数
  238. */
  239. onReachBottom: function() {
  240. },
  241. /**
  242. * 用户点击右上角分享
  243. */
  244. onShareAppMessage: function() {
  245. }
  246. })