findFunds.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <view class="page-container">
  3. <view class="banner"></view>
  4. <view class="find-funds-info">
  5. <view class="title-box">
  6. <view class="title">请上传1~3张产品图</view>
  7. <view class="f-title">图片越清晰越容易识别款式哦~</view>
  8. </view>
  9. <!-- 上传 -->
  10. <view class="upload-box">
  11. <up-upload
  12. :fileList="imageList"
  13. uploadIcon="plus"
  14. @afterRead="afterRead"
  15. @delete="deletePic"
  16. name="1"
  17. multiple
  18. :maxCount="3"
  19. >
  20. <template #trigger>
  21. <view class="upload-block">
  22. <uni-icons size="38" color="#ccc" type="plusempty"></uni-icons>
  23. </view>
  24. </template>
  25. </up-upload>
  26. </view>
  27. <!-- 信息 -->
  28. <view class="info-box">
  29. <view class="info-item">
  30. <view class="info-label">预估重量(g)</view>
  31. <view class="info-input">
  32. <input type="number" v-model="findFunds.estimatedWeight" />
  33. </view>
  34. </view>
  35. <view class="info-item">
  36. <view class="info-label">理想工费(g)</view>
  37. <view class="info-input">
  38. <input type="number" v-model="findFunds.idealWage" />
  39. </view>
  40. </view>
  41. <view class="info-item">
  42. <view class="info-label">购买件数</view>
  43. <view class="info-input">
  44. <input type="number" v-model="findFunds.numberOfUnits" />
  45. </view>
  46. </view>
  47. <view class="info-item">
  48. <view class="info-label">金属类型</view>
  49. <!-- <up-radio-group v-model="goldType" @change="selectGoldType">
  50. <up-radio
  51. v-for="item in goldList"
  52. :key="item.title"
  53. :name="item.name"
  54. activeColor="#e9c279"
  55. :label="item.title"
  56. ></up-radio>
  57. </up-radio-group> -->
  58. <radio-group
  59. @change="selectGoldType"
  60. class="radio-box"
  61. :value="goldType"
  62. >
  63. <label class="lable-box" v-for="item in goldList" :key="item.title">
  64. <view>
  65. <radio
  66. :value="item.value"
  67. activeBackgroundColor="#e9c279"
  68. :checked="goldType == item.value"
  69. />
  70. </view>
  71. <view>{{ item.title }}</view>
  72. </label>
  73. </radio-group>
  74. </view>
  75. <view class="info-item">
  76. <view class="info-label">买家留言</view>
  77. </view>
  78. <view class="info-input info-item-message">
  79. <up-textarea
  80. v-model="findFunds.description"
  81. placeholder="请输入您的留言,例如:l件3克的戒指"
  82. :maxlength="30"
  83. :count="true"
  84. ></up-textarea>
  85. </view>
  86. </view>
  87. </view>
  88. <!-- 发布找款 -->
  89. <view class="btn-box" @click="publish">
  90. <image class="sb-btn-img" src="/static/images/sb_btn.png"></image>
  91. <text>发布找款</text>
  92. </view>
  93. <!-- 提示 -->
  94. <view class="find-finish-tips">
  95. *发布找款后,正常48小时内会有代购接单,如超时代表未找到该订单,
  96. 请关注订单状态。
  97. </view>
  98. </view>
  99. </template>
  100. <script setup>
  101. import { useToast } from "@/hooks/useToast";
  102. import { useImageUpload } from "@/hooks/useImageUpload";
  103. import { ref, reactive } from "vue";
  104. import { findFundsAPI } from "@/api/find_fund";
  105. const { imageList, afterRead, deletePic, uploadLoading } = useImageUpload({
  106. pid: 10,
  107. model: "Refund",
  108. });
  109. const { Toast } = useToast();
  110. // 选择金料类型
  111. const goldList = reactive([
  112. {
  113. title: "黄金",
  114. value: "au",
  115. },
  116. {
  117. title: "白银",
  118. value: "ag",
  119. },
  120. {
  121. title: "铂金",
  122. value: "pt",
  123. },
  124. // {
  125. // title: "K金",
  126. // name: "kau",
  127. // },
  128. ]);
  129. const goldType = ref("au");
  130. const selectGoldType = (e) => {
  131. goldType.value = e.detail.value;
  132. };
  133. const findFunds = ref({
  134. estimatedWeight: "",
  135. idealWage: "",
  136. metalType: "",
  137. numberOfUnits: "",
  138. purchaserImgs: [],
  139. description: "",
  140. });
  141. // 发布找款
  142. const publish = async () => {
  143. if (checkData()) {
  144. const res = await findFundsAPI({
  145. ...findFunds.value,
  146. metalType: goldType.value,
  147. purchaserImgs: imageList.value.map((v) => v.info.url),
  148. });
  149. Toast({ title: "发布成功", icon: "success" });
  150. uni.redirectTo({ url: "/pages/find_funds/fundsOrder" });
  151. }
  152. };
  153. const checkData = () => {
  154. if (findFunds.value.estimatedWeight == "") {
  155. Toast({ title: "请填写预估重量" });
  156. return false;
  157. }
  158. if (findFunds.value.idealWage == "") {
  159. Toast({ title: "请填写理想工费" });
  160. return false;
  161. }
  162. if (findFunds.value.numberOfUnits == "") {
  163. Toast({ title: "请填写购买件数" });
  164. return false;
  165. }
  166. if (findFunds.value.description == "") {
  167. Toast({ title: "请填写买家留言" });
  168. return false;
  169. }
  170. if (imageList.value.length == 0) {
  171. Toast({ title: "请上传产品图" });
  172. return false;
  173. }
  174. return true;
  175. };
  176. // 请输入您的留言
  177. // const message = ref("");
  178. </script>
  179. <style lang="scss" scoped>
  180. .page-container {
  181. width: 750rpx;
  182. height: 100vh;
  183. padding: 20rpx 30rpx;
  184. display: flex;
  185. flex-direction: column;
  186. align-items: center;
  187. position: relative;
  188. min-height: 100vh;
  189. background: $uni-bg-primary;
  190. // .banner {
  191. // position: absolute;
  192. // left: 0;
  193. // top: 0;
  194. // width: 100%;
  195. // height: 50vh;
  196. // background-image: linear-gradient(
  197. // 360deg,
  198. // #ffffff 0%,
  199. // #e8c279 100%
  200. // ) !important;
  201. // z-index: -1;
  202. // }
  203. .find-funds-info {
  204. width: 682rpx;
  205. min-height: 1069rpx;
  206. background-color: #ffffff;
  207. box-shadow: 0rpx 3rpx 13rpx 0rpx rgba(0, 0, 0, 0.13);
  208. border-radius: 20rpx;
  209. box-sizing: border-box;
  210. padding: 40rpx;
  211. .title-box {
  212. display: flex;
  213. flex-direction: column;
  214. align-items: center;
  215. // padding: 30rpx;
  216. box-sizing: border-box;
  217. .title {
  218. font-size: 28rpx;
  219. color: #000000;
  220. }
  221. .f-title {
  222. font-size: 21rpx;
  223. color: #848484;
  224. }
  225. }
  226. .upload-box {
  227. margin-top: 40rpx;
  228. .upload-block {
  229. width: 160rpx;
  230. height: 160rpx;
  231. border: 1px solid #ccc;
  232. border-radius: 10rpx;
  233. display: flex;
  234. flex-direction: column;
  235. justify-content: center;
  236. align-items: center;
  237. color: #ccc;
  238. font-weight: 700;
  239. font-size: 26rpx;
  240. }
  241. }
  242. .info-box {
  243. .info-item {
  244. display: flex;
  245. align-items: center;
  246. margin: 40rpx 0rpx;
  247. position: relative;
  248. .info-label {
  249. font-size: 26rpx;
  250. color: #000000;
  251. width: 200rpx;
  252. }
  253. .info-input {
  254. width: 437rpx;
  255. height: 69rpx;
  256. background-color: #f3f3f3;
  257. border-radius: 10rpx;
  258. display: flex;
  259. align-items: center;
  260. input {
  261. width: 100%;
  262. height: 100%;
  263. padding-left: 10rpx;
  264. }
  265. }
  266. }
  267. }
  268. }
  269. .btn-box {
  270. width: 270rpx;
  271. height: 66rpx;
  272. font-size: 28rpx;
  273. color: #000;
  274. position: relative;
  275. margin-top: 40rpx;
  276. .sb-btn-img {
  277. width: 100%;
  278. height: 100%;
  279. }
  280. text {
  281. position: absolute;
  282. top: 50%;
  283. left: 50%;
  284. transform: translate(-50%, -50%);
  285. white-space: nowrap;
  286. }
  287. }
  288. .find-finish-tips {
  289. margin-top: 50rpx;
  290. font-family: Source Han Sans CN;
  291. font-size: 21rpx;
  292. line-height: 30rpx;
  293. color: #7c7c7c;
  294. }
  295. .radio-box {
  296. width: 437rpx;
  297. display: flex;
  298. justify-content: space-between;
  299. .lable-box {
  300. display: flex;
  301. align-items: center;
  302. margin-right: 10rpx;
  303. }
  304. }
  305. }
  306. </style>