demand.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  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">需求说明</view>
  29. <u--textarea v-model="purchase.description" placeholder="请详细描述你的采购需求" border="none"></u--textarea>
  30. <view class="title">上传营业执照或者身份证件照</view>
  31. <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple :maxCount="1" width="200rpx" height="200rpx"></u-upload>
  32. </view>
  33. <view class="box1">
  34. <view class="title">上传图片以及资质证件照片</view>
  35. <u-upload :fileList="fileList2" @afterRead="afterRead" @delete="deletePic" name="2" multiple :maxCount="9" width="200rpx" height="200rpx"></u-upload>
  36. </view>
  37. <view class="box1 hflex acenter jbetween" style="margin-bottom: 186rpx;padding: 0 20rpx;">
  38. <view class="title">是否隐藏需求</view>
  39. <u-switch v-model="purchase.hidden" @change="changeHide1"></u-switch>
  40. </view>
  41. </view>
  42. <view class="bottom">
  43. <view class="btn" v-if="purchase.id !== ''" @click="publish">立即发布</view>
  44. <view class="btn" v-else @click="publish">立即修改</view>
  45. </view>
  46. </block>
  47. <block v-if="tab_active == 1 && is_write2 == 1">
  48. <view class="box">
  49. <view class="box1">
  50. <view class="hflex acenter jbetween cell">
  51. <view class="label">姓名</view>
  52. <u-input v-model="repair.name" placeholder="请填写姓名" inputAlign="right" border="none"></u-input>
  53. </view>
  54. <view class="hflex acenter jbetween cell">
  55. <view class="label">所在单位</view>
  56. <u-input v-model="repair.company_name" placeholder="请填写所在单位名称" inputAlign="right" border="none"></u-input>
  57. </view>
  58. <view class="cell">
  59. <view class="label">营业执照照片</view>
  60. <view class="upload hflex acenter jcenter">
  61. <u-upload :fileList="fileList3" @afterRead="afterRead" @delete="deletePic" :maxCount="1" name="3" multiple :previewFullImage="true" width="530rpx" height="324rpx">
  62. <image src="https://ship-expert.zhousi.hdlkeji.com/common/upload-business.png" style="width: 530rpx;height: 324rpx;"></image>
  63. <image class="upload_img" src="https://ship-expert.zhousi.hdlkeji.com/common/upload-top.png"></image>
  64. </u-upload>
  65. </view>
  66. </view>
  67. <view class="cell" style="border: none;">
  68. <view class="label">身份证正反面</view>
  69. <view class="hflex acenter jbetween" style="margin-top: 28rpx;">
  70. <u-upload :fileList="fileList4" @afterRead="afterRead" @delete="deletePic" :maxCount="1" name="4" multiple :previewFullImage="true" width="310rpx" height="188rpx">
  71. <image src="https://ship-expert.zhousi.hdlkeji.com/common/upload-just.png" style="width: 310rpx;height: 188rpx;"></image>
  72. </u-upload>
  73. <view class="upload2">
  74. <u-upload :fileList="fileList5" @afterRead="afterRead" @delete="deletePic" :maxCount="1" name="5" multiple :previewFullImage="true" width="310rpx" height="188rpx">
  75. <image src="https://ship-expert.zhousi.hdlkeji.com/common/upload-back.png" style="width: 310rpx;height: 188rpx;"></image>
  76. <image class="upload_img2" src="https://ship-expert.zhousi.hdlkeji.com/common/upload-top.png"></image>
  77. </u-upload>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. <view class="box1" style="padding: 0 20rpx;">
  83. <view class="hflex acenter jbetween cell">
  84. <view class="label">手机号</view>
  85. <u-input v-model="repair.phone" placeholder="请填写你的手机号" inputAlign="right" border="none"></u-input>
  86. </view>
  87. <view class="hflex acenter jbetween cell">
  88. <view class="label">邮箱</view>
  89. <u-input v-model="repair.email" placeholder="请填写你的邮箱" inputAlign="right" border="none"></u-input>
  90. </view>
  91. <view class="hflex acenter jbetween cell" style="border: none;">
  92. <view class="label">地址</view>
  93. <u-input v-model="repair.address" placeholder="请填写你的详细地址" inputAlign="right" border="none"></u-input>
  94. </view>
  95. </view>
  96. <view class="box1">
  97. <view class="cell vflex jbetween">
  98. <view class="label">工作简历</view>
  99. <u-input v-model="repair.job_resume" placeholder="请详细描述你的工作经历" border="none"></u-input>
  100. </view>
  101. <view class="cell vflex jbetween" style="border: none;">
  102. <view class="label">特长</view>
  103. <u-input v-model="repair.specialty" placeholder="请简单叙述一下你的优点及特长" border="none"></u-input>
  104. </view>
  105. </view>
  106. <view class="box1 hflex acenter jbetween" style="margin-bottom: 186rpx;padding: 0 20rpx;">
  107. <view class="title">是否隐藏需求</view>
  108. <u-switch v-model="repair.hidden == 2?true:false" @change="changeHide2"></u-switch>
  109. </view>
  110. </view>
  111. <view class="bottom">
  112. <view class="btn" v-if="JSON.stringify(repair) == '{}'" @click="submit">立即发布</view>
  113. <view class="btn" v-else @click="submit">立即修改</view>
  114. </view>
  115. </block>
  116. </view>
  117. </template>
  118. <script>
  119. import $api from '@/static/js/api.js'
  120. var that = ''
  121. export default {
  122. data() {
  123. return {
  124. tab_active: 0,
  125. is_write1: 0,
  126. is_write2: 0,
  127. purchase: {
  128. description: '',
  129. hidden: false
  130. },
  131. repair: {},
  132. fileList1: [],
  133. fileList2: [],
  134. fileList3: [],
  135. fileList4: [],
  136. fileList5: [],
  137. }
  138. },
  139. onLoad() {
  140. that = this
  141. that.getData()
  142. console.log(that.re);
  143. },
  144. methods: {
  145. getData() {
  146. $api.req({
  147. url: '/data/api.auth.Center/myneed',
  148. method: 'POST',
  149. data: {
  150. type: that.tab_active + 1
  151. }
  152. }, function(res) {
  153. if(res.code == 1) {
  154. console.log(!res.data);
  155. if(!res.data &&that.tab_active == 0) {
  156. that.is_write1 = 0
  157. }
  158. if(res.data &&that.tab_active == 0) {
  159. that.is_write1 = 1
  160. that.purchase = res.data
  161. if(res.data.hidden == 2) {
  162. that.purchase.hidden = false
  163. } else {
  164. that.purchase.hidden = true
  165. }
  166. that.fileList1 = []
  167. that.fileList1.push({
  168. url:res.data.business_img
  169. })
  170. var imgs = res.data.imgs
  171. let obj = {}
  172. for(let key in imgs) {
  173. obj[key] = imgs[key]
  174. }
  175. var fileList2 = Object.keys(obj).map(item => ({
  176. url: obj[item]
  177. }))
  178. that.fileList2 = fileList2
  179. }
  180. if(JSON.stringify(res.data) == "[]" &&that.tab_active == 1) {
  181. that.is_write2 = 0
  182. }
  183. if(JSON.stringify(res.data) !== "[]" &&that.tab_active == 1) {
  184. that.is_write2 = 1
  185. that.repair = res.data
  186. that.fileList3 = []
  187. that.fileList3.push({
  188. url:res.data.business_img
  189. })
  190. that.fileList4 = []
  191. that.fileList4.push({
  192. url:res.data.id_card_zheng
  193. })
  194. that.fileList5 = []
  195. that.fileList5.push({
  196. url:res.data.id_card_fan
  197. })
  198. }
  199. }
  200. })
  201. },
  202. // 切换tabs
  203. changeTabs(index) {
  204. console.log(index);
  205. that.tab_active = index
  206. that.getData()
  207. },
  208. // 立即发布
  209. release(index) {
  210. if(index == 1) {
  211. that.is_write1 = 1
  212. } else {
  213. that.is_write2 = 1
  214. }
  215. },
  216. // 删除图片
  217. deletePic(event) {
  218. this[`fileList${event.name}`].splice(event.index, 1)
  219. },
  220. // 新增图片
  221. async afterRead(event) {
  222. uni.showLoading({
  223. title: '上传中',
  224. mask: true
  225. })
  226. let lists = [].concat(event.file)
  227. let fileListLen = this[`fileList${event.name}`].length
  228. lists.map((item) => {
  229. this[`fileList${event.name}`].push({
  230. ...item,
  231. status: 'uploading',
  232. message: '上传中'
  233. })
  234. })
  235. for (let i = 0; i < lists.length; i++) {
  236. const result = await this.uploadFilePromise(lists[i].url)
  237. let item = this[`fileList${event.name}`][fileListLen]
  238. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  239. status: 'success',
  240. message: '',
  241. url: result.url
  242. }))
  243. fileListLen++
  244. if(lists.length - 1 == i) {
  245. uni.hideLoading()
  246. }
  247. }
  248. },
  249. uploadFilePromise(url) {
  250. return new Promise((resolve, reject) => {
  251. let a = uni.uploadFile({
  252. url: $api.config.baseUrl + '/data/api.auth.Center/upload',
  253. filePath: url,
  254. name: 'file',
  255. header: {
  256. 'content-type': 'application/x-www-form-urlencoded',
  257. 'api-token': uni.getStorageSync('token').token?uni.getStorageSync('token').token:'',
  258. 'api-name': 'wxapp'
  259. },
  260. formData: {
  261. user: 'test'
  262. },
  263. success: (res) => {
  264. setTimeout(() => {
  265. var data = JSON.parse(res.data)
  266. resolve(data.data)
  267. }, 1000)
  268. }
  269. });
  270. })
  271. },
  272. changeHide1(e) {
  273. that.purchase.hidden = e
  274. },
  275. changeHide2(e) {
  276. that.repair.hidden = e
  277. },
  278. submit() {
  279. $api.req({
  280. url: '/data/api.auth.ShipEngineMaintenance/subacceptance',
  281. method: 'POST',
  282. data: {
  283. name: that.repair.name,
  284. company_name: that.repair.company_name,
  285. business_img: that.fileList3[0].url,
  286. id_card_zheng: that.fileList4[0].url,
  287. id_card_fan: that.fileList5[0].url,
  288. phone: that.repair.phone,
  289. email: that.repair.email,
  290. address: that.repair.address,
  291. job_resume: that.repair.job_resume,
  292. specialty: that.repair.specialty,
  293. province: uni.getStorageSync('location').province,
  294. city: uni.getStorageSync('location').city,
  295. area: uni.getStorageSync('location').district,
  296. hidden: that.repair.hidden?2:1,
  297. id: that.repair.id? that.repair.id: ''
  298. }
  299. }, function(res) {
  300. if(res.code == 1) {
  301. $api.info(res.info)
  302. }
  303. })
  304. },
  305. publish() {
  306. var imgs = ''
  307. var imgs2 = ''
  308. if(that.fileList2.length == 1) {
  309. imgs = that.fileList2[0].url
  310. } else if (that.fileList2.length > 1) {
  311. for(var i=0;i<that.fileList2.length;i++) {
  312. if(i == that.fileList2.length - 1) {
  313. imgs += that.fileList2[i].url
  314. } else {
  315. imgs += that.fileList2[i].url + ','
  316. }
  317. }
  318. } else if(that.fileList2.length == 0) {
  319. $api.info('请上传证书')
  320. return
  321. }
  322. if(that.fileList1.length == 0) {
  323. $api.info('请上传营业执照或身份证')
  324. return
  325. } else {
  326. imgs2 = that.fileList1[0].url
  327. }
  328. $api.req({
  329. url: '/data/api.auth.Center/subpurchaseacceptance',
  330. method: 'POST',
  331. data: {
  332. description : that.purchase? that.purchase.description : '',
  333. business_img: imgs2,
  334. imgs: imgs,
  335. hidden: that.purchase.hidden?2:1,
  336. province: uni.getStorageSync('location').province,
  337. city: uni.getStorageSync('location').city,
  338. area: uni.getStorageSync('location').district,
  339. id: that.purchase.id?that.purchase.id:''
  340. }
  341. }, function(res) {
  342. if(res.code == 1) {
  343. $api.info(res.info)
  344. }
  345. })
  346. }
  347. },
  348. }
  349. </script>
  350. <style lang="scss" scoped>
  351. .content::v-deep {
  352. .tabs {
  353. width: 650rpx;
  354. box-sizing: border-box;
  355. margin: 26rpx 56rpx;
  356. background: #F5F5F5;
  357. border-radius: 40rpx;
  358. .tab_item {
  359. width: 50%;
  360. height: 80rpx;
  361. // border-radius: 40rpx;
  362. text-align: center;
  363. font-size: 30rpx;
  364. font-weight: 400;
  365. color: #222222;
  366. line-height: 80rpx;
  367. }
  368. .tab_active {
  369. background: #506DFF;
  370. color: #FFFFFF;
  371. border-radius: 40rpx;
  372. }
  373. }
  374. .img_box {
  375. margin: 120rpx 0 0;
  376. .text {
  377. padding-top: 20rpx;
  378. font-size: 32rpx;
  379. font-weight: 400;
  380. color: #222222;
  381. line-height: 44rpx;
  382. }
  383. }
  384. .release {
  385. margin-top: 112rpx;
  386. width: 450rpx;
  387. height: 92rpx;
  388. background: #506DFF;
  389. border-radius: 46rpx;
  390. font-size: 36rpx;
  391. text-align: center;
  392. font-weight: 500;
  393. color: #FFFFFF;
  394. line-height: 92rpx;
  395. }
  396. .box {
  397. width: 100%;
  398. min-height: calc(100vh - 108rpx);
  399. background: #F5F5F5;
  400. box-sizing: border-box;
  401. padding: 0 20rpx;
  402. .box1 {
  403. width: 100%;
  404. background: #FFFFFF;
  405. border-radius: 10px;
  406. margin-top: 20rpx;
  407. box-sizing: border-box;
  408. padding: 0 20rpx 36rpx;
  409. .title {
  410. padding: 24rpx 0 20rpx;
  411. font-size: 28rpx;
  412. font-weight: 400;
  413. color: #222222;
  414. line-height: 40rpx;
  415. }
  416. .u-textarea {
  417. background-color: #F5F5F5;
  418. }
  419. }
  420. .cell {
  421. width: 100%;
  422. padding: 32rpx 0 24rpx;
  423. border-bottom: 1rpx solid #F4F4F4;
  424. .label {
  425. font-size: 28rpx;
  426. font-weight: 400;
  427. color: #222222;
  428. line-height: 40rpx;
  429. }
  430. .upload {
  431. box-sizing: border-box;
  432. padding: 40rpx 60rpx;
  433. position: relative;
  434. width: 100%;
  435. height: 400rpx;
  436. background: #F4F4F4;
  437. border-radius: 16rpx;
  438. margin-top: 24rpx;
  439. .upload_img {
  440. position: absolute;
  441. width: 120rpx;
  442. height: 120rpx;
  443. top: 142rpx;
  444. left: 266rpx;
  445. }
  446. }
  447. .upload2 {
  448. position: relative;
  449. .upload_img2 {
  450. position: absolute;
  451. width: 80rpx;
  452. height: 80rpx;
  453. top: 40rpx;
  454. left: 116rpx;
  455. }
  456. }
  457. }
  458. }
  459. .bottom {
  460. width: 100%;
  461. height: 166rpx;
  462. background-color: #fff;
  463. box-shadow: 0 -2rpx 16rpx 0 rgba(215,215,215,0.5);
  464. position: fixed;
  465. bottom: 0;
  466. box-sizing: border-box;
  467. padding: 12rpx 30rpx;
  468. z-index: 99;
  469. .btn {
  470. width: 690rpx;
  471. height: 84rpx;
  472. background-color: #506dff;
  473. border-radius: 50rpx;
  474. box-shadow: 0 4rpx 28rpx 0 rgba(132,123,255,0.4);
  475. font-size: 40rpx;
  476. color: #fff;
  477. text-align: center;
  478. line-height: 84rpx;
  479. }
  480. }
  481. }
  482. </style>