25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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