// pages/getMerchant/index.js const config = require('../../config/config.js') const Http = require('../../utils/HttpBasics.js') const util = require('../../utils/util.js') const app = getApp(); Page({ /** * 页面的初始数据 */ data: { phone:'', paramData:[] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { console.log(options) this.setData({ paramData: options }) if (options.a == 2){ tt.setNavigationBarTitle({ title: '会员赠券' }) }else{ tt.setNavigationBarTitle({ title: '会员积分' }) } },//204391258 /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, checkMerchant(e) { let id = e.target.id; this.data.selectList.map((item, index) => { if (id == item.id) { this.setData({ selectMerchant: item`` }) } }) }, submitForm() { const reg = /^1[0|1|2|3|4|5|6|7|8|9]\d{9}$/; let _this=this; if (!reg.test(this.data.phone)) { tt.showToast({ title: '抱歉,请输入正确的手机号', icon: 'none', duration: 2000, mask: false }); return; } Http.get({ url: config.api.findByPhone, data: { phone: _this.data.phone, } }) .then(res => { if (res.data.id){ if(res.data.status == 1){ tt.showModal({ title: "抱歉", content: "会员已被锁定", showCancel: false }) return; } if (this.data.paramData.a == 1){ tt.setStorageSync("avatarUrl", res.data.avatarUrl?res.data.avatarUrl:''); tt.navigateTo({ url: `/pages/Add/index?id=${res.data.id}&levelName=${res.data.level}&nickName=${res.data.nickName}&name=${res.data.name}&phone=${res.data.phone}&score=${res.data.score}&credit=${res.data.credit}` }) } if (this.data.paramData.a == 2) { tt.setStorageSync("avatarUrl", res.data.avatarUrl?res.data.avatarUrl:''); tt.navigateTo({ url: `/pages/giveCoupon/index?id=${res.data.id}&levelName=${res.data.level}&nickName=${res.data.nickName}&name=${res.data.name}&phone=${res .data.phone}&score=${res.data.score}&credit=${res.data.credit}` }) } }else{ tt.showToast({ title: '抱歉,会员信息不存在!', icon: 'none', duration: 2000, mask: false }); } }) .catch(err => { tt.showToast({ title: err.message, icon: 'none', duration: 2000, mask: false }); }); }, getList(e) { console.log(e.detail.value) this.setData({ phone: e.detail.value }) }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })