初始化参股
This commit is contained in:
221
前端/unpackage/dist/dev/mp-weixin/pages/booking/index.js
vendored
Normal file
221
前端/unpackage/dist/dev/mp-weixin/pages/booking/index.js
vendored
Normal file
@@ -0,0 +1,221 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const api_index = require("../../api/index.js");
|
||||
const utils_config = require("../../utils/config.js");
|
||||
class FormData extends UTS.UTSType {
|
||||
static get$UTSMetadata$() {
|
||||
return {
|
||||
kind: 2,
|
||||
get fields() {
|
||||
return {
|
||||
userName: { type: String, optional: false },
|
||||
phone: { type: String, optional: false },
|
||||
address: { type: String, optional: false },
|
||||
sofaType: { type: String, optional: false },
|
||||
problem: { type: String, optional: false }
|
||||
};
|
||||
},
|
||||
name: "FormData"
|
||||
};
|
||||
}
|
||||
constructor(options, metadata = FormData.get$UTSMetadata$(), isJSONParse = false) {
|
||||
super();
|
||||
this.__props__ = UTS.UTSType.initProps(options, metadata, isJSONParse);
|
||||
this.userName = this.__props__.userName;
|
||||
this.phone = this.__props__.phone;
|
||||
this.address = this.__props__.address;
|
||||
this.sofaType = this.__props__.sofaType;
|
||||
this.problem = this.__props__.problem;
|
||||
delete this.__props__;
|
||||
}
|
||||
}
|
||||
class SofaType extends UTS.UTSType {
|
||||
static get$UTSMetadata$() {
|
||||
return {
|
||||
kind: 2,
|
||||
get fields() {
|
||||
return {
|
||||
id: { type: String, optional: false },
|
||||
name: { type: String, optional: false }
|
||||
};
|
||||
},
|
||||
name: "SofaType"
|
||||
};
|
||||
}
|
||||
constructor(options, metadata = SofaType.get$UTSMetadata$(), isJSONParse = false) {
|
||||
super();
|
||||
this.__props__ = UTS.UTSType.initProps(options, metadata, isJSONParse);
|
||||
this.id = this.__props__.id;
|
||||
this.name = this.__props__.name;
|
||||
delete this.__props__;
|
||||
}
|
||||
}
|
||||
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
||||
__name: "index",
|
||||
setup(__props) {
|
||||
const formData = common_vendor.ref(new FormData({
|
||||
userName: "",
|
||||
phone: "",
|
||||
address: "",
|
||||
sofaType: "",
|
||||
problem: ""
|
||||
}));
|
||||
const imageList = common_vendor.ref([]);
|
||||
const sofaTypes = common_vendor.ref([]);
|
||||
const submitting = common_vendor.ref(false);
|
||||
const initSofaTypes = () => {
|
||||
sofaTypes.value = utils_config.SOFA_CATEGORIES.filter((item) => {
|
||||
return item.id != "all";
|
||||
}).map((item) => {
|
||||
return new SofaType({
|
||||
id: item.id,
|
||||
name: item.name
|
||||
});
|
||||
});
|
||||
};
|
||||
const selectSofaType = (id) => {
|
||||
formData.value.sofaType = id;
|
||||
};
|
||||
const chooseImage = () => {
|
||||
common_vendor.index.chooseImage(new UTSJSONObject({
|
||||
count: 9 - imageList.value.length,
|
||||
sizeType: ["compressed"],
|
||||
sourceType: ["album", "camera"],
|
||||
success: (res) => {
|
||||
imageList.value = [...imageList.value, ...res.tempFilePaths];
|
||||
}
|
||||
}));
|
||||
};
|
||||
const deleteImage = (index) => {
|
||||
imageList.value.splice(index, 1);
|
||||
};
|
||||
const validateForm = () => {
|
||||
if (formData.value.userName.trim() == "") {
|
||||
common_vendor.index.showToast({
|
||||
title: "请输入您的姓名",
|
||||
icon: "none"
|
||||
});
|
||||
return false;
|
||||
}
|
||||
const phone = formData.value.phone.trim();
|
||||
if (phone == "") {
|
||||
common_vendor.index.showToast({
|
||||
title: "请输入联系电话",
|
||||
icon: "none"
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if (phone.length != 11) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请输入正确的手机号",
|
||||
icon: "none"
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if (formData.value.address.trim() == "") {
|
||||
common_vendor.index.showToast({
|
||||
title: "请输入您的地址",
|
||||
icon: "none"
|
||||
});
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
const handleSubmit = () => {
|
||||
return common_vendor.__awaiter(this, void 0, void 0, function* () {
|
||||
if (!validateForm())
|
||||
return Promise.resolve(null);
|
||||
if (submitting.value)
|
||||
return Promise.resolve(null);
|
||||
submitting.value = true;
|
||||
try {
|
||||
const data = new UTSJSONObject({
|
||||
userName: formData.value.userName,
|
||||
phone: formData.value.phone,
|
||||
address: formData.value.address,
|
||||
sofaType: formData.value.sofaType,
|
||||
problem: formData.value.problem,
|
||||
images: imageList.value
|
||||
});
|
||||
const res = yield api_index.submitBooking(data);
|
||||
const result = res.data;
|
||||
common_vendor.index.showModal(new UTSJSONObject({
|
||||
title: "预约成功",
|
||||
content: result["message"],
|
||||
showCancel: false,
|
||||
success: () => {
|
||||
common_vendor.index.navigateBack(new UTSJSONObject({
|
||||
fail: () => {
|
||||
common_vendor.index.switchTab({
|
||||
url: "/pages/index/index"
|
||||
});
|
||||
}
|
||||
}));
|
||||
}
|
||||
}));
|
||||
} catch (e) {
|
||||
common_vendor.index.__f__("error", "at pages/booking/index.uvue:270", "提交预约失败", e);
|
||||
common_vendor.index.showToast({
|
||||
title: "提交失败,请重试",
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
submitting.value = false;
|
||||
});
|
||||
};
|
||||
common_vendor.onLoad(() => {
|
||||
initSofaTypes();
|
||||
});
|
||||
return (_ctx, _cache) => {
|
||||
"raw js";
|
||||
const __returned__ = common_vendor.e({
|
||||
a: common_vendor.unref(formData).userName,
|
||||
b: common_vendor.o(($event) => {
|
||||
return common_vendor.unref(formData).userName = $event.detail.value;
|
||||
}),
|
||||
c: common_vendor.unref(formData).phone,
|
||||
d: common_vendor.o(($event) => {
|
||||
return common_vendor.unref(formData).phone = $event.detail.value;
|
||||
}),
|
||||
e: common_vendor.unref(formData).address,
|
||||
f: common_vendor.o(($event) => {
|
||||
return common_vendor.unref(formData).address = $event.detail.value;
|
||||
}),
|
||||
g: common_vendor.f(common_vendor.unref(sofaTypes), (item, k0, i0) => {
|
||||
return {
|
||||
a: common_vendor.t(item.name),
|
||||
b: common_vendor.unref(formData).sofaType == item.id ? 1 : "",
|
||||
c: common_vendor.unref(formData).sofaType == item.id ? 1 : "",
|
||||
d: item.id,
|
||||
e: common_vendor.o(($event) => {
|
||||
return selectSofaType(item.id);
|
||||
}, item.id)
|
||||
};
|
||||
}),
|
||||
h: common_vendor.unref(formData).problem,
|
||||
i: common_vendor.o(($event) => {
|
||||
return common_vendor.unref(formData).problem = $event.detail.value;
|
||||
}),
|
||||
j: common_vendor.t(common_vendor.unref(formData).problem.length),
|
||||
k: common_vendor.f(common_vendor.unref(imageList), (item, index, i0) => {
|
||||
return {
|
||||
a: item,
|
||||
b: common_vendor.o(($event) => {
|
||||
return deleteImage(index);
|
||||
}, index),
|
||||
c: index
|
||||
};
|
||||
}),
|
||||
l: common_vendor.unref(imageList).length < 9
|
||||
}, common_vendor.unref(imageList).length < 9 ? {
|
||||
m: common_vendor.o(chooseImage)
|
||||
} : {}, {
|
||||
n: common_vendor.o(handleSubmit),
|
||||
o: common_vendor.sei(common_vendor.gei(_ctx, ""), "view")
|
||||
});
|
||||
return __returned__;
|
||||
};
|
||||
}
|
||||
});
|
||||
wx.createPage(_sfc_main);
|
||||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/booking/index.js.map
|
||||
4
前端/unpackage/dist/dev/mp-weixin/pages/booking/index.json
vendored
Normal file
4
前端/unpackage/dist/dev/mp-weixin/pages/booking/index.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "预约咨询",
|
||||
"usingComponents": {}
|
||||
}
|
||||
1
前端/unpackage/dist/dev/mp-weixin/pages/booking/index.wxml
vendored
Normal file
1
前端/unpackage/dist/dev/mp-weixin/pages/booking/index.wxml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<view id="{{o}}" change:eS="{{uV.sS}}" eS="{{$eS[o]}}" change:eA="{{uV.sA}}" eA="{{$eA[o]}}" class="{{['page', virtualHostClass]}}" style="{{virtualHostStyle}}" hidden="{{virtualHostHidden || false}}"><scroll-view class="page-scroll" scroll-y enable-flex="true" enhanced="true"><view class="header-section"><text class="header-title">预约翻新服务</text><text class="header-desc">填写以下信息,我们会尽快与您联系</text></view><view class="form-section"><view class="form-item"><text class="form-label"><text class="required">*</text> 您的姓名 </text><input class="form-input" type="text" placeholder="请输入您的姓名" placeholder-class="placeholder" value="{{a}}" bindinput="{{b}}"/></view><view class="form-item"><text class="form-label"><text class="required">*</text> 联系电话 </text><input class="form-input" type="number" placeholder="请输入您的手机号" placeholder-class="placeholder" maxlength="11" value="{{c}}" bindinput="{{d}}"/></view><view class="form-item"><text class="form-label"><text class="required">*</text> 您的地址 </text><input class="form-input" type="text" placeholder="请输入详细地址" placeholder-class="placeholder" value="{{e}}" bindinput="{{f}}"/></view><view class="form-item"><text class="form-label">沙发类型</text><view class="type-grid"><view wx:for="{{g}}" wx:for-item="item" wx:key="d" class="{{['type-item', item.c && 'type-active']}}" bindtap="{{item.e}}"><text class="{{['type-text', item.b && 'type-text-active']}}">{{item.a}}</text></view></view></view><view class="form-item"><text class="form-label">问题描述</text><block wx:if="{{r0}}"><textarea class="form-textarea" placeholder="请描述沙发的问题(如:皮面开裂、褪色、塌陷等)" placeholder-class="placeholder" maxlength="500" value="{{h}}" bindinput="{{i}}"></textarea></block><text class="textarea-count">{{j}}/500</text></view><view class="form-item"><text class="form-label">上传图片(可选)</text><view class="upload-grid"><view wx:for="{{k}}" wx:for-item="item" wx:key="c" class="upload-item"><image class="upload-image" src="{{item.a}}" mode="aspectFill"></image><view class="upload-delete" bindtap="{{item.b}}"><text class="delete-icon">×</text></view></view><view wx:if="{{l}}" class="upload-add" bindtap="{{m}}"><text class="add-icon">+</text><text class="add-text">添加图片</text></view></view><text class="upload-tip">最多可上传9张图片</text></view></view><view class="bottom-space"></view></scroll-view><view class="submit-bar"><view class="submit-btn" bindtap="{{n}}"><text class="submit-text">提交预约</text></view></view></view><wxs src="/common/uniView.wxs" module="uV"/>
|
||||
206
前端/unpackage/dist/dev/mp-weixin/pages/booking/index.wxss
vendored
Normal file
206
前端/unpackage/dist/dev/mp-weixin/pages/booking/index.wxss
vendored
Normal file
@@ -0,0 +1,206 @@
|
||||
@import "../../uvue.wxss";
|
||||
:host{display:flex;flex-direction:column}
|
||||
/**
|
||||
* 优艺家沙发翻新 - 全局样式变量
|
||||
*/
|
||||
/* ========== 项目主题色 ========== */
|
||||
/* 辅助色 */
|
||||
/* 文字颜色 */
|
||||
/* 背景色 */
|
||||
/* 边框颜色 */
|
||||
/* 间距 */
|
||||
/* 圆角 */
|
||||
/* 阴影 */
|
||||
/* ========== uni-app 内置变量 ========== */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
.page {
|
||||
flex: 1;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.page-scroll {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* 头部 */
|
||||
.header-section {
|
||||
background: linear-gradient(135deg, #D4A574 0%, #B8895A 100%);
|
||||
padding: 48rpx 32rpx;
|
||||
align-items: center;
|
||||
}
|
||||
.header-title {
|
||||
font-size: 40rpx;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
.header-desc {
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
/* 表单区域 */
|
||||
.form-section {
|
||||
background-color: #ffffff;
|
||||
margin: 24rpx;
|
||||
border-radius: 16rpx;
|
||||
padding: 32rpx;
|
||||
}
|
||||
.form-item {
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
.form-label {
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
color: #333333;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
.required {
|
||||
color: #F56C6C;
|
||||
margin-right: 4rpx;
|
||||
}
|
||||
.form-input {
|
||||
background-color: #f5f5f5;
|
||||
border-radius: 12rpx;
|
||||
padding: 24rpx;
|
||||
font-size: 28rpx;
|
||||
height: 40px;
|
||||
}
|
||||
.placeholder {
|
||||
color: #C0C4CC;
|
||||
}
|
||||
|
||||
/* 沙发类型选择 */
|
||||
.type-grid {
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.type-item {
|
||||
padding: 16rpx 32rpx;
|
||||
background-color: #f5f5f5;
|
||||
border-radius: 8rpx;
|
||||
margin-right: 16rpx;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
.type-active {
|
||||
background-color: #D4A574;
|
||||
}
|
||||
.type-text {
|
||||
font-size: 26rpx;
|
||||
color: #606266;
|
||||
}
|
||||
.type-text-active {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
/* 文本域 */
|
||||
.form-textarea {
|
||||
background-color: #f5f5f5;
|
||||
border-radius: 12rpx;
|
||||
padding: 24rpx;
|
||||
font-size: 28rpx;
|
||||
height: 200rpx;
|
||||
width: 100%;
|
||||
}
|
||||
.textarea-count {
|
||||
font-size: 24rpx;
|
||||
color: #909399;
|
||||
text-align: right;
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
|
||||
/* 图片上传 */
|
||||
.upload-grid {
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.upload-item {
|
||||
width: 200rpx;
|
||||
height: 200rpx;
|
||||
margin-right: 16rpx;
|
||||
margin-bottom: 16rpx;
|
||||
position: relative;
|
||||
}
|
||||
.upload-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
.upload-delete {
|
||||
position: absolute;
|
||||
top: -16rpx;
|
||||
right: -16rpx;
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
background-color: #F56C6C;
|
||||
border-radius: 50%;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.delete-icon {
|
||||
font-size: 28rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
.upload-add {
|
||||
width: 200rpx;
|
||||
height: 200rpx;
|
||||
background-color: #f5f5f5;
|
||||
border-radius: 12rpx;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-width: 2rpx;
|
||||
border-style: dashed;
|
||||
border-color: #DCDFE6;
|
||||
}
|
||||
.add-icon {
|
||||
font-size: 48rpx;
|
||||
color: #909399;
|
||||
}
|
||||
.add-text {
|
||||
font-size: 24rpx;
|
||||
color: #909399;
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
.upload-tip {
|
||||
font-size: 24rpx;
|
||||
color: #909399;
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
/* 底部间距 */
|
||||
.bottom-space {
|
||||
height: 160rpx;
|
||||
}
|
||||
|
||||
/* 提交按钮 */
|
||||
.submit-bar {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background-color: #ffffff;
|
||||
padding: 24rpx 32rpx;
|
||||
padding-bottom: 48rpx;
|
||||
box-shadow: 0 -4rpx 16rpx rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
.submit-btn {
|
||||
background-color: #D4A574;
|
||||
border-radius: 999rpx;
|
||||
padding: 28rpx 0;
|
||||
align-items: center;
|
||||
}
|
||||
.submit-text {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #ffffff;
|
||||
}
|
||||
Reference in New Issue
Block a user