审查视图

刘晓艳 authored
1 2 3 4 5 6
//app.js
import md5 from 'utils/md5.js';
App({
  post: function(url, data) {
    wx.showNavigationBarLoading()
    wx.showLoading({
7
      title: '加载中',
刘晓艳 authored
8 9 10 11
    })
    var promise = new Promise((resolve, reject) => {
      let that = this;
      let postData = data;
朱振飞 authored
12
      let baseUrl = 'https://insurance.w.broteam.cn/';
刘晓艳 authored
13 14 15 16 17 18 19 20 21
      wx.request({
        url: baseUrl + url,
        data: postData,
        method: 'POST',
        header: {
          'content-type': 'application/x-www-form-urlencoded'
        },
        success: function(res) {
          resolve(res)
22
          wx.hideLoading()
刘晓艳 authored
23 24
          wx.hideNavigationBarLoading()
        },
25
        fail: function(e) {
刘晓艳 authored
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
          reject('');
          wx.hideLoading()
          wx.hideNavigationBarLoading()
          wx.showModal({
            title: '',
            content: res.data.msg,
            showCancel: false
          })
        }
      })
    });
    return promise;
    console.log(promise)
  },
  formCollect(id) {
    let url = 'sign/formid'
    let params = {
      formid: id,
      openid: wx.getStorageSync('openId')
    }
    this.post(url, params).then((res) => {
      console.log(res)
    }).catch((errMsg) => {

    })
  },
  nowDate() {
    let date = new Date();
    let month = date.getMonth() + 1;
    let day = date.getDate();
    return date.getFullYear() + '-' + (month > 9 ? month : ('0' + month)) + '-' + (day > 9 ? day : ('0' + day));
  },
  initDate(a) {
    let date1 = new Date();
    let time1 = date1.getFullYear() + "-" + (date1.getMonth() + 1) + "-" + date1.getDate();
    let date2 = new Date(date1);
    date2.setDate(date1.getDate() + a);
    let time2 = date2.getFullYear() + "-" + (date2.getMonth() + 1) + "-" + date2.getDate();
    return time2;
  },
  // 数组移除指定元素
  arryRemove(arr, item) {
    return arr.filter(function(ele) {
      return ele != item;
    })
  },
  strTime(strtime) {
    let str = 'bronet' + strtime + 'beijing'
    return md5(md5(str))
  },
  globalData: {
    userInfo: null,
    OpenId: '', //用户openid
    UserId: '', //用户userid
    UserType: '', //用户类型(2为普通会员,3为顾问,4为推广)
    checkstatus: '', //分享参数(0为无分享参数,1为保单分享,2为注册分享,3为文章分享)
    UserStatus: '', //用户状态(1初次登录需要授权操作,2多次登录不需要授权)
    PublishId: '', //如果是保单分享返回保单id
刘晓艳 authored
84 85 86
    NewsId: '', //如果是文章分享返回文章id
    temp_UserType:'',
    user_index:''
刘晓艳 authored
87 88
  }
})