|
- const config = require('../../config/config.js')
- const Http = require('../../utils/HttpBasics.js')
- const util = require('../../utils/util.js')
- const format = require('../../utils/format.js')
- const app = getApp();
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- receiptUrl: "",
- courierInput: "",
- expressageIdInput: "",
- formData: {
- orderNo: '',
- orderMoney: '',
- cusVipNum: '',
- cusName: '',
- cusPhone: "",
- cusAddress: "",
- cusId:""
- },
- address: '',
- paramData: null,
- detailData: null,
- auditRemark: '',
- disabled: false,
- btnText: '提交',
- auditRemarkShow: false,
- disabledDetail: true,
- recordExtends: [''],
- rule: {
- "orderNo": [{
- required: true,
- message: "请填写订单编号"
- }],
- "orderMoney": [{
- required: true,
- message: "请填写定金金额"
- },
- {
- type: 'float',
- message: "请输入最多两位小数的数字"
- }
- ],
- "cusVipNum": [{
- required: true,
- message: "请填写会员卡号"
- }],
- "cusName": [{
- required: true,
- message: "请填写客户姓名"
- }],
- "cusPhone": [{
- required: true,
- message: "请填写手机号"
- },
- {
- type: 'phone',
- message: "请输入正确的手机号码"
- }
- ],
- "cusAddress": [{
- required: true,
- message: "请填写客户地址"
- }],
- // "lotteryCount": [{
- // required: true,
- // message: "请填写抽奖券数量"
- // }],
- // "anniversaryLotteryNum": [{
- // required: true,
- // message: "周年庆抽奖编码"
- // }
- // ],
- // "cusAddress":[
- // {
- // pattern:/^[A-Z]{1}[0-9]{9}/g,
- // message:"请输入以大写字母开头的长度为10的字符"
- // }
- // ]
- },
- },
- inputChange(e) {
- console.log(e, 9999)
- this.setData({
- formData: Object.assign(this.data.formData, {
- [e.target.dataset.key]: e.detail.value
- })
- })
- //客户电话且满足手机格式要求时请求会员信息
- if (e.target.dataset.key === 'cusPhone') {
- const {
- formRegular
- } = format
- if (formRegular.phone.test(e.detail.value)) {
- this.getVipData()
- } else {
- this.setData({
- formData: Object.assign(this.data.formData, {
- cusVipNum: '',
- cusName: '',
- cusAddress: "",
- })
- })
- }
- }
- // this.setData({
- // auditRemark: e.detail.value
- // })
- },
- /**
- * 根据手机号获取会员信息
- */
- getVipData() {
- Http.get({
- url: config.api.legionUserGetByPhone,
- data: {
- activityId: this.data.paramData.activityId,
- phone: this.data.formData.cusPhone
- }
- }).then(res => {
- const {
- vipNum = '',
- name = '',
- address = "",
- id=''
- } = res?.data || {}
- this.setData({
- formData: Object.assign(this.data.formData, {
- cusVipNum:vipNum,
- cusName:name,
- cusAddress:address,
- cusId:id
- })
- })
- }).catch(err => {
- wx.showToast({
- title: err.message ? err.message : err.data,
- })
- })
- },
- /**
- * 取消
- */
- goBack() {
- wx.navigateBack({
- delta: 1
- })
- },
- submit() {
- if (!format.validateForm(this.data.formData, this.data.rule)) {
- return
- }
-
- if (this.data.formData.auditRemark == "" && this.data.detailData?.auditStatus == 2) {
- wx.showToast({
- title: '请输入驳回意见',
- icon: "none"
- })
- return
- }
- Http.post({
- url: config.api.legionOrderSaveOrUpdate,
- data: {
- id: this.data.paramData.tag === 'add' ? '' : this.data.detailData.id,
- activityId: this.data.paramData.tag === 'add' ? this.data.paramData.activityId : this.data.detailData.activityId,
- orderNo: this.data.formData.orderNo,
- orderMoney: this.data.formData.orderMoney,
- cusVipNum: this.data.formData.cusVipNum,
- cusName: this.data.formData.cusName,
- cusPhone: this.data.formData.cusPhone,
- cusAddress: this.data.formData.cusAddress,
- cusId:this.data.formData.cusId
- }
- }).then(res => {
- wx.showToast({
- title: '提交成功!',
- icon: "none"
- })
- wx.navigateBack({
- delta: 1
- })
- }).catch(err => {
- wx.showToast({
- title: err.message ? err.message : err.data,
- icon: "none"
- })
- })
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- id: options.id,
- paramData: options,
- disabled: false, //options.tag !== 'add' ? true : false,
- disabledDetail: options.tag === 'add' ? false : true,
- auditRemarkShow: options.auditStatus == '2' ? true : false,
- btnText: options.auditStatus == '0' || options.auditStatus == '1' || options.auditStatus == '3' ? '' : options.auditStatus == '2' ? '修改' : '提交',
- })
- wx.setNavigationBarTitle({
- title: options.auditStatus == '0' || options.auditStatus === '1' ? '查看活动审批' : options.auditStatus == '2' ? '修改活动审批' : '提交活动审批',
- })
- console.log(options, 1111)
- options.tag !== 'add' && this.getData()
- },
- getData() {
- Http.get({
- url: config.api.legionOrderGetInfoById,
- data: {
- id: this.data.id
- }
- }).then(res => {
- res.data.cashRate = res.data.cashRate + '%'
- res.data.mallRate = res.data.mallRate + '%'
- res.data.merchantRate = res.data.merchantRate + '%'
- this.setData({
- detailData: res.data
- })
- const formData = {
- orderNo: res.data.orderNo,
- orderMoney: res.data.orderMoney,
- cusVipNum: res.data.cusVipNum,
- cusName: res.data.cusName,
- cusPhone: res.data.cusPhone,
- cusAddress: res.data.cusAddress,
- cusId:res.data.cusId
- }
- if (res.data.auditStatus === 2) {
- formData.auditRemark = res.data.auditRemark
- }
- console.log(res.data.auditStatus === 0 || res.data.auditStatus === 1 ? true : false, 888888)
- this.setData({
- formData,
- disabledDetail: res.data.auditStatus === 0 || res.data.auditStatus === 1 || res.data.auditStatus === 3 ? true : false
- })
- if (res.data.auditStatus === 0) {
- this.setData({
- disabled: false
- })
- }
- }).catch(err => {
- wx.showToast({
- title: err.message ? err.message : err.data,
- })
- })
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
- }
- })
|