123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- const app = getApp();
- Page({
- data: {
- // 设置上传案例图片的最大数目
- maxImages: 1,
- // 上传的案例图片集合
- QrcodeImages:[],
- // 案例图片数目是否达到了最大数目
- QrcodeImagesNum: false,
- Qrcodeimg: true,
- qrcode:"", // 二维码图片
- wx_user:"", // 微信号
- initial: [], //初始信息
- SubmissionHidden: true,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- var that = this;
- // 获取信息
- let initial_url = 'my/wxqrcode/wxqrcodechange';
- let initial_data = {
- };
- app.postRequest(initial_url, initial_data, function (res) {
- if (res.code == 201) {
- console.log(res.data);
- that.setData({
- initial: res.data, // 初始数据
- initialcode: res, //获取未上传状态
- })
- }
- if (res.data.status == 2) { //如果审核未通过 显示提交按钮
- that.setData({
- SubmissionHidden: false
- })
- } else if (res.code != 201) {
- that.setData({
- SubmissionHidden: false
- })
- } else {
- that.setData({
- SubmissionHidden: true
- })
- }
- })
- },
- // 上传手持身份证
- Qrcodeclick: function (e) {
- var _this = this;
- wx.chooseImage({
- count: 1,
- sizeType: ['original', 'compressed'],
- sourceType: ['album', 'camera'],
- success(res) {
- // console.log(res.tempFilePaths[0]);
- // tempFilePath可以作为img标签的src属性显示图片
- _this.setData({
- QrcodeImages: res.tempFilePaths,
- QrcodeImagesNum: true,
- Qrcodeimg: false,
- qrcode: res.tempFilePaths[0],
- });
- }
- })
- },
- //获取微信号
- WeChatNumber: function (e) {
- var wx_user = e.detail.value;
- // console.log(wx_user);
- this.setData({
- wx_user: wx_user
- });
- },
- // 最后提交认证
- Preservation: function (e) {
- // console.log(this.data.qrcode)
- // console.log(this.data.wx_user)
- var _this = this;
- if (this.data.qrcode != '') {
-
- wx.uploadFile({
- url: app.globalData.url + 'my/wxqrcode/setwxqrcode',
- filePath: this.data.qrcode,
- name: 'qrcode',
- formData: {
- key: wx.getStorageSync('access_key'),
- token: wx.getStorageSync('access_token'),
- 'wx_user': this.data.wx_user,
- },
- success: function (res) {
- var data = JSON.parse(res.data);
- if (data.code == 201) {
- wx.showToast({
- title: '上传成功',
- icon: 'success',
- duration: 2000
- })
-
- _this.onLoad();
- return;
- }
- var _qrcode = '上传失败'
- getApp().Tips(_qrcode);
- }, fail: function (d) {
- }
- })
- } else if (this.data.wx_user != '') {
-
- let setwxqrcode_url = 'my/wxqrcode/setwxqrcode';
- let setwxqrcode_data = {
- 'wx_user': this.data.wx_user,
- };
- app.postRequest(setwxqrcode_url, setwxqrcode_data, function (res) {
- if (res.code == 201) {
- wx.showToast({
- title: '上传成功',
- icon: 'success',
- duration: 2000
- })
- _this.onLoad();
- return;
- }
- var _qrcode = '上传失败'
- getApp().Tips(_qrcode);
- })
- }else{
- var _qrcode = '微信二维码与微信号,任选一项进行完善'
- getApp().Tips(_qrcode);
- }
- },
- })
|