firm.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. <template>
  2. <view class="padding">
  3. <view class="text-white padding bg radius">
  4. <u-form :model="form" ref="uForm" label-position="top" :label-style='lableStyle'>
  5. <u-form-item label="标题">
  6. <u-input v-model="form.myLevel" placeholder="请填写标题内容" />
  7. </u-form-item>
  8. <u-form-item label="服务地区">
  9. <u-input v-model="form.region" :disabled="true" placeholder="请填写" @click="bindOpen()" />
  10. </u-form-item>
  11. <u-form-item label="技能">
  12. <!-- <u-input v-model="form.game" disabled placeholder="可商议" @click="show = true" /> -->
  13. <view v-if="game == ''" @click="openJn(game)">
  14. 选择技能分类(多选)
  15. </view>
  16. <view v-else style="display: inline-flex;">
  17. <view v-for="(item,index) in game" @click="openJn(game)"
  18. style="background: #557EFD;margin-right: 15rpx;color: #FFFFFF;padding: 0rpx 15rpx;border-radius: 15rpx;">
  19. {{item.gameName?item.gameName:item}}
  20. </view>
  21. </view>
  22. </u-form-item>
  23. <u-form-item label="期望薪资">
  24. <u-input v-model="form.money" type="number" placeholder="请填写(必填)" />
  25. </u-form-item>
  26. </u-form>
  27. </view>
  28. <view class="text-white padding bg radius margin-tb">
  29. <view>
  30. <view class="text-lg">特长描述</view>
  31. <view class="margin-tb-sm">
  32. <u-input v-model="form.describes" type="textarea" height="200" placeholde="请描述一下您的特长" maxlengt="200"
  33. :clearable="false" />
  34. </view>
  35. </view>
  36. <view>
  37. <view class="text-lg margin-top-sm">主页图上传</view>
  38. <view class="flex" style="overflow: hidden;flex-wrap: wrap;">
  39. <view v-if="headImg.length">
  40. <view class="margin-top flex margin-right-sm flex-wrap">
  41. <view class="flex"
  42. style="width: 200rpx;height: 200rpx;margin-right: 10rpx;position: relative;"
  43. v-for="(image,index) in headImg" :key="index">
  44. <image :src="image" style="width: 100%;height: 100%;" @click="previewImg(index)">
  45. </image>
  46. <view style="z-index: 9;position: absolute;top: -15rpx;right: -15rpx;"
  47. @click="headImgremove(index)">
  48. <u-icon name="close-circle-fill" color="#2979ff" size="50rpx"></u-icon>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="margin-top" @click="addImage(2)" v-if="headImg.length<=0">
  54. <view style="width: 200rpx;height: 200rpx;background: #f4f5f6;"
  55. class="flex justify-center align-center">
  56. <view>
  57. <view class="text-center">
  58. <image src="../../static/images/my/add.png" style="width: 65rpx;height: 55rpx;">
  59. </image>
  60. </view>
  61. <view class="text-center">添加图片</view>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. <view>
  68. <view class="text-lg margin-top">服务详情图(最多6张)</view>
  69. <view class="flex" style="overflow: hidden;flex-wrap: wrap;">
  70. <view v-if="detailsImg.length">
  71. <view class="margin-top flex margin-right-sm flex-wrap">
  72. <view class="flex"
  73. style="width: 200rpx;height: 200rpx;margin-right: 5rpx;position: relative;"
  74. v-for="(image,index) in detailsImg" :key="index">
  75. <image :src="image" style="width: 100%;height: 100%;" @click="previewImgs(index)">
  76. </image>
  77. <view style="z-index: 9;position: absolute;top: -15rpx;right: -15rpx;"
  78. @click="removeImg(index)">
  79. <u-icon name="close-circle-fill" color="#2979ff" size="50rpx"></u-icon>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. <view class="margin-top" @click="addImages(1)" v-if="detailsImg.length<=5">
  85. <view style="width: 200rpx;height: 200rpx;background: #f4f5f6;"
  86. class="flex justify-center align-center">
  87. <view>
  88. <view class="text-center">
  89. <image src="../../static/images/my/add.png" style="width: 65rpx;height: 55rpx;">
  90. </image>
  91. </view>
  92. <view class="text-center">选择图片</view>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. <!-- 地区选择 -->
  100. <u-picker v-model="Dqshow" mode="region" @confirm="bindRegion"></u-picker>
  101. <u-popup v-model="show" mode="bottom" border-radius="14" :closeable="true">
  102. <view class="fl_pop">
  103. <view class="flex flex-wrap" style="padding: 100rpx 60rpx;margin-bottom: 50rpx;">
  104. <view v-for="(item,index) in gameList" :key="index" class="flex margin-right-sm"
  105. @click="bindList(index,item)">
  106. <text class="tabBox margin-top-xs"
  107. :class="item.ischeck==true?'btnnum':''">{{item.gameName}}</text>
  108. </view>
  109. <u-button @click="bindGame()" :custom-style="customStyle1">确定</u-button>
  110. </view>
  111. </view>
  112. </u-popup>
  113. <u-button v-if="id" @click="update" class="margin-top" :custom-style="customStyle" shape="square"
  114. :hair-line="false">提交发布</u-button>
  115. <u-button v-else @click="submit" class="margin-top" :custom-style="customStyle" shape="square"
  116. :hair-line="false">提交发布</u-button>
  117. <!-- <u-action-sheet :list="actionSheetList" v-model="actionSheetShow" @click="actionSheetCallback"></u-action-sheet> -->
  118. </view>
  119. </template>
  120. <script>
  121. import configdata from '@/common/config.js';
  122. import jsfunRecord from '../components/jc-record/jc-record.vue'
  123. export default {
  124. components: {
  125. jsfunRecord
  126. },
  127. data() {
  128. return {
  129. form: {
  130. authentication: 2,
  131. game: '',
  132. gameId: '',
  133. money: '',
  134. //服务详情图
  135. detailsImg: [],
  136. city: '',
  137. id: 0,
  138. myLevel: '',
  139. //地区
  140. region: '',
  141. describes: '',
  142. headImg: ''
  143. },
  144. disabled: false,
  145. jiedanList: [{
  146. name: '小时',
  147. checked: true,
  148. disabled: 1
  149. }, {
  150. name: '天',
  151. checked: false,
  152. disabled: 2
  153. }],
  154. lableStyle: {
  155. // color: '#FFFFFF',
  156. fontSize: '32rpx'
  157. },
  158. customStyle: {
  159. backgroundColor: '#005DFF',
  160. color: '#FFFFFF',
  161. border: 0
  162. },
  163. status: 1,
  164. customStyle1: {
  165. color: '#FFFFFF',
  166. position: "fixed",
  167. bottom: "15rpx",
  168. left: "0rpx",
  169. right: "0rpx",
  170. margin: "0rpx 50rpx",
  171. backgroundColor: '#005DFF',
  172. },
  173. gameList: [],
  174. listgame: '',
  175. selarr: [],
  176. show: false,
  177. game: '',
  178. checked: false,
  179. disabled: false,
  180. number: 0,
  181. homepageImg: '',
  182. id: '',
  183. Imgo: [],
  184. //地区选择
  185. Dqshow: false,
  186. //详情图上传
  187. detailsImg: [],
  188. headImg: [],
  189. region: ''
  190. }
  191. },
  192. onLoad(option) {
  193. this.id = option.id
  194. this.form.id = option.id
  195. this.form.city = uni.getStorageSync('city')
  196. this.form.latitude = uni.getStorageSync('latitude')
  197. this.form.longitude = uni.getStorageSync('longitude')
  198. this.getData(this.id)
  199. this.getGameList()
  200. },
  201. onShow() {
  202. },
  203. methods: {
  204. // 技能列表
  205. bindList(index, item) {
  206. console.log(index)
  207. if (this.selarr.length > 1 && item.ischeck == false) {
  208. uni.showToast({
  209. title: '最多选择2个技能',
  210. icon: 'none'
  211. })
  212. return
  213. }
  214. if (item.ischeck == false) {
  215. item.ischeck = true;
  216. this.selarr.push(item)
  217. } else {
  218. item.ischeck = false;
  219. let index11 = this.selarr.indexOf(index)
  220. this.selarr.splice(index11, 1)
  221. }
  222. this.selarr = this.selarr;
  223. },
  224. //地区选择
  225. bindOpen() {
  226. this.Dqshow = true
  227. },
  228. bindRegion(e) {
  229. console.log(e)
  230. this.region = e.province.label + e.city.label + e.area.label
  231. this.form.region = e.province.label + ',' + e.city.label + ',' + e.area.label
  232. },
  233. // 详情图删除
  234. removeImg(index) {
  235. this.detailsImg.splice(index, 1)
  236. },
  237. // 预览照片
  238. previewImgs(index) {
  239. let _this = this;
  240. uni.previewImage({
  241. current: index,
  242. urls: _this.detailsImg
  243. });
  244. },
  245. // 详情图删除
  246. headImgremove(index) {
  247. this.headImg.splice(index, 1)
  248. },
  249. // 预览照片
  250. previewImg(index) {
  251. let _this = this;
  252. uni.previewImage({
  253. current: index,
  254. urls: _this.headImg
  255. });
  256. },
  257. openJn(item) {
  258. console.log(item)
  259. this.show = true
  260. // item.ischeck = true
  261. },
  262. // 选中提交
  263. bindGame() {
  264. this.game = this.selarr
  265. console.log(this.form.game, '5555555')
  266. let gameId = "";
  267. for (var game in this.selarr) {
  268. gameId = gameId + "," + this.selarr[game].gameName
  269. }
  270. gameId = gameId.substring(1, gameId.length);
  271. this.form.gameId = gameId
  272. this.show = false
  273. },
  274. jiedanChange(e) {
  275. this.form.unit = e;
  276. },
  277. select(e) {
  278. this.status = e
  279. },
  280. endChange(e) {
  281. if (this.startHour >= e.hour) {
  282. uni.showToast({
  283. title: '结束时间必须大于开始时间一个小时以上',
  284. icon: "none"
  285. })
  286. return
  287. }
  288. this.endTime = e.hour + ':' + e.minute
  289. this.form.orderTakingTime = this.startTime + '~' + this.endTime
  290. },
  291. // 图片上传
  292. addImages(e) {
  293. let that = this
  294. uni.chooseImage({
  295. count: 6,
  296. sourceType: ['album', 'camera'],
  297. success: res => {
  298. for (let i = 0; i < res.tempFilePaths.length; i++) {
  299. that.$queue.showLoading("上传中...");
  300. uni.uploadFile({ // 上传接口
  301. url: that.config("APIHOST1") + '/alioss/upload', //真实的接口地址
  302. filePath: res.tempFilePaths[i],
  303. name: 'file',
  304. success: (uploadFileRes) => {
  305. if (e == 1) {
  306. // that.form.homepageImg = JSON.parse(uploadFileRes.data).data
  307. if (that.detailsImg.length <= 6) {
  308. that.detailsImg.push(JSON.parse(uploadFileRes.data)
  309. .data)
  310. }
  311. // that.detailsImg.push(JSON.parse(uploadFileRes.data).data)
  312. } else if (e == 2) {
  313. // that.headImg.push(JSON.parse(uploadFileRes.data).data)
  314. that.headImg.push(JSON.parse(uploadFileRes.data).data)
  315. }
  316. uni.hideLoading();
  317. }
  318. });
  319. }
  320. }
  321. })
  322. },
  323. addImage(e) {
  324. let that = this
  325. uni.chooseImage({
  326. count:1,
  327. sourceType: ['album', 'camera'],
  328. success: res => {
  329. for (let i = 0; i < 1; i++) {
  330. that.$queue.showLoading("上传中...");
  331. uni.uploadFile({ // 上传接口
  332. url: that.config("APIHOST1") + '/alioss/upload', //真实的接口地址
  333. filePath: res.tempFilePaths[i],
  334. name: 'file',
  335. success: (uploadFileRes) => {
  336. if (e == 2) {
  337. // that.form.homepageImg = JSON.parse(uploadFileRes.data).data
  338. that.headImg.push(JSON.parse(uploadFileRes.data).data)
  339. }
  340. uni.hideLoading();
  341. }
  342. });
  343. }
  344. }
  345. })
  346. },
  347. config: function(name) {
  348. var info = null;
  349. if (name) {
  350. var name2 = name.split("."); //字符分割
  351. if (name2.length > 1) {
  352. info = configdata[name2[0]][name2[1]] || null;
  353. } else {
  354. info = configdata[name] || null;
  355. }
  356. if (info == null) {
  357. let web_config = cache.get("web_config");
  358. if (web_config) {
  359. if (name2.length > 1) {
  360. info = web_config[name2[0]][name2[1]] || null;
  361. } else {
  362. info = web_config[name] || null;
  363. }
  364. }
  365. }
  366. }
  367. return info;
  368. },
  369. // 发布
  370. submit() {
  371. this.form.detailsImg = this.detailsImg
  372. this.form.detailsImg = this.form.detailsImg.toString();
  373. this.form.headImg = this.headImg
  374. this.form.headImg = this.form.headImg.toString();
  375. if (!this.form.myLevel) {
  376. uni.showToast({
  377. title: '请填写发布标题',
  378. icon: 'none',
  379. duration: 1000
  380. })
  381. return
  382. }
  383. // if (!this.form.region) {
  384. // uni.showToast({
  385. // title: '请选择服务地区',
  386. // icon: 'none',
  387. // duration: 1000
  388. // })
  389. // return
  390. // }
  391. if (this.game == '') {
  392. uni.showToast({
  393. title: '请选择技能',
  394. icon: 'none',
  395. duration: 1000
  396. })
  397. return
  398. }
  399. if (!this.form.money) {
  400. uni.showToast({
  401. title: '请填写期望薪资',
  402. icon: 'none',
  403. duration: 1000
  404. })
  405. return
  406. }
  407. if (!this.form.describes) {
  408. uni.showToast({
  409. title: '请填写特长描述',
  410. icon: 'none',
  411. duration: 1000
  412. })
  413. return
  414. }
  415. if (!this.form.headImg) {
  416. uni.showToast({
  417. title: '请上传主页图',
  418. icon: 'none',
  419. duration: 1000
  420. })
  421. return
  422. }
  423. if (!this.form.detailsImg) {
  424. uni.showToast({
  425. title: '请上传服务详情图',
  426. icon: 'none',
  427. duration: 1000
  428. })
  429. return
  430. }
  431. console.log(this.form)
  432. this.form.id = ''
  433. this.$Request.get("/app/orderTaking/insertOrderTaking", this.form).then(res => {
  434. if (res.code == 0) {
  435. uni.showToast({
  436. title: res.msg,
  437. icon: 'none'
  438. })
  439. setTimeout(function() {
  440. // uni.navigateBack()
  441. uni.navigateTo({
  442. url: '/my/publish/index'
  443. })
  444. }, 1000)
  445. } else {
  446. uni.showToast({
  447. title: res.msg,
  448. icon: 'none'
  449. })
  450. }
  451. });
  452. },
  453. // 重新编辑
  454. update() {
  455. this.form.detailsImg = this.detailsImg
  456. this.form.detailsImg = this.form.detailsImg.toString();
  457. this.form.headImg = this.headImg
  458. this.form.headImg = this.form.headImg.toString();
  459. if (!this.form.myLevel) {
  460. uni.showToast({
  461. title: '请填写发布标题',
  462. icon: 'none',
  463. duration: 1000
  464. })
  465. return
  466. }
  467. // if (!this.form.region) {
  468. // uni.showToast({
  469. // title: '请选择服务地区',
  470. // icon: 'none',
  471. // duration: 1000
  472. // })
  473. // return
  474. // }
  475. if (this.game == '') {
  476. uni.showToast({
  477. title: '请选择技能',
  478. icon: 'none',
  479. duration: 1000
  480. })
  481. return
  482. }
  483. if (!this.form.money) {
  484. uni.showToast({
  485. title: '请填写期望薪资',
  486. icon: 'none',
  487. duration: 1000
  488. })
  489. return
  490. }
  491. if (!this.form.describes) {
  492. uni.showToast({
  493. title: '请填写特长描述',
  494. icon: 'none',
  495. duration: 1000
  496. })
  497. return
  498. }
  499. if (!this.form.headImg) {
  500. uni.showToast({
  501. title: '请上传主页图',
  502. icon: 'none',
  503. duration: 1000
  504. })
  505. return
  506. }
  507. if (!this.form.detailsImg) {
  508. uni.showToast({
  509. title: '请上传服务详情图',
  510. icon: 'none',
  511. duration: 1000
  512. })
  513. return
  514. }
  515. this.$Request.get("/app/orderTaking/updateTakingOrder", this.form).then(res => {
  516. if (res.code == 0) {
  517. uni.showToast({
  518. title: '编辑成功',
  519. icon: 'none'
  520. })
  521. setTimeout(function() {
  522. // uni.navigateBack()
  523. uni.navigateTo({
  524. url: '/my/publish/index'
  525. })
  526. }, 1000)
  527. }
  528. });
  529. },
  530. // 获取游戏列表
  531. getGameList() {
  532. this.$Request.get("/app/appGame/queryGameName").then(res => {
  533. if (res.code == 0) {
  534. res.data.forEach(res => {
  535. res.label = res.gameName
  536. res.value = res.id
  537. res.ischeck = false
  538. })
  539. if (this.id) {
  540. for (var i = 0; i < res.data.length; i++) {
  541. for (var a = 0; a < this.game.length; a++) {
  542. if (res.data[i].gameName == this.game[a]) {
  543. res.data[i].ischeck = true
  544. }
  545. }
  546. }
  547. }
  548. this.gameList = res.data
  549. console.log(this.gameList)
  550. }
  551. });
  552. },
  553. // 选择游戏
  554. selConfirm(e) {
  555. // console.log(e);
  556. this.form.game = e[0].label
  557. this.form.gameId = e[0].value
  558. },
  559. getData(e) {
  560. let data = {
  561. id: e
  562. }
  563. this.$Request.get("/app/orderTaking/queryTakingOrder", data).then(res => {
  564. if (res.code == 0 && res.data) {
  565. this.game = res.data.gameId.split(',')
  566. this.form.gameId = res.data.gameId
  567. this.form.myLevel = res.data.myLevel
  568. this.form.region = res.data.region
  569. this.form.money = res.data.oldMoney
  570. this.form.describes = res.data.describes
  571. this.form.detailsImg = res.data.detailsImg
  572. this.detailsImg = res.data.detailsImg.split(',')
  573. this.form.headImg = res.data.headImg ? res.data.headImg : ''
  574. this.headImg = res.data.headImg.split(',')
  575. }
  576. });
  577. },
  578. }
  579. }
  580. </script>
  581. <style>
  582. page {
  583. background-color: #F5F5F5;
  584. }
  585. .bg {
  586. background-color: #FFFFFF;
  587. }
  588. .tabBox {
  589. border: 1rpx solid #999999;
  590. padding: 15rpx 20rpx;
  591. border-radius: 15rpx;
  592. font-size: 28rpx;
  593. }
  594. .btnnum {
  595. color: #005DFF;
  596. border: 1rpx solid #005DFF;
  597. }
  598. </style>