first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1 @@
b42fbb72-51bd-448c-9c26-95c4610bf308

View File

@@ -0,0 +1,168 @@
const {
user,
index,
util
} = getApp().globalData
Page({
data: {
ossUrl: 'https://losta.oss-cn-shanghai.aliyuncs.com',
userInfo: {},
fileList: [],
customItem: '全部',
showSchool: false,
showUserName: false
},
onLoad: function (options) {
if (util.checkIsLogin()) {
let info = wx.getStorageSync('user')
if (info.user_city.length != 0) {
info.user_city = info.user_city.split(",")
}
this.setData({ userInfo: info });
this.setData({
fileList: [
{
url: this.data.userInfo.user_portrait,
name: '图片1',
}
]
})
}
},
async edit() {
let { userInfo } = this.data;
userInfo.user_city = userInfo.user_city.toString();
console.log("userInfo : ", userInfo)
let res = await user.edit(userInfo)
console.log(res)
wx.setStorageSync('user', userInfo);
util.showToast({
title: '修改成功',
icon: 'success',
duration: 2000,
// close: () => wx.switchTab({ url: '/pages/index/index' })
})
},
async afterRead(event) {
const { file } = event.detail;
this.setData({ fileList: [ file ] })
console.log("file === ", file)
let arr = file.url.split(".")
let fileType = arr[arr.length - 1]; // 文件后缀
let ossConfig = await index.token();
let fileName = `${util.random()}.${fileType}`;
console.log("fileName === ", fileName)
wx.uploadFile({
url: this.data.ossUrl,
filePath: file.url,
name: 'file',
formData: { key: fileName, ...ossConfig },
success: (res) => {
console.log("uploadFile success : ", res)
if (res.statusCode == 204) {
this.setData({
['userInfo.user_portrait']: `${this.data.ossUrl}/${fileName}`
});
} else {
wx.showToast({
title: "图片上传错误,稍后再试",
icon: 'none',
duration: 3000
});
}
}
});
},
bindRegionChange: function (e) {
this.setData({
'userInfo.user_city': e.detail.value
})
},
onSchoolChange(e) {
this.setData({
'userInfo.user_school': e.detail
})
},
onUserNameChange(e) {
this.setData({
'userInfo.user_name': e.detail
})
},
showSheet() {
this.setData({showSchool: true})
},
showNameSheet() {
this.setData({showUserName: true})
},
onUserClose() {
this.setData({showUserName: false})
},
onClose() {
this.setData({showSchool: false})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

View File

@@ -0,0 +1,12 @@
{
"usingComponents": {
"van-cell": "@vant/weapp/cell/index",
"van-cell-group": "@vant/weapp/cell-group/index",
"van-image": "@vant/weapp/image/index",
"van-uploader": "@vant/weapp/uploader/index",
"van-action-sheet": "@vant/weapp/action-sheet/index",
"van-field": "@vant/weapp/field/index",
"van-button": "@vant/weapp/button/index"
},
"navigationBarTitleText": "个人信息"
}

View File

@@ -0,0 +1,66 @@
<view class="edit">
<van-cell-group>
<van-cell title="头像" is-link center border="{{ false }}">
<van-uploader
deletable="{{ false }}"
preview-size="40px"
file-list="{{ fileList }}"
bind:after-read="afterRead" />
</van-cell>
<van-cell title="昵称" bind:tap="showNameSheet" value="{{ userInfo.user_name }}" is-link center border="{{ false }}"/>
<van-cell title="手机" value="{{ userInfo.user_phone }}" center border="{{ false }}"/>
<van-cell title="城市" is-link center border="{{ false }}">
<picker mode="region" bindchange="bindRegionChange" value="{{ userInfo.user_city }}" custom-item="请选择">
<view wx:if="{{ userInfo.user_city.length != 0 }}" class="picker">{{userInfo.user_city[0]}}, {{userInfo.user_city[1]}}, {{userInfo.user_city[2]}}</view>
<view wx:else>请选择城市</view>
</picker>
</van-cell>
<van-cell bind:tap="showSheet" title="学校" value="" is-link center border="{{ false }}">
<view wx:if="{{ userInfo.user_school.length != 0 }}">{{ userInfo.user_school }}</view>
<view wx:else>请填写</view>
</van-cell>
</van-cell-group>
<van-action-sheet
title="学校"
show="{{ showSchool }}"
bind:close="onClose"
bind:cancel="onClose"
cancel-text="完成">
<van-field
type="text"
confirm-type="确定"
value="{{ userInfo.user_school }}"
clearable="{{ true }}"
placeholder="请输入学校名称"
border="{{ false }}"
bind:change="onSchoolChange"
/>
</van-action-sheet>
<van-action-sheet
title="昵称"
show="{{ showUserName }}"
bind:close="onUserClose"
bind:cancel="onUserClose"
cancel-text="完成">
<van-field
type="text"
confirm-type="确定"
value="{{ userInfo.user_name }}"
clearable="{{ true }}"
placeholder="请输入用户昵称"
border="{{ false }}"
bind:change="onUserNameChange"
/>
</van-action-sheet>
<view class="submit">
<van-button bind:tap="edit" class="submit" type="primary" round color="#ffd23c" size="large">提 交</van-button>
</view>
</view>

View File

@@ -0,0 +1,18 @@
.edit {
}
.van-uploader__upload {
position: absolute !important;
opacity: 0;
z-index: 999;
}
.van-uploader__preview-image {
border-radius: 60rpx;
}
.submit {
width: 80%;
margin: 60rpx auto;
}