前端小程序:wxml
js里面:
//huitianxia/view/attend/attend/attend.js
var app = getApp();
Page({
/**
*页面的初始数据
*/
data: {
img_arr: [],
formdata: '',
bg: "../../../image/attend/[email protected]",
photo: "../../../image/attend/[email protected]",
content: {
icon1: "../../../image/attend/[email protected]",
icon2: "../../../image/attend/[email protected]",
icon3: "../../../image/attend/[email protected]",
icon4: "../../../image/attend/[email protected]",
icon5: "../../../image/attend/[email protected]",
icon6: "../../../image/attend/[email protected]",
icon7: "../../../image/attend/[email protected]",
icon8: "../../../image/attend/[email protected]",
icon9: "../../../image/attend/[email protected]",
icon10: "../../../image/attend/[email protected]",
icon11: "../../../image/attend/[email protected]",
icon12: "../../../image/attend/[email protected]",
},
footList: [
{
text: "查询证书",
pressImg: "../../../image/common/[email protected]",
seleImg: "../../../image/common/[email protected]",
url: "/huitianxia/view/index/index/index",
active: false
},
{
text: "参会申请",
pressImg: "../../../image/common/[email protected]",
seleImg: "../../../image/common/[email protected]",
url: "/huitianxia/view/attend/attend/attend",
active: true
},
{
text: "联系我们",
pressImg: "../../../image/common/[email protected]",
seleImg: "../../../image/common/[email protected]",
url: "/huitianxia/view/contact/contact/contact",
active: false,
}
]
},
/**
*生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
*生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
*生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
*生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
*生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
*页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
*页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
// 调用图片上传接口
upload: function () {
var that = this;
wx.chooseImage({
success: function (res) {
var tempFilePaths = res.tempFilePaths;
// console.log(tempFilePaths[0])
that.setData({
img:tempFilePaths[0],
photo: tempFilePaths[0]
})
// var uid = app.globalData.uid;
// var web_url = app.globalData.web_url;
// var web_url1 = web_url + "/Tjg/uploadsImg";
// wx.uploadFile({
// url: web_url1, //仅为示例,非真实的接口地址
// filePath: tempFilePaths[0],
// name: 'file',
// formData: {
// 'user': uid
// },
// success: function (res) {
// var res1 = JSON.parse(res.data);
// console.log(res1.data)
// that.setData({
// u_image: res1.data
// })
// }
// })
}
})
},
/**
*用户点击右上角分享
*/
onShareAppMessage: function () {
},
formSubmit: function (e) {
varid = e.target.id
adds = e.detail.value;
adds.program_id = app.jtappid
adds.openid = app._openid
adds.zx_info_id = this.data.zx_info_id
this.upload()
},
//单位名称start
bindworknameChange: function (e) {
console.log('u_workname发送选择改变,携带值为', e.detail.value)
this.setData({
u_workname: e.detail.value
})
},
//法人代表start
bindCorporateChange: function (e) {
console.log('u_corporate发送选择改变,携带值为', e.detail.value)
this.setData({
u_corporate: e.detail.value
})
},
//工商登记号start
bindRegisternumberChange: function (e) {
console.log('u_registernumber发送选择改变,携带值为', e.detail.value)
this.setData({
u_registernumber: e.detail.value
})
},
//注册资金start
bindRegistercapitalChange: function (e) {
console.log('u_registercapital发送选择改变,携带值为', e.detail.value)
this.setData({
u_registercapital: e.detail.value
})
},
//员工数start
bindStaffnumberChange: function (e) {
console.log('u_staffnumber发送选择改变,携带值为', e.detail.value)
this.setData({
u_staffnumber: e.detail.value
})
},
//资产总数start
bindCapitalsumChange: function (e) {
console.log('u_capitalsum发送选择改变,携带值为', e.detail.value)
this.setData({
u_capitalsum: e.detail.value
})
},
//销售总额start
bindMarketsumChange: function (e) {
console.log('u_marketsum发送选择改变,携带值为', e.detail.value)
this.setData({
u_marketsum: e.detail.value
})
},
//企业简介start
bindCompanydescChange: function (e) {
console.log('u_companydesc发送选择改变,携带值为', e.detail.value)
this.setData({
u_companydesc: e.detail.value
})
},
//申请选项start
bindTypeChange: function (e) {
console.log('u_type发送选择改变,携带值为', e.detail.value)
this.setData({
u_type: e.detail.value
})
},
//姓名start
bindUsernameChange: function (e) {
console.log('m_username发送选择改变,携带值为', e.detail.value)
this.setData({
m_username: e.detail.value
})
},
//电话start
bindtelphoneChange: function (e) {
console.log('u_telphone发送选择改变,携带值为', e.detail.value)
this.setData({
u_telphone: e.detail.value
})
},
//提交数据,刷新页面
bindChaneInfo: function () {
var check_tel = /^[1][3,4,5,7,8][0-9]{9}$/;
var that = this;
//varu_id=app.globalData.uid;
var u_workname = this.data.u_workname;
var u_corporate = this.data.u_corporate;
var u_registernumber = this.data.u_registernumber;
var u_registercapital = this.data.u_registercapital;
var u_staffnumber = this.data.u_staffnumber;
var u_capitalsum = this.data.u_capitalsum;
var u_marketsum = this.data.u_marketsum;
var u_companydesc = this.data.u_companydesc;
var u_type = this.data.u_type;
var m_username = this.data.m_username;
var u_telphone = this.data.u_telphone;
var u_image = this.data.img;
//console.log(u_image);
if (!u_workname) {
wx.showToast({
title: '请填写单位名称',
icon: 'none',
duration: 2000
})
return;
}
if (!u_corporate) {
wx.showToast({
title: '请填写法人代表',
icon: 'none',
duration: 2000
})
return;
}
if (!u_registernumber) {
wx.showToast({
title: '请填写工商登记号',
icon: 'none',
duration: 2000
})
return;
}
if (!u_registercapital) {
wx.showToast({
title: '请填写注册资金',
icon: 'none',
duration: 2000
})
return;
}
if (!u_staffnumber) {
wx.showToast({
title: '请填写员工数',
icon: 'none',
duration: 2000
})
return;
}
if (!u_capitalsum) {
wx.showToast({
title: '请填写资产总数',
icon: 'none',
duration: 2000
})
return;
}
if (!u_marketsum) {
wx.showToast({
title: '请填写销售总额',
icon: 'none',
duration: 2000
})
return;
}
if (!u_companydesc) {
wx.showToast({
title: '请填写企业简介',
icon: 'none',
duration: 2000
})
return;
}
if (!u_type) {
wx.showToast({
title: '请填写申请选项',
icon: 'none',
duration: 2000
})
return;
}
if (!u_image) {
wx.showToast({
title: '请上传图片',
icon: 'none',
duration: 2000
})
return;
}
if (!m_username) {
wx.showToast({
title: '请填写联系人姓名',
icon: 'none',
duration: 2000
})
return;
}
if (!check_tel.test(u_telphone)) {
wx.showToast({
title: '请填写正确手机号',
icon: 'none',
duration: 2000
})
return;
}
var web_url = app.globalData.web_url;
var web_url2 = web_url + "/Tjg/applyMember";
wx.uploadFile({
url: web_url2, //仅为示例,非真实的接口地址
filePath: that.data.img,
name: 'file',
formData: {
u_workname: u_workname,
u_corporate: u_corporate,
u_registernumber: u_registernumber,
u_registercapital: u_registercapital,
u_staffnumber: u_staffnumber,
u_capitalsum: u_capitalsum,
u_marketsum: u_marketsum,
u_companydesc: u_companydesc,
u_type: u_type,
m_username: m_username,
m_telphone: u_telphone,
},
success: function (res) {
console.log(res);
wx.showToast({
title: "申请成功",
icon: 'none',
duration: 2000
})
setTimeout(function(){
wx.redirectTo({
url: '/huitianxia/view/attend/attend/attend'
})
},1500)
}
})
// wx.request({
// url: web_url2,//接口地址
// data: {
// u_workname: u_workname,
// u_corporate: u_corporate,
// u_registernumber: u_registernumber,
// u_registercapital: u_registercapital,
// u_staffnumber: u_staffnumber,
// u_capitalsum: u_capitalsum,
// u_marketsum: u_marketsum,
// u_companydesc: u_companydesc,
// u_type: u_type,
// m_username: m_username,
// m_telphone: u_telphone,
// },
// header: {
// 'content-type': 'application/json'//默认值
// },
// success: function (res) {
// wx.showToast({
// title: res.data.message,
// icon: 'none',
// duration: 2000
// })
// }
// })
}
})
后台接口:
//申请成为会员
public function applyMember(){
$data['u_workname']=input("u_workname");
$data['u_corporate']=input("u_corporate");
$data['u_registernumber']=input("u_registernumber");
$data['u_registercapital']=input("u_registercapital");
$data['u_staffnumber']=input("u_staffnumber");
$data['u_capitalsum']=input("u_capitalsum");
$data['u_marketsum']=input("u_marketsum");
$data['u_companydesc']=input("u_companydesc");
$data['u_type']=input("u_type");
$data['m_username']=input("m_username");
$data['m_telphone']=input("m_telphone");
$data['u_create']=time();
//接受营业执照business
$file = request()->file('u_image');
if($file){
$info = $file->move(ROOT_PATH . 'public' . DS . 'business');
if($info){
// 成功上传后 获取上传信息
$data['u_image'] = $info->getSaveName();
//$servername="https://".$_SERVER['SERVER_NAME']."/beijinghuitianxia/public/business/";
$data['u_image'] = str_replace("\\","/", $data['u_image']);
//$data['u_image'] = $servername.$data['u_image'];
$res=Db::table('htx_member')->insertGetId($data);
if($res){
$result = array(
'code' => 1,
'message' => '申请成功!',
);
}else{
$result = array(
'code' => 0,
'message' => '申请错误!'
);
}
}else{
$error=$file->getError();
$result = array(
'code' => 0,
'message' => $error
);
}
}else{
$result = array(
'code' => 0,
'message' => '请上传图片!'
);
}
return json($result);
}