123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- const api = require('../../../utils/api.js');
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- array: ['中国', '美国', '巴西', '日本'],
- index:0,
- codetext:'获取验证码',
- current:0
- },
- bindPickerChange(e) {
- console.log('picker发送选择改变,携带值为', e.detail.value)
- this.setData({
- index: e.detail.value
- })
- },
- swiper:function(e){
- let that=this
- that.setData({
- current:e.detail.current
- })
- },
- code:function(){
- let that=this
- if (!that.data.phone||that.data.phone.split('').length!=11) {
- wx.showToast({
- title: '请输入正确的手机号',
- icon:'none'
- })
- return false
- }
- that.data.codetext = 59
- let timer = setInterval(function () {
- if (that.data.codetext == 0) {
- clearTimeout(timer)
- that.setData({
- codetext: '重新发送'
- })
- }
- that.setData({
- codetext: that.data.codetext
- })
- that.data.codetext--
- }, 1000);
- wx.request({
- url: api.sendPhoneCode,
- data: { 'phone': that.data.phone},
- success(res){
- console.log(res)
- }
- })
- },
- photo:function(){
- let that = this
- wx.chooseImage({
- count: 1,
- sizeType: ['original', 'compressed'],
- sourceType: ['album', 'camera'],
- success(res) {
- // tempFilePath可以作为img标签的src属性显示图片
- that.data.filePaths = res.tempFilePaths
- that.setData({
- photo: that.data.filePaths
- })
- }
- })
- },
- formSubmit:function(e){
- let that = this
- if (!that.data.photo){
- wx.showToast({
- title: '请选择照片',
- icon:'none'
- })
- return false
- }
- if (!e.detail.value.name && !e.detail.value.phone && !e.detail.value.idcard){
- wx.showToast({
- title: '请填写访客基本信息',
- icon: 'none'
- })
- return false
- }
- if (!e.detail.value.code){
- wx.showToast({
- title: '请填写短信验证码',
- icon: 'none'
- })
- return false
- }
- wx.uploadFile({
- url: 'http://192.168.100.234:8080/oneportal/visitor/editorAlumniVisitor.if',
- filePath: that.data.photo[0],
- header: { 'content-type': 'application/x-www-form-urlencoded;charset=utf-8', },
- name: 'file',
- formData: {
- 'inviteUserId': wx.getStorageSync('loginId'),
- 'visitorName': e.detail.value.name,
- 'visitorPhone': e.detail.value.phone,
- 'identity': that.data.array[parseInt(e.detail.value.type)],
- 'IDNumber': e.detail.value.idcard,
- 'phoneCode': e.detail.value.code,
- 'visitorReason': e.detail.value.text,
- 'remarks': '',
- },
- success(res) {
- console.log(res)
- if (JSON.parse(res.data).youtuMessage.errorno == 0) {
- wx.showToast({
- title: '上传成功',
- icon: 'none'
- })
- }
- }
- })
- },
- name:function(e){
- this.setData({
- name:e.detail.value
- })
- },
- idcard: function (e) {
- this.setData({
- idcard: e.detail.value
- })
- },
- phone: function (e) {
- this.setData({
- phone: e.detail.value
- })
- },
- text: function (e) {
- this.setData({
- text: e.detail.value
- })
- },
- previewImage:function(){
- wx.previewImage({
- urls: [this.data.filePaths[0]] // 需要预览的图片http链接列表
- })
- },
- next:function(){
- this.data.current++
- this.setData({
- current: this.data.current,
- swipercurrent: this.data.current
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|