You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
157 lines
2.8 KiB
157 lines
2.8 KiB
// pages/user/retail/apply/index.js
|
|
import spreadApi from "../../../../utils/https/common"
|
|
import userApi from "../../../../utils/https/user"
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
name:"",
|
|
phone:"",
|
|
idcard:"",
|
|
list:[],
|
|
index:-1,
|
|
nickName:""
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
userApi.user_post("user/getMyInfo",{}).then(res=>{
|
|
spreadApi.user_post("commission/getMerchantList",{
|
|
user_id:res.data.id
|
|
}).then(r=>{
|
|
this.setData({
|
|
list:r.data.rows,
|
|
user_id:res.data.id
|
|
})
|
|
})
|
|
})
|
|
|
|
},
|
|
bindPickerChange:function(e){
|
|
console.log(e)
|
|
this.setData({
|
|
index:e.detail.value
|
|
})
|
|
},
|
|
apply:function(){
|
|
if(this.data.index<0){
|
|
wx.showToast({
|
|
title: '请选择所属单位',
|
|
icon:'none'
|
|
})
|
|
return;
|
|
}
|
|
if(!this.data.name){
|
|
wx.showToast({
|
|
title: '请输入姓名',
|
|
icon:'none'
|
|
})
|
|
return;
|
|
}
|
|
if(this.data.phone.length!=11){
|
|
wx.showToast({
|
|
title: '请输入正确的手机号',
|
|
icon:'none'
|
|
})
|
|
return;
|
|
}
|
|
if(this.data.id_card.length!=18){
|
|
wx.showToast({
|
|
title: '请输入正确的身份证号',
|
|
icon:'none'
|
|
})
|
|
return;
|
|
}
|
|
spreadApi.user_post("commission/Register",{
|
|
user_name:this.data.name,
|
|
mobile:this.data.phone,
|
|
id_card:this.data.idcard,
|
|
merchant_id:this.data.list[this.data.index].id,
|
|
user_id:this.data.user_id
|
|
}).then(res=>{
|
|
if(res.code==1){
|
|
wx.showToast({
|
|
title: '申请成功',
|
|
icon:'success'
|
|
})
|
|
setTimeout(()=>{
|
|
wx.navigateBack()
|
|
},1000)
|
|
}
|
|
})
|
|
// wx.redirectTo({
|
|
// url: '../index',
|
|
// })
|
|
},
|
|
changeName:function(e){
|
|
let name = e.detail.value;
|
|
this.setData({
|
|
name:name
|
|
})
|
|
},
|
|
changeTel:function(e){
|
|
let tel = e.detail.value;
|
|
this.setData({
|
|
phone:tel
|
|
})
|
|
},
|
|
changeId:function(e){
|
|
let id = e.detail.value;
|
|
this.setData({
|
|
idcard:id
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
})
|