Commit 0ec0d1d0 by luyt

feat:产品申请开通

1 parent a8434f56
import api from "~/utils/request/request";
const serverApi = {
getMerchantList: "scrm.api.busassistant.merchant.getMerchantListBySceneRemote", //根据场景值、服务商查询4s店
addCoProduct: "scrm.api.busassistant.merchant.addCoProduct", //申请合作产品
};
export const getMerchantListApi = (data) => {
return api.post(
{
method: serverApi.getMerchantList,
...data,
},
true
);
};
export const addCoProductApi = (data) => {
return api.post(
{
method: serverApi.addCoProduct,
...data,
},
true
);
};
// pages/apply/apply.js // pages/apply/apply.js
const navStyle = 'background-color: transparent;' const navStyle = 'background-color: transparent;'
import { IMG_URL } from '~/utils/constantData.js' import { IMG_URL } from '~/utils/constantData.js'
import applyApi from '~/api/applyApi/index' import {getMerchantListApi,addCoProductApi} from '~/api/applyProd.js'
import { behavior as computedBehavior } from '~/utils/lib/miniprogram-computed' import { behavior as computedBehavior } from '~/utils/lib/miniprogram-computed'
import utils from '~/utils/util.js'
Page({ Page({
/** /**
...@@ -16,20 +17,17 @@ Page({ ...@@ -16,20 +17,17 @@ Page({
cooperativeStore:'', cooperativeStore:'',
storeShow: false, storeShow: false,
actions: [ actions: [
{ // {
name: '选项1', // "merchantId": 0,
}, // "merchantName": "选项1"
{ // },
name: '选项2', // {
}, // "merchantId": 1,
{ // "merchantName": "选项2"
name: '选项3', // },
// subname: '描述信息',
// openType: 'share',
},
], ],
selectStoreItem:{} selectStoreItem:{},
scene:'' //场景值
}, },
computed: { computed: {
selectStoreValue(data) { selectStoreValue(data) {
...@@ -61,64 +59,93 @@ Page({ ...@@ -61,64 +59,93 @@ Page({
// 提交信息 // 提交信息
applyFn() { applyFn() {
let { name } = this.data.carObj let {prodName,selectStoreItem} = this.data
console.log('name: ', name) if (!prodName) {
if (!name) {
wx.pro.showToast({ wx.pro.showToast({
title: '请输入开店名称', title: '请输入开店名称',
icon: 'error' icon: 'error'
}) })
return return
} }
if(utils.isEmptyObj(selectStoreItem)){
wx.pro.showToast({
title: '请输入选择合作门店',
icon: 'error'
})
return
}
this.submitForm() this.submitForm()
// console.log(123) // console.log(123)
}, },
submitForm() { async submitForm() {
let { carObj, clueId } = this.data let {prodName,selectStoreItem} = this.data
let { userInfo } = wx.$storage.get() let userInfo = wx.$storage.get('userInfo')
let MerchantInfo = userInfo.subLoginUser let params = {
let params = { ...selectStoreItem,
serviceMerchantId: MerchantInfo.merchantId, serviceMerchantId:userInfo.merchantId,
serviceMerchantName: MerchantInfo.merchantName, serviceMerchantName:userInfo.merchantName,
serviceMerchantPhone: MerchantInfo.phone, coProduct:prodName
merchantContact: carObj.contact,
phone: carObj.phone,
applyMerchantName: carObj.name,
carType: carObj.model,
baseCustomer: carObj.selNum,
clueId
} }
// return wx.$api.showToast('申请成功') let res = await addCoProductApi(params)
applyApi // console.log('res: ', res);
.merchantApply(params) if(code == 0){
.then(result => { wx.$api.showToast('申请成功')
console.log(result) setTimeout(() => {
if (result) { wx.$router.back(page => {
wx.$api.showToast('申请成功') let node = page.selectComponent('#indexclue')
setTimeout(() => { node && node.getClueInit()
wx.$router.back(page => { })
let node = page.selectComponent('#indexclue') }, 1000)
node && node.getClueInit() }
})
}, 1000)
}
})
.catch(err => {}) // // 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 => {})
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) {}, onLoad(options) {
this.getMerchantListFn()
},
onRoute(params) { onRoute(params) {
// 线索id // console.log('params: ', params.scene)
this.setData({ this.setData({
clueId: params scene:params.scene
}) })
// console.log('params: ', params)
}, },
//获取门店
async getMerchantListFn(){
let {scene} = this.data
let params = {scene}
let {code,data} = await getMerchantListApi(params)
if(code== 0 && data.length != 0){
data = data.map(item=>item.name = item.merchantName )
this.setData({
actions:data
})
}
},
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
......
...@@ -154,7 +154,10 @@ Component({ ...@@ -154,7 +154,10 @@ Component({
// 开通 // 开通
openPro() { openPro() {
wx.$router.go("/packagesList/applyProd/pages/apply"); let obj = {
scene:3
}
wx.$router.go("/packagesList/applyProd/pages/apply",obj);
}, },
openBus() { openBus() {
wx.$router.go("/packagesList/apply/pages/apply"); wx.$router.go("/packagesList/apply/pages/apply");
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!