环卫车小程序前端代码
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.

799 lines
24 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
9 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
10 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
9 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
10 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:'',
  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. console.log("进图页面刷新:"+options)
  440. if(options.id){
  441. console.log("如果有数据的情况下:"+options.id)
  442. that.id = options.id
  443. that.getQueryGoodsById()
  444. }else{
  445. that.onQueryCategoryList()
  446. }
  447. // this.onQueryTypeList()
  448. // this.onQueryCategoryOneList()
  449. // this.onQueryCategoryTwoList()
  450. },
  451. watch: {
  452. // "form.categorytwoId": function (newVal, oldVal) {
  453. // if (newVal) {
  454. // this.$nextTick(() => {
  455. // this.form.categorytwoName = this.categoryTwoList
  456. // .filter((item) => item.id == newVal)
  457. // .map((item) => item.name)
  458. // .join('');
  459. // });
  460. // }
  461. // }
  462. },
  463. methods: {
  464. getQueryGoodsById(){
  465. let that = this
  466. queryGoodsById({goodsId:that.id}).then(response=>{
  467. let items = response.result;
  468. console.info("queryGoodsById",response)
  469. that.form.cartypeId=items.cartypeId
  470. that.form.categorytwoId=items.categorytwoId
  471. that.form.categorytwoName=items.categorytwoName
  472. that.form.goodsName=items.goodsName
  473. that.form.brand=items.brand
  474. that.form.model=items.model
  475. that.form.area=items.area
  476. that.form.latitude=items.latitude
  477. that.form.date=String(items.goodsTime)
  478. that.form.inventory=String(items.inventory)
  479. that.form.mileage=String(items.mileage)
  480. that.form.contacts=items.userName
  481. that.form.phone=items.phone
  482. that.form.price=String(items.price)
  483. that.form.views=String(items.views)
  484. that.form.introduce=items.detail
  485. that.form.fileCarList=items.image.split(',').map((url) => ({ url }))
  486. that.form.fileBackList=items.imageBack.split(',').map((url) => ({ url }))
  487. that.form.fileCabList=items.imageCab.split(',').map((url) => ({ url }))
  488. that.form.fileFrontList=items.imageFront.split(',').map((url) => ({ url }))
  489. that.form.fileLeftList=items.imageLeft.split(',').map((url) => ({ url }))
  490. that.form.fileRightList=items.imageRight.split(',').map((url) => ({ url }))
  491. that.onQueryCategoryList()
  492. // this.$refs.uForm.setRules(this.rules)
  493. }).catch(error=>{
  494. })
  495. },
  496. onQueryCategoryList(){
  497. let that = this
  498. queryCategoryList({}).then(response=>{
  499. console.info("queryCategoryList",response)
  500. if(response.result.length>0){
  501. that.categoryList = response.result
  502. if(!that.id){
  503. that.form.cartypeId = response.result[0].id
  504. that.form.cartypeName = response.result[0].name
  505. that.categoryTwoList = response.result[0].carrentCategorytwoList
  506. }else{
  507. that.categoryTwoList = response.result.find(item => item.id == that.form.cartypeId).carrentCategorytwoList
  508. }
  509. }
  510. }).catch(error=>{
  511. })
  512. },
  513. handleCategoryOneChange(){
  514. console.info('handleCategoryOneChange')
  515. this.categoryOneShow = true
  516. },
  517. selectCategoryOneClick(event){
  518. console.info(event)
  519. this.form.cartypeId = event.id
  520. this.form.cartypeName = event.name
  521. this.categoryOneShow = false
  522. },
  523. onQueryCategoryOneList(){
  524. let that = this
  525. let params = {}
  526. queryCategoryOneList(params).then(response=>{
  527. console.info("queryCategoryOneList",response)
  528. that.categoryOneList = response.result.records
  529. }).catch(error=>{
  530. })
  531. },
  532. handleCategoryTwoChange(){
  533. console.info('handleCategoryTwoChange')
  534. this.categoryTwoShow = true
  535. },
  536. selectCategoryTwoClick(event){
  537. console.info("selectCategoryTwoClick",event)
  538. this.form.categorytwoId = event.id
  539. this.form.categorytwoName = event.name
  540. this.categoryTwoShow = false
  541. },
  542. onQueryCategoryTwoList(){
  543. let that = this
  544. let params = {
  545. categoryoneId:"1867039853005877250"
  546. }
  547. queryCategoryTwoList(params).then(response=>{
  548. console.info("queryCategoryTwoList",response)
  549. that.categoryTwoList = response.result.records
  550. }).catch(error=>{
  551. })
  552. },
  553. onQueryTypeList(){
  554. queryTypeList({}).then(response=>{
  555. console.info("queryTypeList",response)
  556. this.actions = response.result.records
  557. this.form.typeId = response.result.records[0].id
  558. }).catch(error=>{
  559. })
  560. },
  561. onCancel(){
  562. this.showDate = false
  563. },
  564. onConfirm(e){
  565. console.info('e',e)
  566. this.form.date = e.value[0];
  567. this.showDate = false
  568. // const date = new Date(e.value);
  569. // const year = date.getFullYear();
  570. // const month = String(date.getMonth() + 1).padStart(2, '0');
  571. // const day = String(date.getDate()).padStart(2, '0');
  572. // this.form.date = `${year}-${month}-${day}`;
  573. // this.showDate = false
  574. },
  575. handleAreaChange(){
  576. const that = this;
  577. wx.chooseLocation({
  578. // type: 'wgs84',
  579. success: function (res) {
  580. const qqmapsdk = new QQMapWX({
  581. key: 'TT7BZ-Z3LW4-KOAUB-KWHOA-SBJJ6-Y5B6R' // 必填
  582. });
  583. uni.showLoading({
  584. title:"获取中...."
  585. })
  586. qqmapsdk.reverseGeocoder({
  587. location: {
  588. latitude: res.latitude,
  589. longitude: res.longitude
  590. },
  591. success: function(response) {
  592. console.log('逆地理编码结果:', response);
  593. uni.hideLoading()
  594. that.form.longitude = response.result.location.lng
  595. that.form.latitude = response.result.location.lat
  596. that.form.area = response.result.address
  597. },
  598. fail: function(error) {
  599. uni.hideLoading()
  600. console.error('逆地理编码失败:', error);
  601. }
  602. });
  603. }
  604. })
  605. // this.$refs.citySelectRef.open()
  606. },
  607. handleCartype(event){
  608. this.form.cartypeId = event.id
  609. this.form.cartypeName = event.name
  610. this.categoryTwoList =event.carrentCategorytwoList
  611. this.form.categorytwoId = ""
  612. this.form.categorytwoName = ""
  613. },
  614. // 照片
  615. delCarFront(event) {
  616. this.form.fileCarList.splice(event.index, 1)
  617. },
  618. async afterCarFront(e) {
  619. let self = this
  620. e.file.forEach(file => {
  621. self.$Oss.ossUpload(file.url).then(url => {
  622. self.form.fileCarList.push({
  623. url
  624. })
  625. })
  626. })
  627. },
  628. // 前
  629. delFront(event) {
  630. this.form.fileFrontList.splice(event.index, 1)
  631. },
  632. async afterFront(e) {
  633. let self = this
  634. e.file.forEach(file => {
  635. self.$Oss.ossUpload(file.url).then(url => {
  636. self.form.fileFrontList.push({
  637. url
  638. })
  639. })
  640. })
  641. },
  642. // 后
  643. delBack(event) {
  644. this.form.fileBackList.splice(event.index, 1)
  645. },
  646. async afterBack(e) {
  647. let self = this
  648. e.file.forEach(file => {
  649. self.$Oss.ossUpload(file.url).then(url => {
  650. self.form.fileBackList.push({
  651. url
  652. })
  653. })
  654. })
  655. },
  656. // 左
  657. delLeft(event) {
  658. this.form.fileLeftList.splice(event.index, 1)
  659. },
  660. async afterLeft(e) {
  661. let self = this
  662. e.file.forEach(file => {
  663. self.$Oss.ossUpload(file.url).then(url => {
  664. self.form.fileLeftList.push({
  665. url
  666. })
  667. })
  668. })
  669. },
  670. // 左
  671. delRight(event) {
  672. this.form.fileRightList.splice(event.index, 1)
  673. },
  674. async afterRight(e) {
  675. let self = this
  676. e.file.forEach(file => {
  677. self.$Oss.ossUpload(file.url).then(url => {
  678. self.form.fileRightList.push({
  679. url
  680. })
  681. })
  682. })
  683. },
  684. // 车辆照片(驾驶室)
  685. delCab(event) {
  686. this.form.fileCabList.splice(event.index, 1)
  687. },
  688. async afterCab(e) {
  689. let self = this
  690. e.file.forEach(file => {
  691. self.$Oss.ossUpload(file.url).then(url => {
  692. self.form.fileCabList.push({
  693. url
  694. })
  695. })
  696. })
  697. },
  698. onSubmit() {
  699. console.info(this.form)
  700. // uni.navigateTo({
  701. // url:"/pages_subpack/success/index"
  702. // })
  703. this.$refs.uForm.validate().then(res => {
  704. // uni.$u.toast('校验通过')
  705. this.onAddGoods()
  706. }).catch(errors => {
  707. console.info(errors)
  708. // uni.$u.toast('校验失败')
  709. })
  710. },
  711. onAddGoods(){
  712. let that = this
  713. console.log("新增或者修改现在标识:"+that.id)
  714. let params={
  715. id:that.id?that.id:'',
  716. cartypeId:that.form.cartypeId,
  717. categorytwoId:that.form.categorytwoId,
  718. goodsName:that.form.goodsName,//商品名称
  719. brand:that.form.brand,//品牌
  720. model:that.form.model,//型号
  721. area:that.form.area,//所在区域
  722. latitude:that.form.latitude,
  723. longitude:that.form.longitude,
  724. goodsTime:Number(that.form.date),//时间
  725. inventory:that.form.inventory,//库存
  726. mileage:that.form.mileage,//公里数
  727. userName:that.form.contacts,//联系人
  728. phone:that.form.phone,//联系人电话
  729. price:that.form.price,//商品价格
  730. views:that.form.views,//浏览量
  731. image:that.form.fileCarList.map(item => item.url).join(','),//商品图片
  732. imageBack:that.form.fileBackList.map(item => item.url).join(','),//车辆照片(后)
  733. imageCab:that.form.fileCabList.map(item => item.url).join(','),//车辆照片(驾驶室)
  734. imageFront:that.form.fileFrontList.map(item => item.url).join(','),//车辆照片(前)
  735. imageLeft:that.form.fileLeftList.map(item => item.url).join(','),//车辆照片(左)
  736. imageRight:that.form.fileRightList.map(item => item.url).join(','),//车辆照片(右)
  737. detail:that.form.introduce,//车辆介绍
  738. }
  739. if(that.id == null){
  740. }
  741. uni.showLoading({
  742. title:"提交中..."
  743. })
  744. addGoods(params).then(response=>{
  745. console.info('response',response)
  746. uni.hideLoading()
  747. if(that.id){
  748. uni.navigateBack({
  749. delta:1
  750. })
  751. }else{
  752. uni.showToast({
  753. title: response.message,
  754. mask: false,
  755. icon: 'none',
  756. duration: 2000
  757. })
  758. setTimeout(()=>{
  759. uni.switchTab({
  760. url:"/pages/home/index"
  761. })
  762. },1500)
  763. }
  764. }).catch(error=>{
  765. })
  766. }
  767. },
  768. onReady() {
  769. this.$refs.uForm.setRules(this.rules)
  770. }
  771. }
  772. </script>
  773. <style>
  774. page {
  775. background-color: transparent;
  776. forced-color-adjust: none;
  777. }
  778. </style>