修复了已知问题
This commit is contained in:
parent
7dfe547728
commit
223147de98
|
@ -1,11 +1,36 @@
|
|||
App({
|
||||
onLaunch(options) {
|
||||
// 第一次打开
|
||||
// options.query == {number:1}
|
||||
console.info('App onLaunch');
|
||||
globalData: {
|
||||
isLoggedIn: false, // 用户登录状态
|
||||
userInfo: null, // 用户信息
|
||||
},
|
||||
onShow(options) {
|
||||
// 从后台被 scheme 重新打开
|
||||
// options.query == {number:1}
|
||||
|
||||
onLaunch() {
|
||||
// 从本地存储读取登录信息
|
||||
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' });
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1,48 +1,60 @@
|
|||
import {url} from '../request'
|
||||
|
||||
Page({
|
||||
data:{
|
||||
authCode:'',
|
||||
data: {
|
||||
authCode: '',
|
||||
},
|
||||
Login(){
|
||||
|
||||
Login() {
|
||||
my.getAuthCode({
|
||||
|
||||
scopes: 'auth_user',
|
||||
success: res => {
|
||||
const authCode = res.authCode;
|
||||
|
||||
console.log(typeof authCode);
|
||||
console.log(authCode)
|
||||
console.log(authCode);
|
||||
|
||||
// 请求后端接口进行用户登录
|
||||
my.request({
|
||||
url: url+'/api/Alipay/parseCode',
|
||||
data: {
|
||||
url: url + '/api/Alipay/parseCode',
|
||||
data: {
|
||||
authCode,
|
||||
},
|
||||
success(res){
|
||||
const { username, avatarUrl } = res.data.data;
|
||||
my.setStorageSync({
|
||||
key: 'user_info',
|
||||
success: (res) => {
|
||||
const { username, avatarUrl,} = res.data.data;
|
||||
const setCookie = res.header['Set-Cookie'];
|
||||
// 存储用户信息到本地存储
|
||||
my.setStorage({
|
||||
key: 'userInfo',
|
||||
data: {
|
||||
username:username,
|
||||
avatarUrl:avatarUrl,
|
||||
username: username,
|
||||
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({
|
||||
title: '登录成功',
|
||||
});
|
||||
my.switchTab({
|
||||
url:'/pages/wode/wode'
|
||||
})
|
||||
|
||||
},
|
||||
fail(res){
|
||||
console.log("失败");
|
||||
my.navigateBack();
|
||||
},
|
||||
fail: (res) => {
|
||||
console.log("登录失败:", res);
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
|
@ -49,7 +49,7 @@ Page({
|
|||
id:id,
|
||||
});
|
||||
my.request({
|
||||
url: url + '/api/commodities/list/page/commoditiesVO',
|
||||
url: url + '/api/commodities/list/page/commodities',
|
||||
method: 'POST',
|
||||
data: {
|
||||
businessId: id,
|
||||
|
@ -84,7 +84,7 @@ Page({
|
|||
meijiahsi(){
|
||||
my.request({
|
||||
url: url + '/api/manicurist/userQueryAll',
|
||||
method: 'POST',
|
||||
method: 'GET',
|
||||
data: {
|
||||
businessId: this.data.id
|
||||
},
|
||||
|
@ -119,14 +119,16 @@ Page({
|
|||
},
|
||||
shangpinjiemian(item){
|
||||
const id = item.target.dataset.num
|
||||
const ID = id.id
|
||||
console.log('传递的数据:', id);
|
||||
const ids = id.id
|
||||
const commoditiesPrice = id.commoditiesPrice
|
||||
const commoditiesName = id.commoditiesName
|
||||
const commoditiesImage = id.commoditiesImage
|
||||
const businessId = id.businessId
|
||||
console.log('Address being passed: ',id,commoditiesPrice,commoditiesName,commoditiesImage,businessId);
|
||||
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+'这是商品的')
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,100 +1,82 @@
|
|||
/* 顶部信息 */
|
||||
.box1{
|
||||
width: 390px;
|
||||
.container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
|
||||
.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;
|
||||
background-color: #eec2c7;
|
||||
border-radius: 50%;
|
||||
}
|
||||
.text1{
|
||||
font-size: 22px;
|
||||
top:10px;
|
||||
left:140px;
|
||||
position: absolute;
|
||||
font-weight: bolder;
|
||||
|
||||
.icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
color: #ccc;
|
||||
}
|
||||
.text2{
|
||||
font-size: 25px;
|
||||
top:80px;
|
||||
left:40px;
|
||||
position: absolute;
|
||||
|
||||
.picker-placeholder {
|
||||
color: #999;
|
||||
display: flex;
|
||||
}
|
||||
/* 账号 */
|
||||
.box2{
|
||||
width: 310px;
|
||||
height: 60px;
|
||||
top:89px;
|
||||
left:39px;
|
||||
position: relative;
|
||||
background-color:darkgrey;
|
||||
|
||||
.upload-button {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 10px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.box3{
|
||||
width: 308px;
|
||||
height: 58px;
|
||||
top:1px;
|
||||
left:1px;
|
||||
position: relative;
|
||||
background-color: #ffffff;
|
||||
border-radius: 10px;
|
||||
|
||||
.submit-button {
|
||||
width: 100%;
|
||||
background-color: #007aff;
|
||||
color: white;
|
||||
text-align: center;
|
||||
padding: 15px;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
font-size: 16px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.z1{
|
||||
color: darkgrey;
|
||||
left:50px;
|
||||
top:20px;
|
||||
position: absolute;
|
||||
}
|
||||
.box3 image{
|
||||
width: 40px;
|
||||
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;
|
||||
.button {
|
||||
background-color: #f3bfc1; /* Light pink background color */
|
||||
color: #000000; /* Text color */
|
||||
border-radius: 20px; /* Rounded edges */
|
||||
padding: 10px 20px;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
width: 320px;
|
||||
}
|
|
@ -1,24 +1,51 @@
|
|||
<view>
|
||||
<view class="box1">
|
||||
<text class="text1">商家登录</text>
|
||||
</view>
|
||||
<text class="text2">商家登录</text>
|
||||
<!-- 账号 -->
|
||||
<view class="box2">
|
||||
<view class="box3">
|
||||
<text class="z1">请输入账号</text>
|
||||
<image mode="scaleToFill" src="../image/账号.png" />
|
||||
<view class="container">
|
||||
<view class="section">
|
||||
<view class="section-title">商家注册</view>
|
||||
<view class="input-row">
|
||||
<text class="label">店铺名称</text>
|
||||
<input class="input" placeholder="请输入店铺名称" onInput="businessName" />
|
||||
</view>
|
||||
<view class="input-row">
|
||||
<text class="label">联系人</text>
|
||||
<input class="input" placeholder="请输入联系人姓名" onInput="person" />
|
||||
<icon type="eye" />
|
||||
</view>
|
||||
</view>
|
||||
<!-- 密码 -->
|
||||
<view class="box4">
|
||||
<view class="box5">
|
||||
<text class="z2">请输入密码</text>
|
||||
<image mode="scaleToFill" src="../image/密码.png" />
|
||||
|
||||
<view class="section">
|
||||
|
||||
|
||||
<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 class="box6">
|
||||
<text class="z3">登录</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="button" onTap="ruzhu">提交申请</view>
|
||||
</view>
|
||||
|
|
|
@ -1,4 +1,55 @@
|
|||
Page({
|
||||
data: {},
|
||||
data: {
|
||||
|
||||
},
|
||||
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);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
{
|
||||
"usingComponents": {},
|
||||
"defaultTitle": "商家入驻",
|
||||
"usingComponents": {
|
||||
"ant-uploader": "antd-mini/es/ImageUpload/index",
|
||||
"ant-container": "antd-mini/es/Container/index"
|
||||
},
|
||||
"styleIsolation": "apply-shared"
|
||||
}
|
||||
|
|
|
@ -1,69 +1,116 @@
|
|||
import {url} from '../request'
|
||||
|
||||
Page({
|
||||
data: {
|
||||
commoditiesImage:'',
|
||||
commoditiesPrice:'',
|
||||
commoditiesName:'',
|
||||
businessId:'',
|
||||
commoditiesImage: '',
|
||||
commoditiesPrice: '',
|
||||
commoditiesName: '',
|
||||
businessId: '',
|
||||
ids: '',
|
||||
items: [
|
||||
{
|
||||
title: '项目详情',
|
||||
},
|
||||
{
|
||||
title: '购买须知',
|
||||
},
|
||||
{
|
||||
title: '评价',
|
||||
},
|
||||
],
|
||||
{ title: '项目详情' },
|
||||
{ title: '购买须知' },
|
||||
{ title: '评价' },
|
||||
],
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
const commoditiesImage = options.commoditiesImage;
|
||||
const commoditiesName = options.commoditiesName;
|
||||
const commoditiesPrice = options.commoditiesPrice;
|
||||
const id = options.id;
|
||||
const businessId = options.businessId
|
||||
// Set them in data for use in the page
|
||||
this.setData({
|
||||
commoditiesImage: commoditiesImage,
|
||||
commoditiesName: commoditiesName,
|
||||
commoditiesPrice:commoditiesPrice,
|
||||
id:id,
|
||||
businessId:businessId
|
||||
});
|
||||
onLoad(options) {
|
||||
const commoditiesImage = options.commoditiesImage;
|
||||
const commoditiesName = options.commoditiesName;
|
||||
const commoditiesPrice = options.commoditiesPrice;
|
||||
const ids = options.ids;
|
||||
const businessId = options.businessId;
|
||||
|
||||
this.setData({
|
||||
commoditiesImage: commoditiesImage,
|
||||
commoditiesName: commoditiesName,
|
||||
commoditiesPrice: commoditiesPrice,
|
||||
ids: ids,
|
||||
businessId: businessId,
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
// 切换标签
|
||||
onChange(current) {
|
||||
this.setData({
|
||||
current,
|
||||
current,
|
||||
});
|
||||
},
|
||||
jiaru(){
|
||||
my.request({
|
||||
url: url+'/api/cart/add',
|
||||
method: 'POST',
|
||||
data: {
|
||||
businessId: 1,
|
||||
commoditiesId: 1,
|
||||
quantity: 1,
|
||||
selectedOptions: ""
|
||||
},
|
||||
headers: {
|
||||
'content-type': 'application/json', //默认值
|
||||
},
|
||||
dataType: 'json',
|
||||
success:(res)=>{
|
||||
console.log(res);
|
||||
my.alert({ content: 'success' });
|
||||
},
|
||||
fail: function (error) {
|
||||
console.error('fail: ', JSON.stringify(error));
|
||||
},
|
||||
complete: function (res) {
|
||||
my.hideLoading();
|
||||
my.alert({ content: 'complete' });
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
onShow(){
|
||||
this.checkUserLogin
|
||||
},
|
||||
// 检查登录状态
|
||||
checkUserLogin() {
|
||||
my.getStorages({
|
||||
key: 'userInfo',
|
||||
success: (res) => {
|
||||
if (res.data && res.data.openId) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('获取用户信息失败:', err);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
jiaru() {
|
||||
// 获取本地存储的用户信息
|
||||
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: '获取用户信息失败,请重试。',
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
@ -57,6 +57,7 @@ Page({
|
|||
},
|
||||
dianpu(item) {
|
||||
const id = item.target.dataset.num
|
||||
console.log('传递的数据:', id);
|
||||
const ID = id.id
|
||||
const userId = id.userId
|
||||
const address = id.address
|
||||
|
|
|
@ -5,19 +5,40 @@ Page({
|
|||
},
|
||||
|
||||
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,如果存在则更新页面数据
|
||||
if (userInfo) {
|
||||
this.setData({
|
||||
username: userInfo.username,
|
||||
avatarUrl: userInfo.avatarUrl
|
||||
});
|
||||
// if (userInfo) {
|
||||
// this.setData({
|
||||
// username: userInfo.username,
|
||||
// avatarUrl: userInfo.avatarUrl
|
||||
// });
|
||||
|
||||
} else {
|
||||
console.log('没有找到用户信息');
|
||||
}
|
||||
// } else {
|
||||
// console.log('没有找到用户信息');
|
||||
// }
|
||||
},
|
||||
|
||||
// 以下是一些页面跳转的示例函数
|
||||
|
|
Loading…
Reference in New Issue
Block a user