修复了已知问题

This commit is contained in:
Ling53666 2024-11-19 18:12:40 +08:00
parent 7dfe547728
commit 223147de98
10 changed files with 392 additions and 220 deletions

View File

@ -1,11 +1,36 @@
App({ App({
onLaunch(options) { globalData: {
// 第一次打开 isLoggedIn: false, // 用户登录状态
// options.query == {number:1} userInfo: null, // 用户信息
console.info('App onLaunch');
}, },
onShow(options) {
// 从后台被 scheme 重新打开 onLaunch() {
// options.query == {number:1} // 从本地存储读取登录信息
const userInfo = my.getStorageSync({ key: 'user_info' }).data;
if (userInfo) {
this.globalData.isLoggedIn = true;
this.globalData.userInfo = userInfo;
}
}, },
});
setUserInfo(userInfo) {
// 设置全局用户信息
this.globalData.isLoggedIn = true;
this.globalData.userInfo = userInfo;
// 同步存储到本地
my.setStorageSync({
key: 'user_info',
data: userInfo
});
},
clearUserInfo() {
// 清空全局用户信息
this.globalData.isLoggedIn = false;
this.globalData.userInfo = null;
// 清除本地存储
my.removeStorageSync({ key: 'user_info' });
}
})

View File

@ -1,48 +1,60 @@
import {url} from '../request' import {url} from '../request'
Page({ Page({
data:{ data: {
authCode:'', authCode: '',
}, },
Login(){
Login() {
my.getAuthCode({ my.getAuthCode({
scopes: 'auth_user', scopes: 'auth_user',
success: res => { success: res => {
const authCode = res.authCode; const authCode = res.authCode;
console.log(typeof authCode); console.log(typeof authCode);
console.log(authCode) console.log(authCode);
// 请求后端接口进行用户登录
my.request({ my.request({
url: url+'/api/Alipay/parseCode', url: url + '/api/Alipay/parseCode',
data: { data: {
authCode, authCode,
}, },
success(res){ success: (res) => {
const { username, avatarUrl } = res.data.data; const { username, avatarUrl,} = res.data.data;
my.setStorageSync({ const setCookie = res.header['Set-Cookie'];
key: 'user_info', // 存储用户信息到本地存储
my.setStorage({
key: 'userInfo',
data: { data: {
username:username, username: username,
avatarUrl:avatarUrl, avatarUrl: avatarUrl,
cookie:setCookie
}, },
success: function () {
console.log('用户信息已存储',cookie);
},
fail: function (err) {
console.error('存储失败:', err);
}
}); });
console.log(res)
console.log(username,avatarUrl)
// 登录成功后的处理逻辑
console.log(res);
my.alert({ my.alert({
title: '登录成功', title: '登录成功',
}); });
my.switchTab({ my.navigateBack();
url:'/pages/wode/wode' },
}) fail: (res) => {
console.log("登录失败:", res);
},
fail(res){
console.log("失败");
} }
}) });
} }
}) });
}, },
});
});

View File

@ -49,7 +49,7 @@ Page({
id:id, id:id,
}); });
my.request({ my.request({
url: url + '/api/commodities/list/page/commoditiesVO', url: url + '/api/commodities/list/page/commodities',
method: 'POST', method: 'POST',
data: { data: {
businessId: id, businessId: id,
@ -84,7 +84,7 @@ Page({
meijiahsi(){ meijiahsi(){
my.request({ my.request({
url: url + '/api/manicurist/userQueryAll', url: url + '/api/manicurist/userQueryAll',
method: 'POST', method: 'GET',
data: { data: {
businessId: this.data.id businessId: this.data.id
}, },
@ -119,14 +119,16 @@ Page({
}, },
shangpinjiemian(item){ shangpinjiemian(item){
const id = item.target.dataset.num const id = item.target.dataset.num
const ID = id.id console.log('传递的数据:', id);
const ids = id.id
const commoditiesPrice = id.commoditiesPrice const commoditiesPrice = id.commoditiesPrice
const commoditiesName = id.commoditiesName const commoditiesName = id.commoditiesName
const commoditiesImage = id.commoditiesImage const commoditiesImage = id.commoditiesImage
const businessId = id.businessId const businessId = id.businessId
console.log('Address being passed: ',id,commoditiesPrice,commoditiesName,commoditiesImage,businessId); console.log('Address being passed: ',id,commoditiesPrice,commoditiesName,commoditiesImage,businessId);
my.navigateTo({ my.navigateTo({
url:`/pages/shangpinjiemian/shangpinjiemian?commoditiesPrice=${commoditiesPrice}&&commoditiesName=${commoditiesName}&&commoditiesImage=${commoditiesImage}&&id=${ID}&&businessId=${businessId}` url:`/pages/shangpinjiemian/shangpinjiemian?commoditiesPrice=${commoditiesPrice}&&commoditiesName=${commoditiesName}&&commoditiesImage=${commoditiesImage}&&ids=${ids}&&businessId=${businessId}`
}) })
console.log(ids,businessId,commoditiesImage,commoditiesName,commoditiesPrice+'这是商品的')
} }
}); });

View File

@ -1,100 +1,82 @@
/* 顶部信息 */ .container {
.box1{ padding: 20px;
width: 390px; }
.section-title {
font-size: 18px;
font-weight: bold;
margin-bottom: 10px;
}
.input-row {
display: flex;
align-items: center;
padding: 10px 0;
border-bottom: 1px solid #ddd;
}
.label {
flex: 0 0 120px;
color: #333;
}
.input {
flex: 1;
border: none;
outline: none;
}
.avatar-upload {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
border: 1px solid #ddd;
width: 50px;
height: 50px; height: 50px;
background-color: #eec2c7; border-radius: 50%;
} }
.text1{
font-size: 22px; .icon {
top:10px; width: 20px;
left:140px; height: 20px;
position: absolute; color: #ccc;
font-weight: bolder;
} }
.text2{
font-size: 25px; .picker-placeholder {
top:80px; color: #999;
left:40px; display: flex;
position: absolute;
} }
/* 账号 */
.box2{ .upload-button {
width: 310px; display: flex;
height: 60px; justify-content: center;
top:89px; align-items: center;
left:39px; width: 50px;
position: relative; height: 50px;
background-color:darkgrey; border: 1px solid #ddd;
border-radius: 10px; border-radius: 10px;
margin-right: 10px;
} }
.box3{
width: 308px; .submit-button {
height: 58px; width: 100%;
top:1px; background-color: #007aff;
left:1px; color: white;
position: relative; text-align: center;
background-color: #ffffff; padding: 15px;
border-radius: 10px; border: none;
border-radius: 5px;
font-size: 16px;
margin-top: 20px;
} }
.z1{ .button {
color: darkgrey; background-color: #f3bfc1; /* Light pink background color */
left:50px; color: #000000; /* Text color */
top:20px; border-radius: 20px; /* Rounded edges */
position: absolute; padding: 10px 20px;
} text-align: center;
.box3 image{ font-size: 16px;
width: 40px; width: 320px;
height: 40px;
position: absolute;
top:8px;
left:8px;
}
/* 密码 */
.box4{
width: 310px;
height: 60px;
top:239px;
left:39px;
position: absolute;
background-color:darkgrey;
border-radius: 10px;
}
.box5{
width: 308px;
height: 58px;
top:1px;
left:1px;
position: absolute;
background-color: #ffffff;
border-radius: 10px;
}
.z2{
color: darkgrey;
left:50px;
top:20px;
position: absolute;
}
.box5 image{
width: 40px;
height: 40px;
position: absolute;
top:8px;
left:8px;
/* 登录按钮 */
}
.box6{
width: 310px;
height: 60px;
position: absolute;
top:360px;
left:40px;
background-color:#4095E5 ;
border-radius: 30px;
}
.z3{
font-size: 25px;
position: absolute;
color: #ffffff;
top:15px;
left:125px;
} }

View File

@ -1,24 +1,51 @@
<view> <view class="container">
<view class="box1"> <view class="section">
<text class="text1">商家登录</text> <view class="section-title">商家注册</view>
</view> <view class="input-row">
<text class="text2">商家登录</text> <text class="label">店铺名称</text>
<!-- 账号 --> <input class="input" placeholder="请输入店铺名称" onInput="businessName" />
<view class="box2"> </view>
<view class="box3"> <view class="input-row">
<text class="z1">请输入账号</text> <text class="label">联系人</text>
<image mode="scaleToFill" src="../image/账号.png" /> <input class="input" placeholder="请输入联系人姓名" onInput="person" />
<icon type="eye" />
</view> </view>
</view> </view>
<!-- 密码 -->
<view class="box4"> <view class="section">
<view class="box5">
<text class="z2">请输入密码</text>
<image mode="scaleToFill" src="../image/密码.png" /> <view class="input-row">
<text class="label">联系方式</text>
<input class="input" placeholder="请输入联系人电话" onInput="phone"/>
</view>
<view class="input-row">
<text class="label">身份证号</text>
<input class="input" placeholder="请输入身份证号" onInput="idcard"/>
</view>
</view>
<view class="section">
<view class="input-row">
<text class="label">请上传营业执照</text>
<ant-uploader
defaultFileList="{{defaultFileList}}"
onChange="onChange"
onUpload="onUpload"
onPreview="onPreview"
onRemove="onRemove"
/>
</view>
<view class="input-row">
<text class="label">请上传身份证照</text>
<ant-uploader
defaultFileList="{{defaultFileList}}"
onChange="onChange"
onUpload="onUpload"
onPreview="onPreview"
onRemove="onRemove"
/>
</view> </view>
</view> </view>
<!-- 登录按钮 --> <view class="button" onTap="ruzhu">提交申请</view>
<view class="box6"> </view>
<text class="z3">登录</text>
</view>
</view>

View File

@ -1,4 +1,55 @@
Page({ Page({
data: {}, data: {
},
onLoad() {}, onLoad() {},
ruzhu(){
// my.request({
// url: url+'/api/business/add',
// method: 'POST',
// data: {
// },
// headers: {
// 'content-type': 'application/json', //默认值
// },
// dataType: 'json',
// success: (res)=> {
// my.alert({ content: 'success' });
// },
// fail: function (error) {
// console.error('fail: ', JSON.stringify(error));
// },
// complete: function (res) {
// my.hideLoading();
// my.alert({ content: 'complete' });
// },
// });
my.alert({ content: '正在审核中,请耐心等待' });
my.navigateBack()
},
businessName(e) {
this.setData({
businessName: e.detail.value,
});
console.log(e.detail.value);
},
person(e) {
this.setData({
person: e.detail.value,
});
console.log(e.detail.value);
},
phone(e) {
this.setData({
phone: e.detail.value,
});
console.log(e.detail.value);
},
idcard(e) {
this.setData({
idcard: e.detail.value,
});
console.log(e.detail.value);
},
}); });

View File

@ -1,4 +1,8 @@
{ {
"usingComponents": {}, "defaultTitle": "商家入驻",
"usingComponents": {
"ant-uploader": "antd-mini/es/ImageUpload/index",
"ant-container": "antd-mini/es/Container/index"
},
"styleIsolation": "apply-shared" "styleIsolation": "apply-shared"
} }

View File

@ -1,69 +1,116 @@
import {url} from '../request' import {url} from '../request'
Page({ Page({
data: { data: {
commoditiesImage:'', commoditiesImage: '',
commoditiesPrice:'', commoditiesPrice: '',
commoditiesName:'', commoditiesName: '',
businessId:'', businessId: '',
ids: '',
items: [ items: [
{ { title: '项目详情' },
title: '项目详情', { title: '购买须知' },
}, { title: '评价' },
{ ],
title: '购买须知',
},
{
title: '评价',
},
],
}, },
onLoad(options) { onLoad(options) {
const commoditiesImage = options.commoditiesImage; const commoditiesImage = options.commoditiesImage;
const commoditiesName = options.commoditiesName; const commoditiesName = options.commoditiesName;
const commoditiesPrice = options.commoditiesPrice; const commoditiesPrice = options.commoditiesPrice;
const id = options.id; const ids = options.ids;
const businessId = options.businessId const businessId = options.businessId;
// Set them in data for use in the page
this.setData({ this.setData({
commoditiesImage: commoditiesImage, commoditiesImage: commoditiesImage,
commoditiesName: commoditiesName, commoditiesName: commoditiesName,
commoditiesPrice:commoditiesPrice, commoditiesPrice: commoditiesPrice,
id:id, ids: ids,
businessId:businessId businessId: businessId,
}); });
}, },
// 切换标签 // 切换标签
onChange(current) { onChange(current) {
this.setData({ this.setData({
current, current,
}); });
}, },
jiaru(){ onShow(){
my.request({ this.checkUserLogin
url: url+'/api/cart/add', },
method: 'POST', // 检查登录状态
data: { checkUserLogin() {
businessId: 1, my.getStorages({
commoditiesId: 1, key: 'userInfo',
quantity: 1, success: (res) => {
selectedOptions: "" if (res.data && res.data.openId) {
},
headers: { } else {
'content-type': 'application/json', //默认值
}, }
dataType: 'json', },
success:(res)=>{ fail: (err) => {
console.log(res); console.error('获取用户信息失败:', err);
my.alert({ content: 'success' }); },
}, });
fail: function (error) { },
console.error('fail: ', JSON.stringify(error));
},
complete: function (res) { jiaru() {
my.hideLoading(); // 获取本地存储的用户信息
my.alert({ content: 'complete' }); my.getStorage({
}, key: 'userInfo',
}); success: (res) => {
} const userInfo = res.data;
if (userInfo && userInfo.cookie) {
// 使用获取的 `cookie` 值
my.request({
url: url + '/api/cart/add',
method: 'POST',
data: {
businessId: this.data.businessId,
commoditiesId: this.data.ids,
quantity: 1,
selectedOptions: "",
},
headers: {
'content-type': 'application/json',
'Cookie': userInfo.cookie, // 通过头部传递 cookie
},
dataType: 'json',
success: (res) => {
console.log(res);
my.alert({ content: '成功添加到购物车' });
},
fail: (error) => {
console.error('请求失败: ', JSON.stringify(error));
my.alert({ content: '请求失败,请稍后重试' });
},
complete: () => {
my.hideLoading();
},
});
} else {
// 未登录时跳转到登录页面
my.alert({
content: '您未登录,请先登录。',
success: () => {
my.navigateTo({
url: '/pages/denglu/denglu',
});
},
});
}
},
fail: (err) => {
console.error('获取用户信息失败:', err);
my.alert({
content: '获取用户信息失败,请重试。',
});
}
});
},
}); });

View File

@ -57,6 +57,7 @@ Page({
}, },
dianpu(item) { dianpu(item) {
const id = item.target.dataset.num const id = item.target.dataset.num
console.log('传递的数据:', id);
const ID = id.id const ID = id.id
const userId = id.userId const userId = id.userId
const address = id.address const address = id.address

View File

@ -5,19 +5,40 @@ Page({
}, },
onShow() { onShow() {
my.getStorage({
key: 'userInfo',
success: (res)=> {
// 成功获取到用户信息
const userInfo = res.data;
console.log('用户信息:', userInfo);
// 可以直接使用 username 和 avatarUrl
this.setData({
username: userInfo.username, // 设置用户名
avatarUrl: userInfo.avatarUrl, // 设置头像链接
});
console.log('用户名:', username);
console.log('头像链接:', avatarUrl);
},
fail: function(err) {
// 如果没有存储的 userInfo说明用户可能未登录
console.error('获取用户信息失败:', err);
}
});
// 获取缓存中的数据 // 获取缓存中的数据
const userInfo = my.getStorageSync({ key: 'user_info' }).data; // const userInfo = my.getStorageSync({ key: 'user_info' }).data;
// 判断是否存在 userInfo如果存在则更新页面数据 // 判断是否存在 userInfo如果存在则更新页面数据
if (userInfo) { // if (userInfo) {
this.setData({ // this.setData({
username: userInfo.username, // username: userInfo.username,
avatarUrl: userInfo.avatarUrl // avatarUrl: userInfo.avatarUrl
}); // });
} else { // } else {
console.log('没有找到用户信息'); // console.log('没有找到用户信息');
} // }
}, },
// 以下是一些页面跳转的示例函数 // 以下是一些页面跳转的示例函数