index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <Theme>
  3. <view class="wrap">
  4. <Navbar title="意向表单" fixed border>
  5. <template #right>
  6. <view class="nav_right" @click.stop="toRecord">
  7. <trans _t="意向记录" />
  8. </view>
  9. </template>
  10. </Navbar>
  11. <view class="form">
  12. <view class="form_item">
  13. <view class="item_label _required">
  14. <trans _t="商品名称" />
  15. </view>
  16. <view class="item_value">
  17. <Input
  18. :placeholder="t('请输入商品名称')"
  19. border="surround"
  20. v-model="form.goods_name"
  21. :maxlength="50"
  22. />
  23. </view>
  24. </view>
  25. <view class="form_item">
  26. <view class="item_label _required">
  27. <trans _t="商品图片" />
  28. </view>
  29. <view class="item_value">
  30. <imageUpload v-model="imageList" :maxCount="6" multiple />
  31. </view>
  32. </view>
  33. <view class="form_item">
  34. <view class="item_label">
  35. <trans _t="商品详细描述" />
  36. </view>
  37. <view class="item_value">
  38. <up-textarea
  39. v-model="form.goods_desc"
  40. :placeholder="t('请输入商品详细描述')"
  41. count
  42. autoHeight
  43. border="surround"
  44. maxlength="500"
  45. ></up-textarea>
  46. </view>
  47. </view>
  48. <view class="form_item">
  49. <view class="item_label">
  50. <trans _t="价格区间" />
  51. </view>
  52. <view class="item_value">
  53. <view class="value_box">
  54. <trans _t="最低价" class="title" />
  55. <Input border="surround" type="Number" v-model="form.min_price">
  56. <template #suffix>
  57. <trans _t="元" class="unit" />
  58. </template>
  59. </Input>
  60. </view>
  61. <view class="price_separator"></view>
  62. <view class="value_box">
  63. <trans _t="最高价" class="title" />
  64. <Input border="surround" type="Number" v-model="form.max_price">
  65. <template #suffix>
  66. <trans _t="元" class="unit" />
  67. </template>
  68. </Input>
  69. </view>
  70. </view>
  71. </view>
  72. <view class="form_item">
  73. <view class="item_label">
  74. <trans _t="购买数量" />
  75. </view>
  76. <view class="item_value">
  77. <up-number-box v-model="form.goods_num" :min="1"></up-number-box>
  78. </view>
  79. </view>
  80. <view class="form_item">
  81. <view class="item_label _required">
  82. <trans _t="联系人姓名" />
  83. </view>
  84. <view class="item_value">
  85. <Input
  86. :placeholder="t('请输入联系人姓名')"
  87. border="surround"
  88. v-model="form.name"
  89. />
  90. </view>
  91. </view>
  92. <view class="form_item">
  93. <view class="item_label _required">
  94. <trans _t="联系人电话" />
  95. </view>
  96. <view class="item_value">
  97. <Input
  98. :placeholder="t('请输入联系人电话')"
  99. border="surround"
  100. type="Number"
  101. v-model="form.mobile"
  102. />
  103. </view>
  104. </view>
  105. </view>
  106. <view class="footer">
  107. <view class="submit_btn" @click="submit">
  108. <trans _t="提交" />
  109. </view>
  110. </view>
  111. </view>
  112. </Theme>
  113. </template>
  114. <script setup>
  115. import Navbar from "@/components/navbar";
  116. import { reactive, ref, watch, nextTick } from "vue";
  117. import { t } from "@/locale";
  118. import Input from "@/components/input";
  119. import imageUpload from "@/components/imageUpload.vue";
  120. import { RONGIMCALL_NEED_FROMS } from "@/api";
  121. import { Toast, Modal } from "@/utils";
  122. const imageList = ref([]);
  123. const form = reactive({
  124. goods_name: "",
  125. imageList: [],
  126. goods_desc: "",
  127. min_price: "",
  128. max_price: "",
  129. goods_num: "1",
  130. name: "",
  131. mobile: "",
  132. });
  133. const toRecord = () => {
  134. uni.navigateTo({
  135. url: `/pages/purpose/record`,
  136. });
  137. };
  138. const submit = () => {
  139. if (!form.goods_name) return Toast(t("请输入商品名称"));
  140. if (!imageList.value.length) return Toast(t("请上传商品图片"));
  141. if (!form.name) return Toast(t("请输入联系人姓名"));
  142. if (!form.mobile) return Toast(t("请输入联系人电话"));
  143. if (imageList.value.length) {
  144. form.goods_imgs = imageList.value.map((item) => item.url).join(",");
  145. }
  146. verificationAdd();
  147. };
  148. const verificationAdd = async () => {
  149. try {
  150. const res = await RONGIMCALL_NEED_FROMS({ ...form });
  151. Toast(res.msg, 1000).then(() => {
  152. setTimeout(() => {
  153. toRecord();
  154. }, 1000);
  155. });
  156. } catch (error) {
  157. Toast(error.msg);
  158. close();
  159. }
  160. };
  161. </script>
  162. <style lang="less" scoped>
  163. @import url("@/style.less");
  164. .wrap {
  165. background: var(--bg);
  166. min-height: 100vh;
  167. padding: 24rpx;
  168. .nav_right {
  169. color: var(--text);
  170. .size(28rpx);
  171. }
  172. .form {
  173. &_item {
  174. margin-top: 24rpx;
  175. &:first-child {
  176. margin-top: 0;
  177. }
  178. .item_label {
  179. font-weight: 700;
  180. color: var(--text);
  181. .size(28rpx);
  182. line-height: 60rpx;
  183. white-space: nowrap;
  184. padding-right: 24rpx;
  185. height: 64rpx;
  186. width: fit-content;
  187. position: relative;
  188. // &::before {
  189. // content: "*";
  190. // color: #f56c6c;
  191. // margin-right: 8rpx;
  192. // }
  193. }
  194. ._required {
  195. &::before {
  196. content: "*";
  197. color: #f56c6c;
  198. margin-right: 8rpx;
  199. }
  200. }
  201. .item_value {
  202. column-gap: 24rpx;
  203. flex: 1;
  204. display: flex;
  205. align-items: center;
  206. gap: 24rpx;
  207. .value_box {
  208. flex: 1;
  209. display: flex;
  210. flex-direction: column;
  211. gap: 12rpx;
  212. .title {
  213. color: var(--text);
  214. .size(24rpx);
  215. font-weight: 500;
  216. }
  217. .unit {
  218. .size(22rpx);
  219. color: var(--text-01);
  220. }
  221. }
  222. .price_separator {
  223. width: 60rpx;
  224. height: 2rpx;
  225. margin: 0 12rpx;
  226. align-self: flex-end;
  227. margin-bottom: 28rpx;
  228. background-color: var(--text-01);
  229. }
  230. /deep/ .u-input {
  231. height: 80rpx;
  232. border-radius: 20rpx;
  233. padding: 0 20rpx !important;
  234. background-color: var(--inputBg);
  235. .u-input__content {
  236. display: flex;
  237. }
  238. }
  239. /deep/ .u-textarea {
  240. border-radius: 20rpx;
  241. padding: 0 20rpx !important;
  242. background-color: var(--inputBg);
  243. }
  244. /deep/ .u-number-box {
  245. border: 1px solid #dcdfe6;
  246. border-radius: 16rpx;
  247. .u-number-box__minus,
  248. .u-number-box__plus {
  249. width: 56rpx !important;
  250. height: 56rpx !important;
  251. background-color: transparent !important;
  252. .u-icon__icon {
  253. .size(26rpx) !important;
  254. color: var(--text) !important;
  255. }
  256. &--hover {
  257. .u-icon__icon {
  258. color: var(--primary) !important;
  259. }
  260. }
  261. }
  262. .u-number-box__input {
  263. margin: 0;
  264. border-left: 1px solid #dcdfe6;
  265. border-right: 1px solid #dcdfe6;
  266. height: 56rpx !important;
  267. width: 100rpx !important;
  268. background-color: transparent !important;
  269. }
  270. }
  271. }
  272. }
  273. }
  274. .submit_btn {
  275. height: 100rpx;
  276. padding: 16rpx 30rpx;
  277. background-color: var(--black);
  278. color: var(--light);
  279. .flex_center();
  280. border-radius: 20rpx;
  281. .size(24rpx);
  282. margin-top: 40rpx;
  283. }
  284. }
  285. </style>