| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307 |
- <template>
- <Theme>
- <view class="wrap">
- <Navbar title="意向表单" fixed border>
- <template #right>
- <view class="nav_right" @click.stop="toRecord">
- <trans _t="意向记录" />
- </view>
- </template>
- </Navbar>
- <view class="form">
- <view class="form_item">
- <view class="item_label _required">
- <trans _t="商品名称" />
- </view>
- <view class="item_value">
- <Input
- :placeholder="t('请输入商品名称')"
- border="surround"
- v-model="form.goods_name"
- :maxlength="50"
- />
- </view>
- </view>
- <view class="form_item">
- <view class="item_label _required">
- <trans _t="商品图片" />
- </view>
- <view class="item_value">
- <imageUpload v-model="imageList" :maxCount="6" multiple />
- </view>
- </view>
- <view class="form_item">
- <view class="item_label">
- <trans _t="商品详细描述" />
- </view>
- <view class="item_value">
- <up-textarea
- v-model="form.goods_desc"
- :placeholder="t('请输入商品详细描述')"
- count
- autoHeight
- border="surround"
- maxlength="500"
- ></up-textarea>
- </view>
- </view>
- <view class="form_item">
- <view class="item_label">
- <trans _t="价格区间" />
- </view>
- <view class="item_value">
- <view class="value_box">
- <trans _t="最低价" class="title" />
- <Input border="surround" type="Number" v-model="form.min_price">
- <template #suffix>
- <trans _t="元" class="unit" />
- </template>
- </Input>
- </view>
- <view class="price_separator"></view>
- <view class="value_box">
- <trans _t="最高价" class="title" />
- <Input border="surround" type="Number" v-model="form.max_price">
- <template #suffix>
- <trans _t="元" class="unit" />
- </template>
- </Input>
- </view>
- </view>
- </view>
- <view class="form_item">
- <view class="item_label">
- <trans _t="购买数量" />
- </view>
- <view class="item_value">
- <up-number-box v-model="form.goods_num" :min="1"></up-number-box>
- </view>
- </view>
- <view class="form_item">
- <view class="item_label _required">
- <trans _t="联系人姓名" />
- </view>
- <view class="item_value">
- <Input
- :placeholder="t('请输入联系人姓名')"
- border="surround"
- v-model="form.name"
- />
- </view>
- </view>
- <view class="form_item">
- <view class="item_label _required">
- <trans _t="联系人电话" />
- </view>
- <view class="item_value">
- <Input
- :placeholder="t('请输入联系人电话')"
- border="surround"
- type="Number"
- v-model="form.mobile"
- />
- </view>
- </view>
- </view>
- <view class="footer">
- <view class="submit_btn" @click="submit">
- <trans _t="提交" />
- </view>
- </view>
- </view>
- </Theme>
- </template>
- <script setup>
- import Navbar from "@/components/navbar";
- import { reactive, ref, watch, nextTick } from "vue";
- import { t } from "@/locale";
- import Input from "@/components/input";
- import imageUpload from "@/components/imageUpload.vue";
- import { RONGIMCALL_NEED_FROMS } from "@/api";
- import { Toast, Modal } from "@/utils";
- const imageList = ref([]);
- const form = reactive({
- goods_name: "",
- imageList: [],
- goods_desc: "",
- min_price: "",
- max_price: "",
- goods_num: "1",
- name: "",
- mobile: "",
- });
- const toRecord = () => {
- uni.navigateTo({
- url: `/pages/purpose/record`,
- });
- };
- const submit = () => {
- if (!form.goods_name) return Toast(t("请输入商品名称"));
- if (!imageList.value.length) return Toast(t("请上传商品图片"));
- if (!form.name) return Toast(t("请输入联系人姓名"));
- if (!form.mobile) return Toast(t("请输入联系人电话"));
- if (imageList.value.length) {
- form.goods_imgs = imageList.value.map((item) => item.url).join(",");
- }
- verificationAdd();
- };
- const verificationAdd = async () => {
- try {
- const res = await RONGIMCALL_NEED_FROMS({ ...form });
- Toast(res.msg, 1000).then(() => {
- setTimeout(() => {
- toRecord();
- }, 1000);
- });
- } catch (error) {
- Toast(error.msg);
- close();
- }
- };
- </script>
- <style lang="less" scoped>
- @import url("@/style.less");
- .wrap {
- background: var(--bg);
- min-height: 100vh;
- padding: 24rpx;
- .nav_right {
- color: var(--text);
- .size(28rpx);
- }
- .form {
- &_item {
- margin-top: 24rpx;
- &:first-child {
- margin-top: 0;
- }
- .item_label {
- font-weight: 700;
- color: var(--text);
- .size(28rpx);
- line-height: 60rpx;
- white-space: nowrap;
- padding-right: 24rpx;
- height: 64rpx;
- width: fit-content;
- position: relative;
- // &::before {
- // content: "*";
- // color: #f56c6c;
- // margin-right: 8rpx;
- // }
- }
- ._required {
- &::before {
- content: "*";
- color: #f56c6c;
- margin-right: 8rpx;
- }
- }
- .item_value {
- column-gap: 24rpx;
- flex: 1;
- display: flex;
- align-items: center;
- gap: 24rpx;
- .value_box {
- flex: 1;
- display: flex;
- flex-direction: column;
- gap: 12rpx;
- .title {
- color: var(--text);
- .size(24rpx);
- font-weight: 500;
- }
- .unit {
- .size(22rpx);
- color: var(--text-01);
- }
- }
- .price_separator {
- width: 60rpx;
- height: 2rpx;
- margin: 0 12rpx;
- align-self: flex-end;
- margin-bottom: 28rpx;
- background-color: var(--text-01);
- }
- /deep/ .u-input {
- height: 80rpx;
- border-radius: 20rpx;
- padding: 0 20rpx !important;
- background-color: var(--inputBg);
- .u-input__content {
- display: flex;
- }
- }
- /deep/ .u-textarea {
- border-radius: 20rpx;
- padding: 0 20rpx !important;
- background-color: var(--inputBg);
- }
- /deep/ .u-number-box {
- border: 1px solid #dcdfe6;
- border-radius: 16rpx;
- .u-number-box__minus,
- .u-number-box__plus {
- width: 56rpx !important;
- height: 56rpx !important;
- background-color: transparent !important;
- .u-icon__icon {
- .size(26rpx) !important;
- color: var(--text) !important;
- }
- &--hover {
- .u-icon__icon {
- color: var(--primary) !important;
- }
- }
- }
- .u-number-box__input {
- margin: 0;
- border-left: 1px solid #dcdfe6;
- border-right: 1px solid #dcdfe6;
- height: 56rpx !important;
- width: 100rpx !important;
- background-color: transparent !important;
- }
- }
- }
- }
- }
- .submit_btn {
- height: 100rpx;
- padding: 16rpx 30rpx;
- background-color: var(--black);
- color: var(--light);
- .flex_center();
- border-radius: 20rpx;
- .size(24rpx);
- margin-top: 40rpx;
- }
- }
- </style>
|