my_service.js 3.42 KB
var e = getApp(),
  a = e.globalData.setting,
  os = a,
  t = e.request;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    qr_code_object: {
      val: "12121",
      content: "请将二维码展示给核销员,服务更快捷!"
    },
    iurl: a.imghost,
    service_List: null, //服务项目列表
    is_service_read: 0,
    curpage: 1,
    total: 0,
    ismore: 0,
    userinfo: null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var userinfo = getApp().globalData.userInfo;
    if (userinfo == null) {
      //界面必须使用warn 做ID,并调用
      getApp().my_warnning("会员为空", 0, this);
      return false;
    }
    this.setData({
      userinfo: userinfo
    });
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    var th = this;
    th.query_service();
  },
  onReachBottom: function() {
    if (this.data.total <= 8) return;
    if (this.data.ismore) return;
    this.query_service();
  },
  //查询服务项目列表
  query_service: function() {
    var th = this;
    var url = "http://localhost:8022/api/weshop/users/grade/wechat/cash/page";
    // //获取服务项目
    // getApp().request.promiseGet("/api/weshop/users/grade/wechat/cash/page", {

    // }).then(res => {
    //        console.log("11111111111"+res);
    // })
    wx.request({
      url: "http://localhost:8022/api/weshop/yy_fuwu_list",
      success: function(res) {

        console.log("11111111111" + res.data.data.pageData);
        if (res.data.code == 0) {

          // th.data.curpage++;
          // var arr1 = th.data.service_List;
          // var arr2 = res.data.data.pageData;
          // var arr3 = [...arr1, ...arr2];

          // var ismore = 0;
          // if (arr3.length == res.data.data.total) ismore = 1

          // th.setData({
          //   service_List: arr3,
          //   total: res.data.data.total,
          //   ismore: ismore,
          //   is_service_read: 1
          // }), wx.stopPullDownRefresh(); //停止下拉刷新

          th.setData({
            service_List: res.data.data.pageData
          })
          console.log(th.data.service_List.name + "111");
        }
      }
    })
  },
  /*-- 打开服务项目 --*/
  open_fw: function(e) {
    var th = this;
    var ind = e.currentTarget.dataset.ind;
    var item = this.data.service_List[ind];

    var ewm = "^" + this.data.userinfo.erpvipid + "|" + item.id + "|" + item.type_b + "|" + item.time+ "|TY01|";
    var tt = th.format_time(1);
    ewm = ewm + tt;
    th.data.qr_code_object.val = ewm;
    th.data.qr_code_object.is_fw = 1;
    console.log(ewm);
    var qc_com = th.selectComponent("#qc_com"); //组件的id
    qc_com.open(th.data.qr_code_object)
  },
  //图片失败,默认图片
  bind_bnerr1: function(e) {
    var _errImg = e.target.dataset.errorimg;
    var _Img = e.target.dataset.img;
    if (_Img != undefined) {
      var _errObj = {};
      _errObj[_errImg] = "/miniapp/images/no_cate_def.png";
      this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
    }
  },
  format_time: function(isFull) {
    var d = new Date();
    var m = d.getMonth() + 1;
    if (m < 10) m = "0" + m;
    var dd = d.getDate();
    if (dd < 10) dd = "0" + dd;
    var fm = [d.getFullYear(), m, dd].join('-');
    if (isFull == 1)
      fm = fm + ' ' + [d.getHours(), d.getMinutes(), d.getSeconds()].join(':')
    return fm;
  },
})