|
|
@@ -0,0 +1,347 @@
|
|
|
+import {
|
|
|
+ ApiModel
|
|
|
+} from "../../utils/api";
|
|
|
+const _Http = new ApiModel();
|
|
|
+import {
|
|
|
+ TestVerify
|
|
|
+} from "../../utils/verify"
|
|
|
+const _Verify = new TestVerify();
|
|
|
+const utilMd5 = require('../../utils/md5');
|
|
|
+let countDownTime1 = null;
|
|
|
+Page({
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面的初始数据
|
|
|
+ */
|
|
|
+ data: {
|
|
|
+ tabsList: ['身份信息'], //tabs
|
|
|
+ pageType: 0, //0报名 1查看二维码
|
|
|
+ rulesChecked: true, //同意用户隐私协议
|
|
|
+ isNoToken: false, //是否存在登录
|
|
|
+ countDownTime: 30, //倒计时
|
|
|
+ tactivityid: 2, //展会id
|
|
|
+ fname: "", //姓名
|
|
|
+ fidcard: "", //身份证号
|
|
|
+ fphonenumber: "", //手机号
|
|
|
+ password: '', //验证码
|
|
|
+ fcompname: "", //公司
|
|
|
+ frole: "", //职位
|
|
|
+ findustry: "", //行业
|
|
|
+ faddress: "", //地址
|
|
|
+ fchannel: "", //入会渠道
|
|
|
+ errTips: {
|
|
|
+ fname: false, //姓名
|
|
|
+ fidcard: false, //身份证号
|
|
|
+ fphonenumber: false, //手机号
|
|
|
+ password: false, //验证码
|
|
|
+ fcompname: false, //公司
|
|
|
+ frole: false, //职位
|
|
|
+ findustry: false, //行业
|
|
|
+ },
|
|
|
+ throttle: false, //截流
|
|
|
+ msg: null,
|
|
|
+ myShowModel: false, //角色选择
|
|
|
+ userIndex: null, //选择账号下标
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面加载
|
|
|
+ */
|
|
|
+ onLoad: function (options) {
|
|
|
+ /* this.setData({
|
|
|
+ tactivityid: options.id
|
|
|
+ }) */
|
|
|
+ //判断是否存在登录态
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('userData').token,
|
|
|
+ "classname": "customer.activity.activitysignup",
|
|
|
+ "method": "getsignupmsg",
|
|
|
+ "content": {
|
|
|
+ "tactivityid": 2
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("获取个人信息", res)
|
|
|
+ if (res.msg == '失败') {
|
|
|
+ this.setData({
|
|
|
+ isNoToken: true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ if (res.data.length >= 1) {
|
|
|
+ this.setData({
|
|
|
+ pageType: 1,
|
|
|
+ msg: res.data[0]
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 获取验证码 */
|
|
|
+ getVerifyCode() {
|
|
|
+ //验证手机号码
|
|
|
+ if (!_Verify.phoneNumber(this.data.fphonenumber, 1)) return this.setData({
|
|
|
+ "errTips.fphonenumber": true
|
|
|
+ });
|
|
|
+ /* 倒计时中阻止 */
|
|
|
+ if (this.data.countDownTime != 30) return wx.showToast({
|
|
|
+ title: '请勿重复获取验证码',
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ _Http.getPassword({
|
|
|
+ "phonenumber": this.data.fphonenumber,
|
|
|
+ "client": "wechat_customer"
|
|
|
+ }).then(res => {
|
|
|
+ this.setData({
|
|
|
+ countDownTime: this.data.countDownTime - 1
|
|
|
+ })
|
|
|
+ countDownTime1 = setInterval(() => {
|
|
|
+ if (this.data.countDownTime != 0) {
|
|
|
+ this.setData({
|
|
|
+ countDownTime: this.data.countDownTime - 1
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ clearInterval(countDownTime1);
|
|
|
+ this.setData({
|
|
|
+ countDownTime: 30
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
+ wx.showToast({
|
|
|
+ title: res.msg,
|
|
|
+ icon: "none",
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //验证必填项
|
|
|
+ verify() {
|
|
|
+ let errTips = this.data.errTips,
|
|
|
+ result = false;
|
|
|
+ for (let key in this.data.errTips) {
|
|
|
+ if (this.data.isNoToken) {
|
|
|
+ if (this.data[key] == '') {
|
|
|
+ errTips[key] = true;
|
|
|
+ result = true;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (this.data[key] == '' && key != 'password') {
|
|
|
+ errTips[key] = true;
|
|
|
+ result = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ this.setData({
|
|
|
+ errTips
|
|
|
+ })
|
|
|
+ return result;
|
|
|
+ },
|
|
|
+ /* 提交表单 */
|
|
|
+ submitData() {
|
|
|
+ if (this.verify()) return wx.showToast({
|
|
|
+ title: '请完善表格必填项',
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ if (this.data.throttle) return;
|
|
|
+ if (!this.data.isNoToken) {
|
|
|
+ //存在登录态,直接提交
|
|
|
+ this.signup(wx.getStorageSync('userData').token);
|
|
|
+ } else {
|
|
|
+ //未存在登录态,先登录在提交
|
|
|
+ if (!this.data.password) {
|
|
|
+ this.setData({
|
|
|
+ "errTips.password": true
|
|
|
+ })
|
|
|
+ return wx.showToast({
|
|
|
+ title: '还未填写验证码',
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ };
|
|
|
+ _Http.login({
|
|
|
+ "phonenumber": this.data.fphonenumber,
|
|
|
+ "password": utilMd5.hexMD5(this.data.password),
|
|
|
+ "client": "wechat_customer"
|
|
|
+ }).then(res => {
|
|
|
+ /* 结果验证 */
|
|
|
+ if (res.msg != '成功') {
|
|
|
+ this.setData({
|
|
|
+ "errTips.password": true
|
|
|
+ });
|
|
|
+ return wx.showToast({
|
|
|
+ title: '账号或验证码错误!',
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ console.log("用户登录", res)
|
|
|
+ if (res.account_list.length == 1) {
|
|
|
+ this.signup(res.account_list[0].token);
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ account_list: res.account_list,
|
|
|
+ myShowModel: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /* 获取焦点 */
|
|
|
+ inputFocus(e) {
|
|
|
+ const {
|
|
|
+ name
|
|
|
+ } = e.currentTarget.dataset;
|
|
|
+ let errTips = this.data.errTips;
|
|
|
+ errTips[name] = false;
|
|
|
+ this.setData({
|
|
|
+ errTips
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 失去焦点 */
|
|
|
+ inputBlur(e) {
|
|
|
+ const {
|
|
|
+ name
|
|
|
+ } = e.currentTarget.dataset;
|
|
|
+ const {
|
|
|
+ value
|
|
|
+ } = e.detail;
|
|
|
+ if (name == 'fphonenumber') {
|
|
|
+ if (!_Verify.phoneNumber(this.data.fphonenumber, 1)) return this.setData({
|
|
|
+ "errTips.fphonenumber": true
|
|
|
+ })
|
|
|
+ };
|
|
|
+ if (value.trim() == "") {
|
|
|
+ let errTips = this.data.errTips;
|
|
|
+ errTips[name] = true;
|
|
|
+ this.setData({
|
|
|
+ errTips
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /* 选择用户 */
|
|
|
+ userSelect(e) {
|
|
|
+ console.log(e)
|
|
|
+ const {index,item} = e.currentTarget.dataset;
|
|
|
+ this.setData({
|
|
|
+ userIndex:index
|
|
|
+ })
|
|
|
+ wx.setStorageSync('userData', item);
|
|
|
+ this.signup(item.token)
|
|
|
+ },
|
|
|
+ /* 提交报名表 */
|
|
|
+ signup(token) {
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": token,
|
|
|
+ "classname": "customer.activity.activitysignup",
|
|
|
+ "method": "signup",
|
|
|
+ "content": {
|
|
|
+ "fname": this.data.fname,
|
|
|
+ "fidcard": this.data.fidcard,
|
|
|
+ "fphonenumber": this.data.fphonenumber,
|
|
|
+ "fcompname": this.data.fcompname,
|
|
|
+ "frole": this.data.frole,
|
|
|
+ "findustry": this.data.findustry,
|
|
|
+ "faddress": this.data.faddress,
|
|
|
+ "fchannel": this.data.fchannel,
|
|
|
+ "tactivityid": this.data.tactivityid
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("提交报名", res)
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ throttle: true
|
|
|
+ });
|
|
|
+ wx.showToast({
|
|
|
+ title: '报名成功'
|
|
|
+ })
|
|
|
+ setTimeout(() => {
|
|
|
+ wx.navigateBack({
|
|
|
+ delta: 1,
|
|
|
+ })
|
|
|
+ }, 500);
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* input事件剔除特殊字符 */
|
|
|
+ eliminate(value) {
|
|
|
+ const {
|
|
|
+ name
|
|
|
+ } = value.target.dataset;
|
|
|
+ this.setData({
|
|
|
+ [name]: _Verify.Eliminate(value.detail)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 用户守则 */
|
|
|
+ rulesOnChange() {
|
|
|
+ this.setData({
|
|
|
+ rulesChecked: !this.data.rulesChecked
|
|
|
+ })
|
|
|
+ },
|
|
|
+ viewRules() {
|
|
|
+ wx.downloadFile({
|
|
|
+ url: 'https://bwj.obs.cn-east-2.myhuaweicloud.com/resources/PrivacyPolicy.docx',
|
|
|
+ success: (res) => {
|
|
|
+ console.log(res)
|
|
|
+ wx.openDocument({
|
|
|
+ filePath: res.tempFilePath,
|
|
|
+ fail: (err) => {
|
|
|
+ console.log(err)
|
|
|
+ wx.showToast({
|
|
|
+ title: '读取失败,请稍后再试',
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: (err) => {
|
|
|
+ console.log(err)
|
|
|
+ wx.showToast({
|
|
|
+ title: '读取失败,请稍后再试',
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面初次渲染完成
|
|
|
+ */
|
|
|
+ onReady: function () {
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面显示
|
|
|
+ */
|
|
|
+ onShow: function () {
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面隐藏
|
|
|
+ */
|
|
|
+ onHide: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生命周期函数--监听页面卸载
|
|
|
+ */
|
|
|
+ onUnload: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面相关事件处理函数--监听用户下拉动作
|
|
|
+ */
|
|
|
+ onPullDownRefresh: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面上拉触底事件的处理函数
|
|
|
+ */
|
|
|
+ onReachBottom: function () {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户点击右上角分享
|
|
|
+ */
|
|
|
+ onShareAppMessage: function () {
|
|
|
+
|
|
|
+ }
|
|
|
+})
|