import {url} from '../request' Page({ data: { selectedCity:'', xuanran:[], inputtext:'', }, onShow(){ this.chaxun(); my.getLocation({ type: 1, // 获取包括省市区县数据 success: (res) => { console.log('定位成功:', res); this.setData({ selectedCity: res.city // 将城市名称设置到 selectedCity }); }, fail: (error) => { console.error('定位失败:', error); my.alert({ title: '定位失败', content: '无法获取当前位置,请检查定位权限设置。' }); this.setData({ selectedCity: '定位失败' }); } }); }, chaxun(){ my.request({ url: url + '/api/business/list', method: 'POST', data: { }, headers: { 'content-type': 'application/json', }, dataType: 'json', success: (res) => { console.log('Request succeeded:', res); if (res.data && res.data.data) { this.setData({ xuanran: res.data.data, // 更新 tuijian 列表 }); } else { console.log('shibaile') } }, fail: (error) => { console.error('Request failed', error); } }); }, onConfirm(){ my.request({ url: url + '/api/business/list/page/vo', method: 'POST', data: { address: this.data.selectedCity, businessName: this.data.inputtext, businessProfile: "", categoryId: "", current: 1, id: "", pageSize: 20, sortField: "", sortOrder: "", state: "", storeStatus: "", userId: "" }, headers: { 'content-type': 'application/json', }, dataType: 'json', success: (res) => { console.log('Request succeeded:', res); if (res.data && res.data.data) { this.setData({ xuanran:res.data.data.records }) } else { console.log('shibaile') } }, fail: (error) => { console.error('Request failed', error); } }); }, dianpu(item) { const id = item.target.dataset.num // console.log('传递的数据:', id); const ID = id.id console.log(ID); const userId = id.userId const address = id.address const businessName = id.businessName const businessAvatar = id.businessAvatar const endBusiness = id.endBusiness const startBusiness = id.startBusiness const storeStatus = id.storeStatus const businessPhone =id.businessPhone console.log('Address being passed: ', ID,address,businessName,businessAvatar,endBusiness,startBusiness,businessPhone); my.navigateTo({ url: `/pages/shnagmendianpu/shnagmendianpu?userId=${userId}&&address=${address}&&businessName=${businessName}&&businessAvatar=${businessAvatar}&&startBusiness=${startBusiness}&&endBusiness=${endBusiness}&&storeStatus=${storeStatus}&&id=${ID}&&businessPhone=${businessPhone}`, }); }, onChange(e) { this.setData({ inputtext:e.detail.value, }); console.log(e.detail.value); console.log(this.data.inputtext); }, });