上传代码
This commit is contained in:
86
distribution/unpackage/dist/dev/mp-alipay/pages/changeUserMessage/changeUserMessage.acss
vendored
Normal file
86
distribution/unpackage/dist/dev/mp-alipay/pages/changeUserMessage/changeUserMessage.acss
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
|
||||
.user-profile.data-v-983df345 {
|
||||
background: linear-gradient(to bottom, #5e7dec,white);
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
}
|
||||
.avatar-container.data-v-983df345 {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.avatar-container .avatar.data-v-983df345 {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
border-radius: 50%;
|
||||
object-fit: cover;
|
||||
}
|
||||
.edit-text.data-v-983df345 {
|
||||
color: white;
|
||||
margin-top: 10px;
|
||||
}
|
||||
.form-container.data-v-983df345 {
|
||||
background-color: white;
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
width: 90%;
|
||||
max-width: 600px;
|
||||
}
|
||||
.form-item.data-v-983df345 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.label.data-v-983df345 {
|
||||
width: 35px;
|
||||
text-align: right;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.gender-item.data-v-983df345 {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
/* 确保性别选项水平显示 */
|
||||
.gender-container.data-v-983df345 {
|
||||
display: flex;
|
||||
flex-direction: row; /* 默认值为row,这里明确指定是为了清晰 */
|
||||
}
|
||||
.gender-container label.data-v-983df345 {
|
||||
margin-right: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.input-field.data-v-983df345 {
|
||||
flex: 1;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
height: 45px;
|
||||
border-radius: 15px;
|
||||
}
|
||||
.save-button.data-v-983df345 {
|
||||
background-color: transparent; /* 设置背景为透明 */
|
||||
color: white;
|
||||
padding: 0px 20px; /* 增加内边距以便按钮看起来更舒适 */
|
||||
border: 2px solid #5e7dec; /* 添加边框以增强立体感 */
|
||||
border-radius: 20px;
|
||||
margin-top: 20px;
|
||||
width: 100%;
|
||||
max-width: 300px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease; /* 应用到所有属性的过渡效果 */
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* 添加阴影以增加立体感 */
|
||||
}
|
||||
.save-button.data-v-983df345:hover {
|
||||
background-color: rgba(94, 125, 236, 0.1); /* 鼠标悬停时轻微改变背景颜色 */
|
||||
box-shadow: 0 6px 8px rgba(0, 0, 0, 0.2); /* 增强阴影效果 */
|
||||
}
|
||||
.save-button.data-v-983df345:active {
|
||||
transform: translateY(2px); /* 点击时向下移动,模拟按下的效果 */
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* 减弱阴影效果 */
|
||||
}
|
1
distribution/unpackage/dist/dev/mp-alipay/pages/changeUserMessage/changeUserMessage.axml
vendored
Normal file
1
distribution/unpackage/dist/dev/mp-alipay/pages/changeUserMessage/changeUserMessage.axml
vendored
Normal file
@ -0,0 +1 @@
|
||||
<view class="user-profile data-v-983df345"><view class="avatar-container data-v-983df345"><image src="{{a}}" mode="aspectFill" class="avatar data-v-983df345" onTap="{{b}}"></image><text class="edit-text data-v-983df345">点击修改头像</text></view><view class="form-container data-v-983df345"><view class="form-item data-v-983df345"><text class="label data-v-983df345">昵称</text><input type="text" class="input-field data-v-983df345" value="{{c}}" onInput="{{d}}"/></view><view class="form-item gender-item data-v-983df345"><text class="label data-v-983df345">性别</text><radio-group class="gender-container data-v-983df345"><label class="data-v-983df345"><radio class="data-v-983df345" checked="{{e}}" value="male" onTap="{{f}}"></radio><text class="data-v-983df345">男</text></label><label class="data-v-983df345"><radio class="data-v-983df345" checked="{{g}}" value="female" onTap="{{h}}"></radio><text class="data-v-983df345">女</text></label></radio-group></view><view class="form-item data-v-983df345"><text class="label data-v-983df345">手机</text><input type="text" class="input-field data-v-983df345" value="{{i}}" onInput="{{j}}"/></view><view class="form-item data-v-983df345"><text class="label data-v-983df345">范围</text><input type="text" class="input-field data-v-983df345" value="{{k}}" onInput="{{l}}"/></view></view><button class="save-button data-v-983df345" onTap="{{m}}">保 存</button></view>
|
121
distribution/unpackage/dist/dev/mp-alipay/pages/changeUserMessage/changeUserMessage.js
vendored
Normal file
121
distribution/unpackage/dist/dev/mp-alipay/pages/changeUserMessage/changeUserMessage.js
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const API_api = require("../../API/api.js");
|
||||
const _sfc_main = {
|
||||
__name: "changeUserMessage",
|
||||
setup(__props) {
|
||||
const user = common_vendor.ref({ errandName: "未登录", errandAvatarUrl: "", gender: "", errandPhone: "", distributionScope: "" });
|
||||
const tempAvatarUrl = common_vendor.ref("");
|
||||
const getCurrentUser = () => {
|
||||
common_vendor.index.request({
|
||||
url: API_api.apiImageUrl + "/api/errand/get/current",
|
||||
method: "POST",
|
||||
header: {
|
||||
"cookie": common_vendor.index.getStorageSync("cookie")
|
||||
},
|
||||
success(res) {
|
||||
console.log(res);
|
||||
if (res.data.code === 0 && res.data.data) {
|
||||
Object.assign(user.value, res.data.data);
|
||||
}
|
||||
},
|
||||
fail(err) {
|
||||
console.error("请求失败:", err);
|
||||
}
|
||||
});
|
||||
};
|
||||
common_vendor.onShow(() => {
|
||||
getCurrentUser();
|
||||
});
|
||||
common_vendor.onMounted(() => {
|
||||
getCurrentUser();
|
||||
});
|
||||
const chooseImage = () => {
|
||||
common_vendor.index.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ["original", "compressed"],
|
||||
sourceType: ["album", "camera"],
|
||||
success: (res) => {
|
||||
const tempFilePaths = res.tempFilePaths;
|
||||
tempAvatarUrl.value = tempFilePaths[0];
|
||||
uploadImage(tempFilePaths[0]);
|
||||
}
|
||||
});
|
||||
};
|
||||
const uploadImage = (filePath) => {
|
||||
common_vendor.index.uploadFile({
|
||||
url: API_api.apiImageUrl + "/api/file/upload/server",
|
||||
filePath,
|
||||
name: "file",
|
||||
formData: {
|
||||
biz: "user_avatar"
|
||||
},
|
||||
success: (res) => {
|
||||
const data = JSON.parse(res.data);
|
||||
if (data.code === 0) {
|
||||
user.value.errandAvatarUrl = data.data.url;
|
||||
tempAvatarUrl.value = "";
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error("上传失败:", err);
|
||||
}
|
||||
});
|
||||
};
|
||||
const saveUser = () => {
|
||||
const updatedUser = {
|
||||
distributionScope: user.value.distributionScope,
|
||||
errandName: user.value.errandName,
|
||||
errandPhone: user.value.errandPhone,
|
||||
gender: user.value.gender,
|
||||
id: user.value.id,
|
||||
state: 0
|
||||
};
|
||||
common_vendor.index.request({
|
||||
url: API_api.apiImageUrl + "/api/errand/update/my",
|
||||
method: "POST",
|
||||
data: updatedUser,
|
||||
header: {
|
||||
"Content-Type": "application/json",
|
||||
"cookie": common_vendor.index.getStorageSync("cookie")
|
||||
},
|
||||
success(res) {
|
||||
if (res.data.code === 0) {
|
||||
common_vendor.index.showToast({
|
||||
title: "更新成功",
|
||||
icon: "success"
|
||||
});
|
||||
getCurrentUser();
|
||||
} else {
|
||||
common_vendor.index.showToast({
|
||||
title: "更新失败",
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
},
|
||||
fail(err) {
|
||||
console.error("请求失败:", err);
|
||||
}
|
||||
});
|
||||
};
|
||||
return (_ctx, _cache) => {
|
||||
return {
|
||||
a: tempAvatarUrl.value || user.value.errandAvatarUrl || "../../static/logo.png",
|
||||
b: common_vendor.o(chooseImage),
|
||||
c: user.value.errandName,
|
||||
d: common_vendor.o(($event) => user.value.errandName = $event.detail.value),
|
||||
e: user.value.gender === 0,
|
||||
f: common_vendor.o(($event) => user.value.gender = 0),
|
||||
g: user.value.gender === 1,
|
||||
h: common_vendor.o(($event) => user.value.gender = 1),
|
||||
i: user.value.errandPhone,
|
||||
j: common_vendor.o(($event) => user.value.errandPhone = $event.detail.value),
|
||||
k: user.value.distributionScope,
|
||||
l: common_vendor.o(($event) => user.value.distributionScope = $event.detail.value),
|
||||
m: common_vendor.o(saveUser)
|
||||
};
|
||||
};
|
||||
}
|
||||
};
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-983df345"]]);
|
||||
my.createPage(MiniProgramPage);
|
5
distribution/unpackage/dist/dev/mp-alipay/pages/changeUserMessage/changeUserMessage.json
vendored
Normal file
5
distribution/unpackage/dist/dev/mp-alipay/pages/changeUserMessage/changeUserMessage.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"defaultTitle": "修改用户信息",
|
||||
"titleBarColor": "#5e7dec",
|
||||
"usingComponents": {}
|
||||
}
|
Reference in New Issue
Block a user