demand.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. <template>
  2. <view class="content">
  3. <view class="tabs hflex acenter jcenter">
  4. <view class="tab_item" :class="tab_active == 0?'tab_active':''" @click="changeTabs(0)">采购接单需求</view>
  5. <view class="tab_item" :class="tab_active == 1?'tab_active':''" @click="changeTabs(1)">船机修理接单需求</view>
  6. </view>
  7. <block v-if="tab_active == 0 && is_write1 == 0">
  8. <view class="vflex acenter jcenter">
  9. <view class="img_box vflex acenter jcenter">
  10. <u-icon name="info-circle-fill" color="#506dff" size="50"></u-icon>
  11. <view class="text">还未发布采购需求信息</view>
  12. </view>
  13. <view class="release" @click="release(1)">立即发布</view>
  14. </view>
  15. </block>
  16. <block v-if="tab_active == 1 && is_write2 == 0">
  17. <view class="vflex acenter jcenter">
  18. <view class="img_box vflex acenter jcenter">
  19. <u-icon name="info-circle-fill" color="#506dff" size="50"></u-icon>
  20. <view class="text">还未提交需求信息</view>
  21. </view>
  22. <view class="release" @click="release(2)">立即发布</view>
  23. </view>
  24. </block>
  25. <block v-if="tab_active == 0 && is_write1 == 1">
  26. <view class="box">
  27. <view class="box1">
  28. <view class="title requied">需求说明</view>
  29. <u--textarea v-model="purchase.description" placeholder="请详细描述你的采购需求" border="none"></u--textarea>
  30. <view class="title requied">上传营业执照或者身份证件照</view>
  31. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple :maxCount="1" width="200rpx" height="200rpx">
  32. <image src="@/static/images/index/upload_img.png" mode="" style="width: 200rpx;height: 200rpx"></image>
  33. </u-upload>
  34. </view>
  35. <view class="box1">
  36. <view class="title requied">上传图片以及资质证件照片</view>
  37. <u-upload :fileList="fileList2" @afterRead="afterRead" @delete="deletePic" name="2" multiple :maxCount="9" width="200rpx" height="200rpx">
  38. <image src="@/static/images/index/upload_img.png" mode="" style="width: 200rpx;height: 200rpx"></image>
  39. </u-upload>
  40. </view>
  41. <view class="box1" style="margin-bottom: 186rpx;padding: 0 20rpx;">
  42. <view class="hflex acenter jbetween">
  43. <view class="title requied">是否隐藏需求</view>
  44. <u-switch v-model="purchase.hidden" inactiveColor="rgb(230, 230, 230)" @change="changeHide1"></u-switch>
  45. </view>
  46. <view class="text">
  47. 说明:灰色开关为显示需求,蓝色开关为隐藏需求,默认为显示需求
  48. </view>
  49. </view>
  50. </view>
  51. <view class="bottom">
  52. <view class="btn" v-if="purchase.id !== ''" @click="publish">立即发布</view>
  53. <view class="btn" v-else @click="publish">立即修改</view>
  54. </view>
  55. </block>
  56. <block v-if="tab_active == 1 && is_write2 == 1">
  57. <view class="box">
  58. <view class="box1">
  59. <view class="hflex acenter jbetween cell">
  60. <view class="label requied">姓名</view>
  61. <u-input v-model="repair.name" placeholder="请填写姓名" inputAlign="right" border="none"></u-input>
  62. </view>
  63. <view class="hflex acenter jbetween cell">
  64. <view class="label requied">所在单位</view>
  65. <u-input v-model="repair.company_name" placeholder="请填写所在单位名称" inputAlign="right" border="none"></u-input>
  66. </view>
  67. <view class="cell">
  68. <view class="label requied">营业执照照片</view>
  69. <view class="upload hflex acenter jcenter">
  70. <u-upload :fileList="fileList3" @afterRead="afterRead" @delete="deletePic" :maxCount="1" name="3" multiple :previewFullImage="true" width="530rpx" height="324rpx">
  71. <image src="https://ship.shipcc.cn/common/upload-business.png" style="width: 530rpx;height: 324rpx;"></image>
  72. <image class="upload_img" src="https://ship.shipcc.cn/common/upload-top.png"></image>
  73. </u-upload>
  74. </view>
  75. </view>
  76. <view class="cell" style="border: none;">
  77. <view class="label requied">身份证正反面</view>
  78. <view class="hflex acenter jbetween" style="margin-top: 28rpx;">
  79. <u-upload :fileList="fileList4" @afterRead="afterRead" @delete="deletePic" :maxCount="1" name="4" multiple :previewFullImage="true" width="310rpx" height="188rpx">
  80. <!-- <image src="https://ship.shipcc.cn/common/upload-just.png" style="width: 310rpx;height: 188rpx;"></image> -->
  81. <view class="" style="position: relative;">
  82. <image src="@/static/images/index/upload-back.png" style="width: 310rpx;height: 188rpx;"></image>
  83. <image src="@/static/images/mine/upload_center.png" style="position: absolute;top:40rpx;left: 116rpx; width: 80rpx;height: 80rpx;"></image>
  84. <view style="position: absolute;bottom: 16rpx;left: 70rpx;font-size: 16rpx;color: #506DFF;">上传身份证人像面照片</view>
  85. </view>
  86. </u-upload>
  87. <view class="upload2">
  88. <u-upload :fileList="fileList5" @afterRead="afterRead" @delete="deletePic" :maxCount="1" name="5" multiple :previewFullImage="true" width="310rpx" height="188rpx">
  89. <!-- <image src="https://ship.shipcc.cn/common/upload-back.png" style="width: 310rpx;height: 188rpx;"></image>
  90. <image class="upload_img2" src="https://ship.shipcc.cn/common/upload-top.png"></image> -->
  91. <view class="" style="position: relative;">
  92. <image src="https://ship.shipcc.cn/common/upload-back.png" style="width: 310rpx;height: 188rpx;"></image>
  93. <image src="@/static/images/mine/upload_center.png" style="position: absolute;top:40rpx;left: 116rpx; width: 80rpx;height: 80rpx;"></image>
  94. <view style="position: absolute;bottom: 16rpx;left: 70rpx;font-size: 16rpx;color: #506DFF;">上传身份证国徽面图片</view>
  95. </view>
  96. </u-upload>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. <view class="box1" style="padding: 0 20rpx;">
  102. <view class="hflex acenter jbetween cell">
  103. <view class="label requied">手机号</view>
  104. <u-input v-model="repair.phone" placeholder="请填写你的手机号" inputAlign="right" border="none"></u-input>
  105. </view>
  106. <view class="hflex acenter jbetween cell">
  107. <view class="label requied">邮箱</view>
  108. <u-input v-model="repair.email" placeholder="请填写你的邮箱" inputAlign="right" border="none"></u-input>
  109. </view>
  110. <view class="hflex acenter jbetween cell" style="border: none;">
  111. <view class="label requied">地址</view>
  112. <u-input v-model="repair.address" placeholder="请填写你的详细地址" inputAlign="right" border="none"></u-input>
  113. </view>
  114. </view>
  115. <view class="box1">
  116. <view class="cell vflex jbetween">
  117. <view class="label">工作简历</view>
  118. <u-input v-model="repair.job_resume" placeholder="请详细描述你的工作经历" border="none"></u-input>
  119. </view>
  120. <view class="cell vflex jbetween" style="border: none;">
  121. <view class="label">特长</view>
  122. <u-input v-model="repair.specialty" placeholder="请简单叙述一下你的优点及特长" border="none"></u-input>
  123. </view>
  124. </view>
  125. <view class="box1" style="margin-bottom: 186rpx;padding: 0 20rpx;">
  126. <view class="hflex acenter jbetween">
  127. <view class="title">是否隐藏需求</view>
  128. <u-switch v-model="repair.hidden" inactiveColor="rgb(230, 230, 230)" @change="changeHide2"></u-switch>
  129. </view>
  130. <view class="text">
  131. 说明:灰色开关为显示需求,蓝色开关为隐藏需求,默认为显示需求
  132. </view>
  133. </view>
  134. </view>
  135. <view class="bottom">
  136. <view class="btn" v-if="JSON.stringify(repair) == '{}'" @click="submit">立即发布</view>
  137. <view class="btn" v-else @click="submit">立即修改</view>
  138. </view>
  139. </block>
  140. <u-modal :show="show_tips" :closeOnClickOverlay="true" :showConfirmButton="false">
  141. <view class="popup1">
  142. <image src="https://ship.shipcc.cn/common/small-bell.png" class="popup_img"></image>
  143. <view class="popup1_title">温馨提示</view>
  144. <view class="popup1_text">您还不是维修工,不能参与报价,可立即申请成为维修工</view>
  145. <view class="popup1_btn" @click="toApply">立即申请</view>
  146. <view class="popup1_text" style="margin: 36rpx 0 0;" @click="close">暂不</view>
  147. </view>
  148. </u-modal>
  149. </view>
  150. </template>
  151. <script>
  152. import $api from '@/static/js/api.js'
  153. var that = ''
  154. export default {
  155. data() {
  156. return {
  157. tab_active: 0,
  158. is_write1: 0,
  159. is_write2: 0,
  160. purchase: {
  161. description: '',
  162. hidden: false
  163. },
  164. repair: {},
  165. fileList1: [],
  166. fileList2: [],
  167. fileList3: [],
  168. fileList4: [],
  169. fileList5: [],
  170. show_tips: false
  171. }
  172. },
  173. onLoad() {
  174. that = this
  175. that.getData()
  176. console.log(that.re);
  177. },
  178. methods: {
  179. getData() {
  180. $api.req({
  181. url: '/data/api.auth.Center/myneed',
  182. method: 'POST',
  183. data: {
  184. type: that.tab_active + 1
  185. }
  186. }, function(res) {
  187. if(res.code == 1) {
  188. console.log(!res.data);
  189. if(!res.data &&that.tab_active == 0) {
  190. that.is_write1 = 0
  191. }
  192. if(res.data &&that.tab_active == 0) {
  193. that.is_write1 = 1
  194. that.purchase = res.data
  195. if(res.data.hidden == 2) {
  196. that.purchase.hidden = true
  197. } else {
  198. that.purchase.hidden = false
  199. }
  200. that.fileList1 = []
  201. that.fileList1.push({
  202. url:res.data.business_img
  203. })
  204. var imgs = res.data.imgs
  205. let obj = {}
  206. for(let key in imgs) {
  207. obj[key] = imgs[key]
  208. }
  209. var fileList2 = Object.keys(obj).map(item => ({
  210. url: obj[item]
  211. }))
  212. that.fileList2 = fileList2
  213. }
  214. if(!res.data &&that.tab_active == 1) {
  215. that.is_write2 = 0
  216. }
  217. if(res.data &&that.tab_active == 1) {
  218. that.is_write2 = 1
  219. that.repair = res.data
  220. if(res.data.hidden == 2) {
  221. that.repair.hidden = true
  222. } else {
  223. that.repair.hidden = false
  224. }
  225. that.fileList3 = []
  226. that.fileList3.push({
  227. url:res.data.business_img
  228. })
  229. that.fileList4 = []
  230. that.fileList4.push({
  231. url:res.data.id_card_zheng
  232. })
  233. that.fileList5 = []
  234. that.fileList5.push({
  235. url:res.data.id_card_fan
  236. })
  237. }
  238. }
  239. })
  240. },
  241. // 切换tabs
  242. changeTabs(index) {
  243. console.log(index);
  244. that.tab_active = index
  245. that.getData()
  246. },
  247. // 立即发布
  248. release(index) {
  249. if(index == 1) {
  250. that.is_write1 = 1
  251. that.purchase.description = ''
  252. } else {
  253. console.log('是否是维修工',uni.getStorageSync('maintenance'));
  254. if(uni.getStorageSync('maintenance')) {
  255. that.is_write2 = 1
  256. } else {
  257. that.show_tips = true
  258. }
  259. }
  260. },
  261. // 删除图片
  262. deletePic(event) {
  263. this[`fileList${event.name}`].splice(event.index, 1)
  264. },
  265. // 新增图片
  266. async afterRead(event) {
  267. uni.showLoading({
  268. title: '上传中',
  269. mask: true
  270. })
  271. let lists = [].concat(event.file)
  272. let fileListLen = this[`fileList${event.name}`].length
  273. lists.map((item) => {
  274. this[`fileList${event.name}`].push({
  275. ...item,
  276. status: 'uploading',
  277. message: '上传中'
  278. })
  279. })
  280. for (let i = 0; i < lists.length; i++) {
  281. const result = await this.uploadFilePromise(lists[i].url)
  282. let item = this[`fileList${event.name}`][fileListLen]
  283. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  284. status: 'success',
  285. message: '',
  286. url: result.url
  287. }))
  288. fileListLen++
  289. if(lists.length - 1 == i) {
  290. uni.hideLoading()
  291. }
  292. }
  293. },
  294. uploadFilePromise(url) {
  295. return new Promise((resolve, reject) => {
  296. let a = uni.uploadFile({
  297. url: $api.config.baseUrl + '/data/api.auth.Center/upload',
  298. filePath: url,
  299. name: 'file',
  300. header: {
  301. 'content-type': 'application/x-www-form-urlencoded',
  302. 'api-token': uni.getStorageSync('token').token?uni.getStorageSync('token').token:'',
  303. 'api-name': 'wxapp'
  304. },
  305. formData: {
  306. user: 'test'
  307. },
  308. success: (res) => {
  309. setTimeout(() => {
  310. var data = JSON.parse(res.data)
  311. resolve(data.data)
  312. }, 1000)
  313. }
  314. });
  315. })
  316. },
  317. changeHide1(e) {
  318. that.purchase.hidden = e
  319. },
  320. changeHide2(e) {
  321. that.repair.hidden = e
  322. },
  323. submit() {
  324. if(!that.repair.name) {
  325. $api.info('请填写姓名')
  326. return
  327. }
  328. if(!that.repair.company_name) {
  329. $api.info('请填写所在单位')
  330. return
  331. }
  332. if(that.fileList3 == '') {
  333. $api.info('请上传营业执照')
  334. return
  335. }
  336. if(that.fileList4 == '' || that.fileList5 == '') {
  337. $api.info('请上传身份证照片')
  338. return
  339. }
  340. if(that.repair.phone == '') {
  341. $api.info('请填写你的手机号')
  342. return
  343. }
  344. if(that.repair.email == '') {
  345. $api.info('请填写你的邮箱')
  346. return
  347. }
  348. if(that.repair.address == '' ) {
  349. $api.info('请填写你的详细地址')
  350. return
  351. }
  352. $api.req({
  353. url: '/data/api.auth.ShipEngineMaintenance/subacceptance',
  354. method: 'POST',
  355. data: {
  356. name: that.repair.name,
  357. company_name: that.repair.company_name,
  358. business_img: that.fileList3[0].url,
  359. id_card_zheng: that.fileList4[0].url,
  360. id_card_fan: that.fileList5[0].url,
  361. phone: that.repair.phone,
  362. email: that.repair.email,
  363. address: that.repair.address,
  364. job_resume: that.repair.job_resume,
  365. specialty: that.repair.specialty,
  366. province: uni.getStorageSync('location').province,
  367. city: uni.getStorageSync('location').city,
  368. area: uni.getStorageSync('location').district,
  369. hidden: that.repair.hidden?2:1,
  370. id: that.repair.id? that.repair.id: ''
  371. }
  372. }, function(res) {
  373. if(res.code == 1) {
  374. $api.info(res.info)
  375. }
  376. })
  377. },
  378. publish() {
  379. if(that.purchase.description == '') {
  380. $api.info('请先输入需求说明')
  381. return
  382. }
  383. var imgs = ''
  384. var imgs2 = ''
  385. if(that.fileList2.length == 1) {
  386. imgs = that.fileList2[0].url
  387. } else if (that.fileList2.length > 1) {
  388. for(var i=0;i<that.fileList2.length;i++) {
  389. if(i == that.fileList2.length - 1) {
  390. imgs += that.fileList2[i].url
  391. } else {
  392. imgs += that.fileList2[i].url + ','
  393. }
  394. }
  395. } else if(that.fileList2.length == 0) {
  396. $api.info('请上传证书')
  397. return
  398. }
  399. if(that.fileList1.length == 0) {
  400. $api.info('请上传营业执照或身份证')
  401. return
  402. } else {
  403. imgs2 = that.fileList1[0].url
  404. }
  405. $api.req({
  406. url: '/data/api.auth.Center/subpurchaseacceptance',
  407. method: 'POST',
  408. data: {
  409. description : that.purchase? that.purchase.description : '',
  410. business_img: imgs2,
  411. imgs: imgs,
  412. hidden: that.purchase.hidden?2:1,
  413. province: uni.getStorageSync('location').province,
  414. city: uni.getStorageSync('location').city,
  415. area: uni.getStorageSync('location').district,
  416. id: that.purchase.id?that.purchase.id:''
  417. }
  418. }, function(res) {
  419. if(res.code == 1) {
  420. $api.info(res.info)
  421. }
  422. })
  423. },
  424. // 去申请
  425. toApply() {
  426. that.close()
  427. $api.jump('/page_shop/pages/service/applyMaintenance')
  428. },
  429. // 关闭
  430. close() {
  431. that.show_tips = false
  432. },
  433. },
  434. }
  435. </script>
  436. <style lang="scss" scoped>
  437. .content::v-deep {
  438. .tabs {
  439. width: 650rpx;
  440. box-sizing: border-box;
  441. margin: 26rpx 56rpx;
  442. background: #F5F5F5;
  443. border-radius: 40rpx;
  444. .tab_item {
  445. width: 50%;
  446. height: 80rpx;
  447. // border-radius: 40rpx;
  448. text-align: center;
  449. font-size: 30rpx;
  450. font-weight: 400;
  451. color: #222222;
  452. line-height: 80rpx;
  453. }
  454. .tab_active {
  455. background: #506DFF;
  456. color: #FFFFFF;
  457. border-radius: 40rpx;
  458. }
  459. }
  460. .img_box {
  461. margin: 120rpx 0 0;
  462. .text {
  463. padding-top: 20rpx;
  464. font-size: 32rpx;
  465. font-weight: 400;
  466. color: #222222;
  467. line-height: 44rpx;
  468. }
  469. }
  470. .release {
  471. margin-top: 112rpx;
  472. width: 450rpx;
  473. height: 92rpx;
  474. background: #506DFF;
  475. border-radius: 46rpx;
  476. font-size: 36rpx;
  477. text-align: center;
  478. font-weight: 500;
  479. color: #FFFFFF;
  480. line-height: 92rpx;
  481. }
  482. .box {
  483. width: 100%;
  484. min-height: calc(100vh - 108rpx);
  485. background: #F5F5F5;
  486. box-sizing: border-box;
  487. padding: 0 20rpx;
  488. .box1 {
  489. width: 100%;
  490. background: #FFFFFF;
  491. border-radius: 10px;
  492. margin-top: 20rpx;
  493. box-sizing: border-box;
  494. padding: 0 20rpx 36rpx;
  495. .title {
  496. margin: 24rpx 0 20rpx 10rpx;
  497. font-size: 28rpx;
  498. font-weight: 400;
  499. color: #222222;
  500. line-height: 40rpx;
  501. }
  502. .requied {
  503. position: relative;
  504. padding-left: 10rpx;
  505. }
  506. .requied::before{
  507. content: '*';
  508. position: absolute;
  509. top: 10rpx;
  510. left: -10rpx;
  511. color: #ff0000;
  512. }
  513. .u-textarea {
  514. background-color: #F5F5F5;
  515. }
  516. .text {
  517. font-size: 24rpx;
  518. font-weight: 400;
  519. color: #d75a59;
  520. margin: 16rpx 0;
  521. }
  522. }
  523. .cell {
  524. width: 100%;
  525. padding: 32rpx 0 24rpx;
  526. border-bottom: 1rpx solid #F4F4F4;
  527. .label {
  528. font-size: 28rpx;
  529. font-weight: 400;
  530. color: #222222;
  531. line-height: 40rpx;
  532. }
  533. .upload {
  534. box-sizing: border-box;
  535. padding: 40rpx 60rpx;
  536. position: relative;
  537. width: 100%;
  538. height: 400rpx;
  539. background: #F4F4F4;
  540. border-radius: 16rpx;
  541. margin-top: 24rpx;
  542. .upload_img {
  543. position: absolute;
  544. width: 120rpx;
  545. height: 120rpx;
  546. top: 142rpx;
  547. left: 266rpx;
  548. }
  549. }
  550. .upload2 {
  551. position: relative;
  552. .upload_img2 {
  553. position: absolute;
  554. width: 80rpx;
  555. height: 80rpx;
  556. top: 40rpx;
  557. left: 116rpx;
  558. }
  559. }
  560. }
  561. }
  562. .bottom {
  563. width: 100%;
  564. height: 166rpx;
  565. background-color: #fff;
  566. box-shadow: 0 -2rpx 16rpx 0 rgba(215,215,215,0.5);
  567. position: fixed;
  568. bottom: 0;
  569. box-sizing: border-box;
  570. padding: 12rpx 30rpx;
  571. z-index: 99;
  572. .btn {
  573. width: 690rpx;
  574. height: 84rpx;
  575. background-color: #506dff;
  576. border-radius: 50rpx;
  577. box-shadow: 0 4rpx 28rpx 0 rgba(132,123,255,0.4);
  578. font-size: 40rpx;
  579. color: #fff;
  580. text-align: center;
  581. line-height: 84rpx;
  582. }
  583. }
  584. }
  585. .popup1 {
  586. width: 530rpx;
  587. // height: 520rpx;
  588. border-radius: 40rpx;
  589. position: relative;
  590. box-sizing: border-box;
  591. padding: 0 40rpx 40rpx;
  592. .popup_img {
  593. width: 174rpx;
  594. height: 172rpx;
  595. position: absolute;
  596. top: -50rpx;
  597. left: 178rpx;
  598. z-index: 99;
  599. }
  600. .popup1_title {
  601. margin-top: 134rpx;
  602. text-align: center;
  603. font-size: 48rpx;
  604. font-weight: 400;
  605. color: #222222;
  606. }
  607. .popup1_text {
  608. width: 100%;
  609. text-align: center;
  610. font-size: 28rpx;
  611. font-weight: 400;
  612. color: #666666;
  613. margin: 44rpx auto 52rpx;
  614. }
  615. .popup1_btn {
  616. margin: 0 auto;
  617. width: 310rpx;
  618. height: 84rpx;
  619. background: linear-gradient(90deg, #506DFF 0%, #88A6FF 100%);
  620. box-shadow: 0px 4rpx 24rpx 0px rgba(90,119,255,0.36);
  621. border-radius: 42rpx;
  622. text-align: center;
  623. line-height: 84rpx;
  624. font-size: 32rpx;
  625. font-weight: 500;
  626. color: #FFFFFF;
  627. }
  628. }
  629. </style>