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 @@
eea885d6-b43c-4c7a-93f7-e94324b0d82a

View File

@@ -0,0 +1,198 @@
const {
index,
util
} = getApp().globalData
Page({
/**
* 页面的初始数据
*/
data: {
ossUrl: 'https://losta.oss-cn-shanghai.aliyuncs.com',
showTips: true,
fileList: [],
thingTypeIndex: 0,
thingTypeArr: [
{ title: '失物招领', type: 1 },
{ title: '寻物启事', type: 2 },
],
thingCategoryIndex: 0,
thingCategoryArr: [
{ title: '证件', type: 1 },
{ title: '服装', type: 2 },
{ title: '数码', type: 3 },
{ title: '日用品', type: 4 },
{ title: '其他', type: 5 },
],
pushParams: {
user_id: 0,
thing_title: '',
thing_introduce: '',
thing_img: '',
thing_type: 1,
thing_category: 1
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if (util.checkIsLogin()) {
this.setData({ thingTypeIndex: options.id - 1 })
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
onShow: function () {
setTimeout(()=> {
this.setData({ showTips: false })
},4000)
},
thingTitleInput(e) {
this.setData({
['pushParams.thing_title']: e.detail.value
});
},
thingIntrInput(e) {
this.setData({
['pushParams.thing_introduce']: e.detail.value
})
},
changeThingTypeIndex(e) {
this.setData({ thingTypeIndex: e.target.dataset.id })
},
changeThingCategoryIndex(e) {
this.setData({ thingCategoryIndex: e.target.dataset.id })
},
async PushThing() {
let userInfo = wx.getStorageSync('user');
let {
fileList, pushParams,
thingTypeIndex, thingTypeArr,
thingCategoryIndex, thingCategoryArr
} = this.data;
if (pushParams.thing_title.length == 0) {
wx.showToast({
title: '标题必填',
icon: 'none',
duration: 2000
});
return false;
}
if (pushParams.thing_introduce.length == 0 || pushParams.thing_introduce.length > 500) {
wx.showToast({
title: '介绍必填,且字数不能大于500',
icon: 'none',
duration: 2000
});
return false;
}
if (pushParams.thing_img.length == 0) {
wx.showToast({
title: '图片必须上传',
icon: 'none',
duration: 2000
});
return false;
}
pushParams.user_id = userInfo.user_id;
pushParams.thing_type = thingTypeArr[thingTypeIndex].type;
pushParams.thing_category = thingCategoryArr[thingCategoryIndex].type;
console.log("请求参数:", pushParams)
let res = await index.push(pushParams);
console.log(res);
util.showToast({
title: '发布成功',
icon: 'success',
duration: 2000,
close: () => {
wx.navigateBack()
}
})
},
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({
['pushParams.thing_img']: `${this.data.ossUrl}/${fileName}`
});
} else {
wx.showToast({
title: "图片上传错误,稍后再试",
icon: 'none',
duration: 3000
});
}
}
});
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

View File

@@ -0,0 +1,8 @@
{
"usingComponents": {
"van-uploader": "@vant/weapp/uploader/index",
"van-divider": "@vant/weapp/divider/index",
"van-icon": "@vant/weapp/icon/index"
},
"navigationBarTitleText": "发布信息"
}

View File

@@ -0,0 +1,42 @@
<div class="push content">
<input bindinput="thingTitleInput" class="thing_title" type="text" placeholder="物品的标题"></input>
<textarea bindinput="thingIntrInput"
maxlength="500" class="thing_introduce"
auto-height
placeholder="请描述清楚时间,地点,物品特征等基本信息(限500字)"/>
<van-uploader
file-list="{{ fileList }}"
max-count="1"
bind:after-read="afterRead" />
<view class="action_title">物品类型</view>
<view class="type">
<view class="type_item {{ thingTypeIndex == index ? 'active' : '' }}"
wx:for="{{thingTypeArr}}"
data-id="{{ index }}"
bind:tap="changeThingTypeIndex"
wx:key="type">
{{ item.title }}
</view>
</view>
<view class="action_title">物品类别</view>
<view class="category">
<view class="category_item {{ thingCategoryIndex == index ? 'active' : '' }}"
wx:key="type"
data-id="{{ index }}"
bind:tap="changeThingCategoryIndex"
wx:for="{{thingCategoryArr}}">
{{ item.title }}
</view>
</view>
<movable-area class="push_wrap">
<movable-view bind:tap="PushThing" class="push_action" x="{{46}}" y="{{13}}" direction="all">
<van-icon color="#c19503" name="guide-o" size="60rpx"/>
<view class="tips" wx:if="{{showTips}}">按住,可以拖动哦</view>
</movable-view>
</movable-area>
</div>

View File

@@ -0,0 +1,92 @@
page {
background: #fff;
}
.push {
}
.thing_title {
height: 120rpx;
font-size: 30rpx;
}
.thing_introduce {
width: 100%;
height: 250rpx !important;
font-size: 30rpx;
}
.action_title {
margin: 30rpx 0px 19rpx 20rpx;
color: rgba(69,90,100,.6);
font-size: 27rpx;
}
.type {
margin-bottom: 67rpx;
}
.type,
.category {
display: flex;
}
.type .type_item,
.category .category_item {
margin-right: 15rpx;
color: #151515;
text-align: center;
width: 160rpx;
height: 65rpx;
font-size: 28rpx;
line-height: 65rpx;
border-radius: 20px;
background: #e8e8e8;
}
.category {}
.category .category_item{}
.active {
background: #ffd23c !important;
}
.push_wrap {
position: fixed;
width: 100%;
left: 0;
bottom: 0;
height: 200rpx;
}
.push_action {
width: 120rpx;
height: 120rpx;
border-radius: 100%;
background: #ffd23c;
display: flex;
align-items: center;
justify-content: center;
position: relative;
border: 1px solid #fbcb2d;
box-shadow: 3px 3px 21px #ffd23c;
}
.push_wrap .tips {
position: absolute;
right: -150rpx;
top: -63rpx;
width: 225rpx;
background: #ffd23c;
padding: 10rpx 19rpx;
border-radius: 8px;
transform: rotate(14deg) scale(1,1);
font-size: 26rpx;
animation: shak 2s ease-in-out infinite reverse;
}
@keyframes shak {
0% {
transform: rotate(14deg) scale(1,1);
}
50% {
transform: rotate(30deg) scale(1.2,1.2);
}
100% {
transform: rotate(14deg) scale(1,1);
}
}