// 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(){ 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 () { } })