jiaqingjiayi-xiaochengxu/甲情_甲意/miniprogram/pages/shangmenyuyue/shangmenyuyue.js

128 lines
3.3 KiB
JavaScript
Raw Normal View History

2024-12-17 11:46:10 +00:00
import {url} from '../request'
2024-11-10 07:01:22 +00:00
Page({
data: {
2024-12-10 10:35:22 +00:00
selectedCity:'',
2024-12-17 11:46:10 +00:00
xuanran:[],
inputtext:'',
2024-11-10 07:01:22 +00:00
},
2024-12-10 10:35:22 +00:00
onShow(){
2024-12-17 11:46:10 +00:00
this.chaxun();
2024-12-10 10:35:22 +00:00
my.getLocation({
type: 1, // 获取包括省市区县数据
success: (res) => {
console.log('定位成功:', res);
2024-11-10 07:01:22 +00:00
this.setData({
2024-12-10 10:35:22 +00:00
selectedCity: res.city // 将城市名称设置到 selectedCity
});
},
fail: (error) => {
console.error('定位失败:', error);
my.alert({
title: '定位失败',
content: '无法获取当前位置,请检查定位权限设置。'
});
this.setData({
selectedCity: '定位失败'
});
2024-11-10 07:01:22 +00:00
}
2024-12-10 10:35:22 +00:00
});
2024-12-17 11:46:10 +00:00
},
chaxun(){
my.request({
2025-01-21 13:56:53 +00:00
url: url + '/api/business/listLv',
2024-12-17 11:46:10 +00:00
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 列表
});
2025-01-21 13:56:53 +00:00
console.log(this.data.xuanran,'askjdsakldlasjdl');
2024-12-17 11:46:10 +00:00
} 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
2025-01-21 13:56:53 +00:00
const level =id.level
console.log('Address being passed: ',level, ID,address,businessName,businessAvatar,endBusiness,startBusiness,businessPhone);
2024-12-17 11:46:10 +00:00
my.navigateTo({
2025-01-21 13:56:53 +00:00
url: `/pages/shnagmendianpu/shnagmendianpu?userId=${userId}
&&address=${address}&&businessName=${businessName}
&&businessAvatar=${businessAvatar}&&startBusiness=${startBusiness}
&&endBusiness=${endBusiness}&&storeStatus=${storeStatus}
&&id=${ID}&&businessPhone=${businessPhone}&&level=${level}`,
2024-12-17 11:46:10 +00:00
});
},
2025-01-13 13:07:00 +00:00
onChange(e) {
2024-12-17 11:46:10 +00:00
this.setData({
2025-01-13 13:07:00 +00:00
inputtext:e.detail.value,
});
console.log(e.detail.value);
2024-12-17 11:46:10 +00:00
console.log(this.data.inputtext);
},
2025-01-13 13:07:00 +00:00
2024-11-10 07:01:22 +00:00
});