123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- // pages/OfflinePayment/OfflinePayment.js
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- kid: '',
- deposit: '',
- agree: true,
- img:'',
- fileid: '',
- bidding_agreement_path:'',
- bidding_rules_path:'',
- },
- formSubmit: function(e) {
-
- var _this = this;
- var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
- var format = /^(([1][1-5])|([2][1-3])|([3][1-7])|([4][1-6])|([5][0-4])|([6][1-5])|([7][1])|([8][1-2]))\d{4}(([1][9]\d{2})|([2]\d{3}))(([0][1-9])|([1][0-2]))(([0][1-9])|([1-2][0-9])|([3][0-1]))\d{3}[0-9xX]$/;
- var receive_mobile = e.detail.value.number;
- var id_card = e.detail.value.card;
- var company_name = e.detail.value.company_name;
- if (company_name == '' || company_name == undefined) {
- wx.showToast({
- title: '公司名称不能为空',
- icon: 'none',
- duration: 2000
- });
- } else if (!myreg.test(receive_mobile) || receive_mobile == "" || receive_mobile == undefined) {
- wx.showToast({
- title: '请输入正确的手机号',
- icon: 'none',
- duration: 2000
- });
- } else if (!format.test(id_card) || id_card == "" || id_card == undefined) {
- wx.showToast({
- title: '请输入正确格式的身份证号',
- icon: 'none',
- duration: 2000
- });
- } else if (this.data.agree) {
- wx.request({
- url: app.globalData.prodUrl + 'web-pm/wx/submit/offline_apply',
- data: {
- pm_item_id: this.data.kid,
- receive_name: e.detail.value.name,
- receive_mobile: receive_mobile,
- id_card: id_card,
- company_name: company_name,
- file_id:this.data.fileid,
- },
- header: {
- 'ydw-token': wx.getStorageSync('key').ydw_token
- },
- method: 'GET',
- dataType: 'json',
- responseType: 'text',
- success: function(res) {
-
- if (res.statusCode == 200) {
- wx.navigateBack({})
- }
- },
- fail: function(res) {}
- })
- } else {
- wx.showToast({
- title: '请确认同意《用户竞买协议》和《保证金规则》',
- icon: 'none',
- duration: 3000,
- success: function(res) {
-
- }
- })
- }
- },
-
- // 选择图片
- selectimg: function () {
- const that = this;
- wx.chooseImage({
- count: 1, // 最多可以选择的图片张数(最大数量-当前已上传数量)
- sizeType: ['original', 'compressed'],
- sourceType: ['album', 'camera'],
- success: function (res) {
-
- that.setData({
- img: res.tempFilePaths[0]
- });
- var imgUrl = res.tempFilePaths[0];
-
- wx.uploadFile({
- //上传图片的网路请求地址
- url: app.globalData.prodUrl + 'web-cp-all/upload_pm/upload',
- //选择
- filePath: imgUrl,
- name: 'file',
-
- method: "POST",
- success: function (res) {
- that.setData({
- fileid: JSON.parse(res.data).file_id
- })
- },
- fail: function (res) {
- wx.showToast({
- title: keyurl.message + '请重新上传',
- icon: 'none'
- })
- }
- });
- },
- })
- },
- // 图片预览
- previewImage: function(e) {
- var current = e.target.dataset.src
- wx.previewImage({
- current: current,
- urls: this.data.img,
- })
- },
- // 删除图片(选中图片移除)
- delImg: function (e) {
- const that = this;
- that.setData({
- img: '',
- })
- },
-
- // 勾选同意协议事件
- checkboxChange: function(e) {
- if (e.detail.value[0] === '确认同意') {
- this.setData({
- agree: true
- })
- } else {
- this.setData({
- agree: false
- })
- }
- },
- getWeiz: function(e) {
- var name = e.target.dataset.name;
- var lat = e.target.dataset.lat;
- var lng = e.target.dataset.lng;
- wx.openLocation({ //使用微信内置地图查看位置。
- name: name,
- scale: 28,
- address: name
- })
- },
- // 点击事件
- openFile(event) { // item为当前点击的事物对象
- // 预览网络文档
- wx.downloadFile({
- url: event.currentTarget.dataset.id, // 文件的本身url
- filePath: wx.env.USER_DATA_PATH + '/res' , // 本地自定义的文件名
- success: function (res) {
- let filePath = res.filePath; // 微信临时文件路径(这里要使用自定义的名字文件名,否则打开的文件名是乱码)
- wx.openDocument({
- filePath: filePath,
- fileType: 'pdf',
- success: function () {
- },
- });
- },
- });
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- this.setData({
- kid: options.kid,
- deposit: options.deposit,
- bidding_agreement_path:options.bidding_agreement_path,
- bidding_rules_path:options.bidding_rules_path,
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function() {
- }
- })
|