环卫车小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

792 lines
24 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
5 months ago
  1. <template>
  2. <view class="se-m-20 se-p-20 se-br-10">
  3. <u--form labelPosition="left" :model="form" :rules="rules" ref="uForm" labelWidth="80">
  4. <u-form-item labelWidth="0">
  5. <view class="se-fs-26 se-c-black se-pb-10">
  6. 请选择您要发布的车辆类型
  7. </view>
  8. <view class="se-flex se-flex-ai-c se-flex-ff-rw">
  9. <view v-if="item.name !='环卫设备及配件'" class="se-py-10 se-px-30 se-fs-22 se-br-10 se-mr-15 se-mt-10" :class="item.id==form.cartypeId ? 'se-bgc-green se-c-white se-b-green' : 'se-b se-c-text'" @click="handleCartype(item)" v-for="(item,index) in categoryList" :key="index">
  10. {{item.name}}
  11. </view>
  12. </view>
  13. </u-form-item>
  14. <!-- <u-form-item label="一级分类" prop="cartypeId" @click="handleCategoryOneChange()">
  15. <u--input readonly v-model="form.cartypeName" placeholder="请选择一级分类" border="bottom"></u--input>
  16. <u-icon slot="right" name="arrow-right"></u-icon>
  17. </u-form-item> -->
  18. <u-form-item label="二级分类" prop="categorytwoId" @click="handleCategoryTwoChange()">
  19. <u--input readonly v-model="form.categorytwoName" placeholder="请选择二级分类" border="bottom"></u--input>
  20. <u-icon slot="right" name="arrow-right"></u-icon>
  21. </u-form-item>
  22. <u-form-item label="标题" prop="goodsName">
  23. <view class="se-flex se-flex-h-c">
  24. <u--input v-model="form.goodsName" type="text" class="se-w-200" placeholder="请填写标题"></u--input>
  25. </view>
  26. </u-form-item>
  27. <u-form-item label="品牌" prop="brand">
  28. <view class="se-flex se-flex-h-c">
  29. <u--input v-model="form.brand" type="text" class="se-w-200" placeholder="请填写品牌"></u--input>
  30. </view>
  31. </u-form-item>
  32. <u-form-item label="型号" prop="model">
  33. <view class="se-flex se-flex-h-c">
  34. <u--input v-model="form.model" type="text" class="se-w-200" placeholder="请填写型号"></u--input>
  35. </view>
  36. </u-form-item>
  37. <u-form-item label="区域" prop="area" @click="handleAreaChange()">
  38. <u--input readonly v-model="form.area" placeholder="请选择地址" border="bottom"></u--input>
  39. <u-icon slot="right" name="arrow-right"></u-icon>
  40. </u-form-item>
  41. <u-form-item label="年限" prop="date" @click="showDate=true">
  42. <u--input border="bottom" type="number" v-model="form.date" readonly placeholder="请填写年限"></u--input>
  43. <u-icon slot="right" name="arrow-right"></u-icon>
  44. </u-form-item>
  45. <u-form-item label="公里数" prop="mileage">
  46. <u--input v-model="form.mileage" type="number" placeholder="请填写公里数"></u--input>
  47. </u-form-item>
  48. <u-form-item label="价格" prop="price">
  49. <u--input v-model="form.price" type="number" placeholder="请填写价格"></u--input>
  50. <div slot="right" class="se-c-green"> <text v-if="form.cartypeName=='租赁车辆'">/</text> </div>
  51. </u-form-item>
  52. <u-form-item label="库存" prop="inventory">
  53. <u--input v-model="form.inventory" type="number" placeholder="请填写库存"></u--input>
  54. </u-form-item>
  55. <u-form-item label="联系人" prop="contacts">
  56. <u--input v-model="form.contacts" type="text" placeholder="请填写联系人"></u--input>
  57. </u-form-item>
  58. <u-form-item label="联系人电话" prop="phone">
  59. <u--input v-model="form.phone" type="number" placeholder="请填写电话"></u--input>
  60. </u-form-item>
  61. <u-form-item label="浏览量" prop="views">
  62. <u--input v-model="form.views" type="number" placeholder="请填写浏览量"></u--input>
  63. </u-form-item>
  64. <u-form-item prop="fileCarList" labelWidth="0">
  65. <view class="se-flex se-flex-v-sa">
  66. <view class="se-py-20 se-w-p-100 se-flex">
  67. 车辆照片
  68. </view>
  69. <view class="se-py-20 se-w-p-100">
  70. <u-upload :fileList="form.fileCarList" @afterRead="afterCarFront" @delete="delCarFront" multiple :maxCount="5"></u-upload>
  71. </view>
  72. </view>
  73. </u-form-item>
  74. <u-form-item prop="fileFrontList" labelWidth="0">
  75. <view class="se-flex se-flex-v-sa">
  76. <view class="se-py-20 se-w-p-100 se-flex">
  77. 车辆照片()
  78. </view>
  79. <view class="se-py-20 se-w-p-100">
  80. <u-upload :fileList="form.fileFrontList" @afterRead="afterFront" @delete="delFront" multiple :maxCount="5"></u-upload>
  81. </view>
  82. </view>
  83. </u-form-item>
  84. <u-form-item prop="fileBackList" labelWidth="0">
  85. <view class="se-flex se-flex-v-sa">
  86. <view class="se-py-20 se-w-p-100 se-flex">
  87. 车辆照片()
  88. </view>
  89. <view class="se-py-20 se-w-p-100">
  90. <u-upload :fileList="form.fileBackList" @afterRead="afterBack" @delete="delBack" multiple :maxCount="5"></u-upload>
  91. </view>
  92. </view>
  93. </u-form-item>
  94. <u-form-item prop="fileLeftList" labelWidth="0">
  95. <view class="se-flex se-flex-v-sa">
  96. <view class="se-py-20 se-w-p-100 se-flex">
  97. 车辆照片()
  98. </view>
  99. <view class="se-py-20 se-w-p-100">
  100. <u-upload :fileList="form.fileLeftList" @afterRead="afterLeft" @delete="delLeft" multiple :maxCount="5"></u-upload>
  101. </view>
  102. </view>
  103. </u-form-item>
  104. <u-form-item prop="fileRightList" labelWidth="0">
  105. <view class="se-flex se-flex-v-sa">
  106. <view class="se-py-20 se-w-p-100 se-flex">
  107. 车辆照片()
  108. </view>
  109. <view class="se-py-20 se-w-p-100">
  110. <u-upload :fileList="form.fileRightList" @afterRead="afterRight" @delete="delRight" multiple :maxCount="5"></u-upload>
  111. </view>
  112. </view>
  113. </u-form-item>
  114. <u-form-item prop="fileCabList" labelWidth="0">
  115. <view class="se-flex se-flex-v-sa">
  116. <view class="se-py-20 se-w-p-100 se-flex">
  117. 车辆照片(驾驶室)
  118. </view>
  119. <view class="se-py-20 se-w-p-100">
  120. <u-upload :fileList="form.fileCabList" @afterRead="afterCab" @delete="delCab" multiple :maxCount="5"></u-upload>
  121. </view>
  122. </view>
  123. </u-form-item>
  124. <u-form-item label="车辆介绍" labelPosition="top" prop="introduce">
  125. <u--textarea v-model="form.introduce" class="se-mt-20" count
  126. placeholder="请填写车辆介绍"></u--textarea>
  127. </u-form-item>
  128. <u-form-item>
  129. <view class="se-px-20 se-pt-20">
  130. <view class="se-px-20 se-pb-80 se-fs-20 se-flex">
  131. <view @click="onSubmit"
  132. class="se-mx-10 se-flex-1 se-br-40 se-flex-h-c se-h-80 se-lh-80 se-ta-c se-fs-28 se-c-white se-bgc-green">
  133. <text>提交订单</text>
  134. </view>
  135. </view>
  136. </view>
  137. </u-form-item>
  138. </u--form>
  139. <u-picker :show="showDate" :columns="columns" @confirm="onConfirm"
  140. @cancel="onCancel"></u-picker>
  141. <!-- <u-datetime-picker
  142. :maxDate="maxDate"
  143. :show="showDate"
  144. v-model="date"
  145. mode="year"
  146. @confirm="onConfirm"
  147. @cancel="onCancel"
  148. ></u-datetime-picker> -->
  149. <u-action-sheet :actions="categoryOneList" @select="selectCategoryOneClick" title="分类" :show="categoryOneShow" @close="categoryOneShow=false"></u-action-sheet>
  150. <u-action-sheet :actions="categoryTwoList" @select="selectCategoryTwoClick" title="分类" :show="categoryTwoShow" @close="categoryTwoShow=false"></u-action-sheet>
  151. </view>
  152. </template>
  153. <script>
  154. const now = new Date();
  155. const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();
  156. const startOfYesterday = startOfToday - 24 * 60 * 60 * 1000;
  157. import { queryTypeList,addGoods,queryCategoryOneList,queryCategoryTwoList,queryCategoryList,queryGoodsById } from "@/common/api.js"
  158. import QQMapWX from "@/util/qqmap-wx-jssdk.min.js"
  159. export default {
  160. components:{
  161. },
  162. data() {
  163. return {
  164. id:null,
  165. columns:[['2025', '2024', '2023', '2022', '2020', '2019', '2018', '2017', '2016', '2015', '2014', '2013', '2012', '2011', '2010', '2009', '2008', '2007', '2006', '2005', '2004', '2003', '2002', '2001', '2000']],
  166. maxDate:startOfYesterday,
  167. actions:[],
  168. showType:false,
  169. showDate:false,
  170. date:Number(new Date()),
  171. categoryOneShow:false,
  172. categoryOneList:[],
  173. categoryTwoShow:false,
  174. categoryTwoList:[],
  175. categoryList:[],//分类
  176. form: {
  177. // typeId:"",//类型
  178. // cartypeId:"",//一级分类
  179. // cartypeName:"",//一级分类名称
  180. // categorytwoId:"",//二级分类
  181. // categorytwoName:"",//二级分类名称
  182. // goodsName:"驾驶式扫地机",//标题
  183. // brand:"大众",//品牌
  184. // model:"朗逸",//型号
  185. // area:"湖南省长沙市岳麓区含光路658号",//区域
  186. // latitude:"28.23586",
  187. // longitude:"112.931496",
  188. // address:'',
  189. // date:"2024-12-15",//时间
  190. // mileage:"2000",//距离
  191. // price:"210000",//价格
  192. // inventory:"5",//库存
  193. // contacts:"柳川",//联系人
  194. // phone:"13189698115",//联系人电话
  195. // views:"5",//浏览量
  196. // fileCarList:[
  197. // {
  198. // url:"https://tennis-oss.xzaiyp.top/2024-12-14/7e98056b-e0b9-496f-89f8-88026ce9426e.png"
  199. // },
  200. // {
  201. // url:"https://tennis-oss.xzaiyp.top/2024-12-14/499fcd8a-3d4b-42f3-b023-61bac6b1c020.png"
  202. // }
  203. // ],//车辆照片
  204. // fileFrontList:[
  205. // {
  206. // url:"https://tennis-oss.xzaiyp.top/2024-12-14/7e98056b-e0b9-496f-89f8-88026ce9426e.png"
  207. // },
  208. // {
  209. // url:"https://tennis-oss.xzaiyp.top/2024-12-14/499fcd8a-3d4b-42f3-b023-61bac6b1c020.png"
  210. // }
  211. // ],//车辆照片前
  212. // fileBackList:[
  213. // {
  214. // url:"https://tennis-oss.xzaiyp.top/2024-12-14/7e98056b-e0b9-496f-89f8-88026ce9426e.png"
  215. // },
  216. // {
  217. // url:"https://tennis-oss.xzaiyp.top/2024-12-14/499fcd8a-3d4b-42f3-b023-61bac6b1c020.png"
  218. // }
  219. // ],//车辆照片后
  220. // fileLeftList:[
  221. // {
  222. // url:"https://tennis-oss.xzaiyp.top/2024-12-14/7e98056b-e0b9-496f-89f8-88026ce9426e.png"
  223. // },
  224. // {
  225. // url:"https://tennis-oss.xzaiyp.top/2024-12-14/499fcd8a-3d4b-42f3-b023-61bac6b1c020.png"
  226. // }
  227. // ],//车辆照片左
  228. // fileRightList:[
  229. // {
  230. // url:"https://tennis-oss.xzaiyp.top/2024-12-14/7e98056b-e0b9-496f-89f8-88026ce9426e.png"
  231. // },
  232. // {
  233. // url:"https://tennis-oss.xzaiyp.top/2024-12-14/499fcd8a-3d4b-42f3-b023-61bac6b1c020.png"
  234. // }
  235. // ],//车辆照片右
  236. // fileCabList:[
  237. // {
  238. // status:1,
  239. // url:"https://tennis-oss.xzaiyp.top/2024-12-14/7e98056b-e0b9-496f-89f8-88026ce9426e.png"
  240. // },
  241. // {
  242. // status:0,
  243. // url:"https://tennis-oss.xzaiyp.top/2024-12-14/499fcd8a-3d4b-42f3-b023-61bac6b1c020.png"
  244. // }
  245. // ],//车辆照片 驾驶室
  246. // introduce:`车型名称:车辆的品牌和型号,例如 "Toyota Corolla 2024"。
  247. // 车辆类型:轿车、SUV、MPV、皮卡、跑车等。
  248. // 价格区间:可选项,适用于市场推广。`,//车辆介绍
  249. typeId:"",//类型
  250. typeName:"",//类型名称
  251. cartypeId:"",//一级分类
  252. cartypeName:"",//一级分类名称
  253. categorytwoId:"",//二级分类
  254. categorytwoName:"",//二级分类名称
  255. goodsName:"",//标题
  256. brand:"",//品牌
  257. model:"",//型号
  258. area:"",//区域
  259. latitude:"",
  260. longitude:"",
  261. address:'',
  262. date:"",//时间
  263. mileage:"",//距离
  264. price:"",//价格
  265. inventory:"",//库存
  266. contacts:"",//联系人
  267. phone:"",//联系人电话
  268. views:"",//浏览量
  269. fileCarList:[],//车辆照片
  270. fileFrontList:[],//车辆照片前
  271. fileBackList:[],//车辆照片后
  272. fileLeftList:[],//车辆照片左
  273. fileRightList:[],//车辆照片右
  274. fileCabList:[],//车辆照片 驾驶室
  275. introduce:``,//车辆介绍
  276. },
  277. rules: {
  278. typeId:[
  279. {
  280. required: true,
  281. message: '请选择类型',
  282. trigger: ['blur', 'change']
  283. }
  284. ],
  285. goodsName:[
  286. {
  287. required: true,
  288. message: '请填写标题',
  289. trigger: ['blur', 'change']
  290. }
  291. ],
  292. brand:[
  293. {
  294. required: true,
  295. message: '请填写品牌',
  296. trigger: ['blur', 'change']
  297. }
  298. ],
  299. model:[
  300. {
  301. required: true,
  302. message: '请填写型号',
  303. trigger: ['blur', 'change']
  304. }
  305. ],
  306. area:[
  307. {
  308. required: true,
  309. message: '请选择所在地区',
  310. trigger: ['blur', 'change']
  311. }
  312. ],
  313. date:[
  314. {
  315. required: true,
  316. message: '请填写时间',
  317. trigger: ['blur', 'change']
  318. }
  319. ],
  320. mileage:[
  321. {
  322. required: true,
  323. message: '请填写公里数',
  324. trigger: ['blur', 'change']
  325. }
  326. ],
  327. price:[
  328. {
  329. required: true,
  330. message: '请填写价格',
  331. trigger: ['blur']
  332. }
  333. ],
  334. inventory:[
  335. {
  336. required: true,
  337. message: '请填写库存',
  338. trigger: ['blur']
  339. }
  340. ],
  341. contacts:[
  342. {
  343. required: true,
  344. message: '请填写联系人',
  345. trigger: ['blur', 'change']
  346. }
  347. ],
  348. phone:[
  349. {
  350. required: true,
  351. message: '请填写联系电话',
  352. trigger: ['blur', 'change']
  353. }
  354. ],
  355. views:[
  356. {
  357. required: true,
  358. message: '请填写浏览量',
  359. trigger: ['blur']
  360. }
  361. ],
  362. fileCarList:[
  363. {
  364. validator: (rule, value, callback) => {
  365. if (value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0)) {
  366. callback(new Error('照片不能为空'));
  367. } else {
  368. callback();
  369. }
  370. },
  371. trigger: 'blur'
  372. }
  373. ],
  374. fileFrontList:[
  375. {
  376. validator: (rule, value, callback) => {
  377. if (value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0)) {
  378. callback(new Error('照片不能为空'));
  379. } else {
  380. callback();
  381. }
  382. },
  383. trigger: 'blur'
  384. }
  385. ],
  386. fileBackList:[
  387. {
  388. validator: (rule, value, callback) => {
  389. if (value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0)) {
  390. callback(new Error('照片不能为空'));
  391. } else {
  392. callback();
  393. }
  394. },
  395. trigger: 'blur'
  396. }
  397. ],
  398. fileLeftList:[
  399. {
  400. validator: (rule, value, callback) => {
  401. if (value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0)) {
  402. callback(new Error('照片不能为空'));
  403. } else {
  404. callback();
  405. }
  406. },
  407. trigger: 'blur'
  408. }
  409. ],
  410. fileRightList:[
  411. {
  412. validator: (rule, value, callback) => {
  413. if (value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0)) {
  414. callback(new Error('照片不能为空'));
  415. } else {
  416. callback();
  417. }
  418. },
  419. trigger: 'blur'
  420. }
  421. ],
  422. fileCabList:[
  423. {
  424. validator: (rule, value, callback) => {
  425. if (value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0)) {
  426. callback(new Error('照片不能为空'));
  427. } else {
  428. callback();
  429. }
  430. },
  431. trigger: 'blur'
  432. }
  433. ],
  434. }
  435. }
  436. },
  437. onLoad(options) {
  438. let that = this
  439. if(options.id){
  440. that.id = options.id
  441. that.getQueryGoodsById()
  442. }else{
  443. that.onQueryCategoryList()
  444. }
  445. // this.onQueryTypeList()
  446. // this.onQueryCategoryOneList()
  447. // this.onQueryCategoryTwoList()
  448. },
  449. watch: {
  450. // "form.categorytwoId": function (newVal, oldVal) {
  451. // if (newVal) {
  452. // this.$nextTick(() => {
  453. // this.form.categorytwoName = this.categoryTwoList
  454. // .filter((item) => item.id == newVal)
  455. // .map((item) => item.name)
  456. // .join('');
  457. // });
  458. // }
  459. // }
  460. },
  461. methods: {
  462. getQueryGoodsById(){
  463. let that = this
  464. queryGoodsById({goodsId:that.id}).then(response=>{
  465. let items = response.result;
  466. console.info("queryGoodsById",response)
  467. that.form.cartypeId=items.cartypeId
  468. that.form.categorytwoId=items.categorytwoId
  469. that.form.categorytwoName=items.categorytwoName
  470. that.form.goodsName=items.goodsName
  471. that.form.brand=items.brand
  472. that.form.model=items.model
  473. that.form.area=items.area
  474. that.form.latitude=items.latitude
  475. that.form.date=String(items.goodsTime)
  476. that.form.inventory=String(items.inventory)
  477. that.form.mileage=String(items.mileage)
  478. that.form.contacts=items.userName
  479. that.form.phone=items.phone
  480. that.form.price=String(items.price)
  481. that.form.views=String(items.views)
  482. that.form.introduce=items.detail
  483. that.form.fileCarList=items.image.split(',').map((url) => ({ url }))
  484. that.form.fileBackList=items.imageBack.split(',').map((url) => ({ url }))
  485. that.form.fileCabList=items.imageCab.split(',').map((url) => ({ url }))
  486. that.form.fileFrontList=items.imageFront.split(',').map((url) => ({ url }))
  487. that.form.fileLeftList=items.imageLeft.split(',').map((url) => ({ url }))
  488. that.form.fileRightList=items.imageRight.split(',').map((url) => ({ url }))
  489. that.onQueryCategoryList()
  490. // this.$refs.uForm.setRules(this.rules)
  491. }).catch(error=>{
  492. })
  493. },
  494. onQueryCategoryList(){
  495. let that = this
  496. queryCategoryList({}).then(response=>{
  497. console.info("queryCategoryList",response)
  498. if(response.result.length>0){
  499. that.categoryList = response.result
  500. if(!that.id){
  501. that.form.cartypeId = response.result[0].id
  502. that.form.cartypeName = response.result[0].name
  503. that.categoryTwoList = response.result[0].carrentCategorytwoList
  504. }else{
  505. that.categoryTwoList = response.result.find(item => item.id == that.form.cartypeId).carrentCategorytwoList
  506. }
  507. }
  508. }).catch(error=>{
  509. })
  510. },
  511. handleCategoryOneChange(){
  512. console.info('handleCategoryOneChange')
  513. this.categoryOneShow = true
  514. },
  515. selectCategoryOneClick(event){
  516. console.info(event)
  517. this.form.cartypeId = event.id
  518. this.form.cartypeName = event.name
  519. this.categoryOneShow = false
  520. },
  521. onQueryCategoryOneList(){
  522. let that = this
  523. let params = {}
  524. queryCategoryOneList(params).then(response=>{
  525. console.info("queryCategoryOneList",response)
  526. that.categoryOneList = response.result.records
  527. }).catch(error=>{
  528. })
  529. },
  530. handleCategoryTwoChange(){
  531. console.info('handleCategoryTwoChange')
  532. this.categoryTwoShow = true
  533. },
  534. selectCategoryTwoClick(event){
  535. console.info("selectCategoryTwoClick",event)
  536. this.form.categorytwoId = event.id
  537. this.form.categorytwoName = event.name
  538. this.categoryTwoShow = false
  539. },
  540. onQueryCategoryTwoList(){
  541. let that = this
  542. let params = {
  543. categoryoneId:"1867039853005877250"
  544. }
  545. queryCategoryTwoList(params).then(response=>{
  546. console.info("queryCategoryTwoList",response)
  547. that.categoryTwoList = response.result.records
  548. }).catch(error=>{
  549. })
  550. },
  551. onQueryTypeList(){
  552. queryTypeList({}).then(response=>{
  553. console.info("queryTypeList",response)
  554. this.actions = response.result.records
  555. this.form.typeId = response.result.records[0].id
  556. }).catch(error=>{
  557. })
  558. },
  559. onCancel(){
  560. this.showDate = false
  561. },
  562. onConfirm(e){
  563. console.info('e',e)
  564. this.form.date = e.value[0];
  565. this.showDate = false
  566. // const date = new Date(e.value);
  567. // const year = date.getFullYear();
  568. // const month = String(date.getMonth() + 1).padStart(2, '0');
  569. // const day = String(date.getDate()).padStart(2, '0');
  570. // this.form.date = `${year}-${month}-${day}`;
  571. // this.showDate = false
  572. },
  573. handleAreaChange(){
  574. const that = this;
  575. wx.chooseLocation({
  576. // type: 'wgs84',
  577. success: function (res) {
  578. const qqmapsdk = new QQMapWX({
  579. key: 'TT7BZ-Z3LW4-KOAUB-KWHOA-SBJJ6-Y5B6R' // 必填
  580. });
  581. uni.showLoading({
  582. title:"获取中...."
  583. })
  584. qqmapsdk.reverseGeocoder({
  585. location: {
  586. latitude: res.latitude,
  587. longitude: res.longitude
  588. },
  589. success: function(response) {
  590. console.log('逆地理编码结果:', response);
  591. uni.hideLoading()
  592. that.form.longitude = response.result.location.lng
  593. that.form.latitude = response.result.location.lat
  594. that.form.area = response.result.address
  595. },
  596. fail: function(error) {
  597. uni.hideLoading()
  598. console.error('逆地理编码失败:', error);
  599. }
  600. });
  601. }
  602. })
  603. // this.$refs.citySelectRef.open()
  604. },
  605. handleCartype(event){
  606. this.form.cartypeId = event.id
  607. this.form.cartypeName = event.name
  608. this.categoryTwoList =event.carrentCategorytwoList
  609. this.form.categorytwoId = ""
  610. this.form.categorytwoName = ""
  611. },
  612. // 照片
  613. delCarFront(event) {
  614. this.form.fileCarList.splice(event.index, 1)
  615. },
  616. async afterCarFront(e) {
  617. let self = this
  618. e.file.forEach(file => {
  619. self.$Oss.ossUpload(file.url).then(url => {
  620. self.form.fileCarList.push({
  621. url
  622. })
  623. })
  624. })
  625. },
  626. // 前
  627. delFront(event) {
  628. this.form.fileFrontList.splice(event.index, 1)
  629. },
  630. async afterFront(e) {
  631. let self = this
  632. e.file.forEach(file => {
  633. self.$Oss.ossUpload(file.url).then(url => {
  634. self.form.fileFrontList.push({
  635. url
  636. })
  637. })
  638. })
  639. },
  640. // 后
  641. delBack(event) {
  642. this.form.fileBackList.splice(event.index, 1)
  643. },
  644. async afterBack(e) {
  645. let self = this
  646. e.file.forEach(file => {
  647. self.$Oss.ossUpload(file.url).then(url => {
  648. self.form.fileBackList.push({
  649. url
  650. })
  651. })
  652. })
  653. },
  654. // 左
  655. delLeft(event) {
  656. this.form.fileLeftList.splice(event.index, 1)
  657. },
  658. async afterLeft(e) {
  659. let self = this
  660. e.file.forEach(file => {
  661. self.$Oss.ossUpload(file.url).then(url => {
  662. self.form.fileLeftList.push({
  663. url
  664. })
  665. })
  666. })
  667. },
  668. // 左
  669. delRight(event) {
  670. this.form.fileRightList.splice(event.index, 1)
  671. },
  672. async afterRight(e) {
  673. let self = this
  674. e.file.forEach(file => {
  675. self.$Oss.ossUpload(file.url).then(url => {
  676. self.form.fileRightList.push({
  677. url
  678. })
  679. })
  680. })
  681. },
  682. // 车辆照片(驾驶室)
  683. delCab(event) {
  684. this.form.fileCabList.splice(event.index, 1)
  685. },
  686. async afterCab(e) {
  687. let self = this
  688. e.file.forEach(file => {
  689. self.$Oss.ossUpload(file.url).then(url => {
  690. self.form.fileCabList.push({
  691. url
  692. })
  693. })
  694. })
  695. },
  696. onSubmit() {
  697. console.info(this.form)
  698. // uni.navigateTo({
  699. // url:"/pages_subpack/success/index"
  700. // })
  701. this.$refs.uForm.validate().then(res => {
  702. // uni.$u.toast('校验通过')
  703. this.onAddGoods()
  704. }).catch(errors => {
  705. console.info(errors)
  706. // uni.$u.toast('校验失败')
  707. })
  708. },
  709. onAddGoods(){
  710. let that = this
  711. let params={
  712. id:that.id?that.id:null,
  713. cartypeId:that.form.cartypeId,
  714. categorytwoId:that.form.categorytwoId,
  715. goodsName:that.form.goodsName,//商品名称
  716. brand:that.form.brand,//品牌
  717. model:that.form.model,//型号
  718. area:that.form.area,//所在区域
  719. latitude:that.form.latitude,
  720. longitude:that.form.longitude,
  721. goodsTime:Number(that.form.date),//时间
  722. inventory:that.form.inventory,//库存
  723. mileage:that.form.mileage,//公里数
  724. userName:that.form.contacts,//联系人
  725. phone:that.form.phone,//联系人电话
  726. price:that.form.price,//商品价格
  727. views:that.form.views,//浏览量
  728. image:that.form.fileCarList.map(item => item.url).join(','),//商品图片
  729. imageBack:that.form.fileBackList.map(item => item.url).join(','),//车辆照片(后)
  730. imageCab:that.form.fileCabList.map(item => item.url).join(','),//车辆照片(驾驶室)
  731. imageFront:that.form.fileFrontList.map(item => item.url).join(','),//车辆照片(前)
  732. imageLeft:that.form.fileLeftList.map(item => item.url).join(','),//车辆照片(左)
  733. imageRight:that.form.fileRightList.map(item => item.url).join(','),//车辆照片(右)
  734. detail:that.form.introduce,//车辆介绍
  735. }
  736. uni.showLoading({
  737. title:"提交中..."
  738. })
  739. addGoods(params).then(response=>{
  740. console.info('response',response)
  741. uni.hideLoading()
  742. if(that.id){
  743. uni.navigateBack({
  744. delta:1
  745. })
  746. }else{
  747. uni.showToast({
  748. title: response.message,
  749. mask: false,
  750. icon: 'none',
  751. duration: 2000
  752. })
  753. setTimeout(()=>{
  754. uni.switchTab({
  755. url:"/pages/home/index"
  756. })
  757. },1500)
  758. }
  759. }).catch(error=>{
  760. })
  761. }
  762. },
  763. onReady() {
  764. this.$refs.uForm.setRules(this.rules)
  765. }
  766. }
  767. </script>
  768. <style>
  769. page {
  770. background-color: transparent;
  771. forced-color-adjust: none;
  772. }
  773. </style>