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.

282 lines
7.0 KiB

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