equityQualityOrderList.js 5.47 KB
// packageEquity/pages/qualityOrderList/qualityOrderList.js
import {
  quotationPage
} from "../../api";
import data from "../carQuotation/constant/data";
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/dj-car-boutique-work-wechat/'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    IMG_URL,
    pageSize: 4,
    currentPage: 1,
    nothing: false,
    flag: false,
    staffUuid: '',
    triggered: false,
    scrollTop: 0,
    searchdate: '',
    customerName: '',
    merchantId: '',
    customerPhones: [],
    orderStatusObj: data.orderStatusObj,
    orderObj: [
      {
        label: "销售顾问",
        arr: ["merchantName", "referrerName"],
      },
      {
        label: "转化人员",
        arr: ["parkMerchantName", "transferName"],
      },
      {
        label: "车架号",
        key: "carVin",
      },
      {
        label: "购买商品",
        key: "goodsNameAlias",
        otherKey: "goodsName",
      },
      {
        label: "工单编号",
        key: "payId",
      },
      {
        label: "交易流水号",
        key: "transactionNo",
        canCopy: true,
      },
      {
        label: "拒升原因",
        key: "remark",
      },
      {
        label: "支付时间",
        key: "payTime",
      },
      {
        label: "创建时间",
        key: "createdTime",
      },
      {
        label: "支付方式",
        key: "payType",
        mapValue: {
          1: "线上支付",
          2: "门店收款",
          5: "嘀加收款"
        },
      },
    ],
  },
  // 上滑加载更多
  onBottomRefresh() {
    this.getList()
  },

  // 清空搜索条件
  handleReset() {
    this.setData({
      customerName: "",
    })
    this.search()
  },
  // 输入框输入
  input(e) {
    let { value } = e.detail
    this.setData({
      customerName: value,
    })
  },
  // 搜索
  search() {
    this.setData({
      currentPage: 1,
      nothing: false,
      flag: false,
      list: []
    })
    this.getList(true)
  },
  // 获取订单列表
  getList(isReset = false) {
    let {
      pageSize,
      currentPage,
      searchdate,
      customerName,
      merchantId,
      nothing,
      staffUuid,
      customerPhones
    } = this.data
    if (nothing) {
      return
    }
    let params = {
      pageSize,
      currentPage,
      customerName,
      minPayTime: searchdate ? `${searchdate} 00:00:00` : '',
      maxPayTime: searchdate ? `${searchdate} 23:59:59` : '',
      merchantId,
      customerPhones
    }
    if (staffUuid) {
      params.transferIds = [staffUuid]
    }

    wx.$util.showLoading()
    quotationPage(params)
      .then((res) => {
        wx.hideLoading()
        if (res.code == "0") {
          let { list, pages } = res.data
          // 处理返回数据
          let tempList = this.dealListData(list || [])
          tempList = tempList.map((item) => {
            item.createdTime = wx.$util.tsFormatTime(
              item.createdTime,
              "Y/M/D h:m:s"
            )
            if (item.payTime) {
              item.payTime = wx.$util.tsFormatTime(
                item.payTime,
                "Y/M/D h:m:s"
              )
            }
            return item
          })
          this.setData({
            [`list[${currentPage - 1}]`]: tempList,
            currentPage: currentPage + 1,
            nothing: currentPage == pages,
            triggered: false,
            flag: true,
          })
          if (isReset) {
            this.setData({
              scrollTop: 0,
            })
          }
        } else {
          this.setData({
            list: [],
            nothing: false,
            flag: true,
          })
          wx.$util.showToast(res.message || "接口异常");
        }
      })
      .catch((err) => {
        wx.hideLoading()
      })
  },

  dealListData(arr) {
    if (!arr) {
      return arr
    }
    var attrList = ["equityPrice", "quotedPrice", "quotedPriceUpdate"]
    arr.forEach((item) => {
      attrList.forEach((k) => {
        if (item[k]) {
          item[k] = (item[k] / 100).toFixed(2);
        }
      })
    })
    return arr
  },

  // 复制交易流水号
  toCopyNumber(e) {
    let { ordernum } = e.currentTarget.dataset
    ordernum = ordernum.replace(/,$/, "")
    wx.setClipboardData({
      data: ordernum.toString(),
      success(res) {
        wx.$util.showToast("已复制")
      },
    })
  },
  // 跳转接待详情
  jumpReception(e) {
    const { item } = e.currentTarget.dataset
    wx.$router.go("reception", item)
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    wx.$router.getData(res => {
      this.setData({
        staffUuid: res?.staffUuid, // 员工id
        searchdate: res?.searchdate, // 质检页面筛选的时间条件
        merchantId: res?.merchantId, // 员工归属门店
        customerPhones: res.phoneNumberLists ? res.phoneNumberLists : [] // 接待客户手机号
      })
      this.getList()
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})