|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- // 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: {
- selectList:[],
- list: [],
- selectMerchant:null,
- businessId:''
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- paramData: options
- })
- this.getMerchent()
- },
- getMerchent() {
- let _this = this;
- Http.get({
- url: config.api.getMerchentList
- })
- .then(res => {
- _this.setData({
- list: res.data,
- selectList:res.data
- })
- })
- .catch(err => {
- tt.showToast({
- title: err.message,
- icon: 'none',
- duration: 2000,
- mask: false
- });
- });
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
- checkMerchant(e){
- console.log(e)
- let id=e.target.id;
- this.data.selectList.map((item,index)=>{
- if(id==item.id){
- console.log(item,item.businessId)
- this.setData({
- selectMerchant:item,
- businessId: item.businessId
- })
- }
- })
- },
- submitForm(){
- if (this.data.selectMerchant!=null){
- tt.redirectTo({
- url: `/pages/operation/index?address=${this.data.paramData.address}&id=${this.data.paramData.id}&levelName=${this.data.paramData.levelName}&name=${this.data.paramData.name}&nickName=${this.data.paramData.nickName}&phone=${this.data.paramData.phone}&score=${this.data.paramData.score}&credit=${this.data.paramData.credit}&type=1&merchantName=${this.data.selectMerchant.merchantName}&merchant_id=${this.data.selectMerchant.id}&isAdmin=1&merchantType=1&businessId=${this.data.businessId}`,
- })
- }else{
- tt.showToast({
- title: '抱歉,您未选择门店',
- icon: 'none',
- duration: 2000,
- mask: false
- });
- }
- },
- getList(e){
- console.log(e.detail.value)
- let selectList = [];
- var reg = new RegExp(e.detail.value.toUpperCase());
- this.data.list.map((item,index)=>{
- if (item.merchantName.toUpperCase().match(reg) || e.detail.value==''){
- selectList.push(item)
- }
- })
- let haveIf=false;
- selectList.map((item,index)=>{
- console.log(item,this.data.selectMerchant)
- if (this.data.selectMerchant!=null&&item.id == this.data.selectMerchant.id){
- haveIf=true
- }
- })
- if (!haveIf){
- this.setData({
- selectMerchant:null
- })
- }
- // debugger
- this.setData({
- selectList
- })
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
- }
- })
|