apply.js 2.81 KB
// pages/apply/apply.js
const navStyle = 'background-color: transparent;'
import { IMG_URL } from '~/utils/constantData.js'
import applyApi from '~/api/applyApi/index'
// `${IMG_URL}index/car2.png`,
//本地图片路径
let IMG_URLLocal = '../../images/'

Page({
  /**
   * 页面的初始数据
   */
  data: {
    navStyle,
    IMG_URL,
    carObj: {
      name: '',
      model: '',
      selNum: '',
      contact: '',
      phone: ''
    }
  },
  // navbar高度设置
  navbarReady(e) {
    let { height, statusBarHeight } = e.detail
    this.setData({
      tabBarStyle: height / 2 + statusBarHeight
      // headerHeight: height / 2 + statusBarHeight +  88*2
    })
  },
  // 提交信息
  applyFn() {
    let { name } = this.data.carObj
    console.log('name: ', name)
    if (!name) {
      wx.pro.showToast({
        title: '请输入开店名称',
        icon: 'error'
      })
      return
    }
    this.submitForm()
    // console.log(123)
  },
  submitForm() {
    let { carObj, clueId } = this.data
    let { userInfo } = wx.$storage.get()
    let MerchantInfo = userInfo.subLoginUser
    let params = {
      serviceMerchantId: MerchantInfo.merchantId,
      serviceMerchantName: MerchantInfo.merchantName,
      serviceMerchantPhone: MerchantInfo.phone,
      merchantContact: carObj.contact,
      phone: carObj.phone,
      applyMerchantName: carObj.name,
      carType: carObj.model,
      baseCustomer: carObj.selNum,
      clueId
    }
    // return wx.$api.showToast('申请成功')
    applyApi
      .merchantApply(params)
      .then(result => {
        console.log(result)
        if (result) {
          wx.$api.showToast('申请成功')
          setTimeout(() => {
            wx.$router.back(page => {
              let node = page.selectComponent('#indexclue')
              node && node.getClueInit()
            })
          }, 1000)
        }
      })
      .catch(err => {})
  },
  bindinputFn(e) {
    // console.log("e: ", e);
    let name = e.currentTarget.dataset.name
    let content = e.detail.value
    this.setData({
      [`carObj.${name}`]: content
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {},
  onRoute(params) {
    // 线索id
    this.setData({
      clueId: params
    })
    // console.log('params: ', params)
  },

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

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

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

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

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

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

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