editRelease.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. <template>
  2. <view class="content">
  3. <view class="content1">
  4. <!-- <view class="top">
  5. <textarea v-model="dataObj.publishingContent" placeholder="请发布粮食类商品交易信息,建议包含联系方" maxlength='200'
  6. placeholder-class='placeholder-class' class="textarea" />
  7. <view class="number">
  8. {{dataObj.publishingContent.length}}/200个字
  9. </view>
  10. </view> -->
  11. <view class='row'>
  12. <view class="textarea">
  13. <textarea placeholder-style="color:#AFB3BF;" placeholder="请发布粮食类商品交易信息,建议包含联系方式" maxlength="2000"
  14. v-model="dataObj.publishingContent"></textarea>
  15. <view class="textarea-left">
  16. <view class="clear" @click="clear()">清除全部</view>
  17. </view>
  18. <view class="textarea-bottom">
  19. {{dataObj.publishingContent?dataObj.publishingContent.length:'0'}}/2000字
  20. </view>
  21. </view>
  22. <!-- <view class="number">
  23. {{dataObj.publishingContent.length}}/2000个字
  24. </view> -->
  25. </view>
  26. <view style="padding-left: 10rpx;">
  27. <view style='flex-wrap:wrap;' class='flex'>
  28. <view v-for='(item,index) in imgList2' v-if="imgList2 && imgList2.length > 0"
  29. style="position: relative;margin-left: 20rpx;">
  30. <view class="delete_img" @click="deleteImg(index)">
  31. <u-icon size='4' name="close"></u-icon>
  32. </view>
  33. <image :src="item.appendixPath" mode=""
  34. style="width: 100px;height: 100px;border:1px solid #ccc;border-radius: 5rpx;"></image>
  35. </view>
  36. <view class="biankuang" @click="uploadClick" v-if="imgList2.length < 9">
  37. <view class="tubiao">
  38. <image class="upload" src="../../static/img/jiaoyi/tianjiazhaopian.png" mode="">
  39. </image>
  40. </view>
  41. </view>
  42. </view>
  43. <!-- <upload :file-list='businesslicense' class="upload" ref="upload" :action="action" :max-size="maxSize"
  44. delIconSize='30' delBgColor='rgba(0,0,0,0.4)' delIcon="trash" :max-count="9"
  45. :size-type="['compressed']" @on-success="getImgUrl" @on-remove="onRemove"
  46. :before-upload="filterFileType"></upload> -->
  47. </view>
  48. </view>
  49. <view class="content2">
  50. <u-cell-group class='wrap'>
  51. <u-cell-item title="交易类型" :arrow="false" :title-style="titleStyle">
  52. <u-radio-group v-model="dataObj.tranType">
  53. <u-radio @change="radioChange" v-for="(item, index) in list" :key="index" :name="item.name"
  54. :disabled="item.disabled" active-color="#303030">
  55. {{item.name}}
  56. </u-radio>
  57. </u-radio-group>
  58. </u-cell-item>
  59. <u-cell-item :title="placeTitle" :title-style="titleStyle">
  60. <selectAddress @selectAddress='selectAddress' series='3' :textStyle='textStyle' :edit='true'
  61. :text='dataObj.placeDelivery'></selectAddress>
  62. </u-cell-item>
  63. <u-cell-item title="发布者昵称" :title-style="titleStyle" :border-bottom='false' @click="editNicknamee">
  64. <view :style='textStyle'>
  65. {{dataObj.publisher}}
  66. </view>
  67. <!-- <selectAddress @selectAddress='selectAddress' series='3' :textStyle='textStyle'></selectAddress> -->
  68. </u-cell-item>
  69. </u-cell-group>
  70. </view>
  71. <view class="submit" @click="submit">
  72. 发布
  73. </view>
  74. <u-popup v-model="showNickname" mode='center' border-radius="14" width='70%' @close='closePopup'>
  75. <view class="edit-nickname">
  76. <view>昵称长度限制在2-24个字符内</view>
  77. <u-input v-model="dataObj.publisher" border class='nickname-input' />
  78. <view style="text-align: center;">
  79. <u-button type="success" size="medium" class="nickname-btn" @click="nickNamesubmit">保存</u-button>
  80. </view>
  81. </view>
  82. </u-popup>
  83. </view>
  84. </template>
  85. <script>
  86. import * as config from '../../config'
  87. import upload from '@/components/upload_small.vue';
  88. import selectAddress from "@/components/selectAddress.vue"
  89. import {
  90. mapState
  91. } from 'vuex';
  92. export default {
  93. components: {
  94. upload,
  95. selectAddress
  96. },
  97. data() {
  98. return {
  99. imgList2: [],
  100. searchPlaceHolder: '选择交货地区',
  101. placeTitle: '交货地',
  102. id: '',
  103. imgList: [],
  104. showNickname: false,
  105. dataObj: {
  106. userId: '',
  107. tranType: '采购',
  108. placeDelivery: '',
  109. urlImg: '',
  110. publishingContent: '',
  111. publisher: '',
  112. },
  113. titleStyle: {
  114. "font-size": "28rpx",
  115. "color": "#333333",
  116. // "font-weight": 700
  117. },
  118. textStyle: {
  119. "font-size": "32rpx",
  120. "color": "#333333",
  121. "margin-right": '27rpx'
  122. },
  123. list: [{
  124. name: '采购',
  125. disabled: false
  126. },
  127. {
  128. name: '销售',
  129. disabled: false
  130. }
  131. ],
  132. businesslicense: [],
  133. value: '',
  134. action: this.$uploadUrl,
  135. maxSize: 50 * 1024 * 1024, //限制文件大小 50M
  136. isAdd: false,
  137. num: 0
  138. };
  139. },
  140. watch: {
  141. imgList: {
  142. handler: function() {
  143. var that = this
  144. setTimeout(() => {
  145. that.$api.doRequest('get', 'appendix/query/getFileList', {
  146. appendixIds: that.imgList.toString()
  147. }).then(res => {
  148. that.imgList2 = res.data.data
  149. that.$forceUpdate()
  150. })
  151. }, 1000)
  152. },
  153. deep: true,
  154. immediate: true
  155. }
  156. },
  157. onLoad(options) {
  158. this.id = options.id
  159. console.log(this.id)
  160. this.init()
  161. // this.dataObj.userId = this.userInfo.id
  162. // this.dataObj.publisher = this.userInfo.wechatNo
  163. },
  164. onNavigationBarButtonTap(e) {
  165. console.log(e)
  166. uni.navigateTo({
  167. url: 'record'
  168. })
  169. },
  170. computed: {
  171. ...mapState(['hasLogin', 'userInfo', 'clientId']),
  172. },
  173. onShow() {
  174. let _tl = uni.getStorageSync('transactionPlace')
  175. if (_tl) {
  176. this.dataObj.placeDelivery = _tl.address
  177. } else {
  178. }
  179. },
  180. methods: {
  181. deleteImg(index) {
  182. this.num = this.imgList.length
  183. this.imgList.splice(index, 1)
  184. },
  185. async uploadClick() {
  186. let baseUrlNew = config.def().baseUrlNew
  187. let pcUserInfo = uni.getStorageSync('pcUserInfo')
  188. console.log('baseUrlNew', baseUrlNew)
  189. if (!pcUserInfo) {
  190. uni.showToast({
  191. title: "登录已失效,请重新登录"
  192. })
  193. return
  194. }
  195. await uni.chooseImage({
  196. count: 9,
  197. success: (chooseImageRes) => {
  198. console.log('chooseImageRes', chooseImageRes)
  199. let files = []
  200. for (let item of chooseImageRes.tempFiles) {
  201. files.push({
  202. name: 'fileName',
  203. url: item.path
  204. });
  205. }
  206. console.log(files)
  207. for (let i = 0; i < files.length; i++) {
  208. this.num++
  209. if (this.num < 10) {
  210. console.log(this.num)
  211. uni.uploadFile({
  212. url: baseUrlNew + 'appendix/api/uploadFiles',
  213. // url: baseUrlNew+'appendix/api/uploadFiles', //仅为示例,非真实的接口地址
  214. // files: files[i],
  215. filePath: files[i].url,
  216. name: files[i].name,
  217. formData: {
  218. // fileName: chooseImageRes.tempFiles[0],
  219. companyId: pcUserInfo.compId,
  220. modelId: '',
  221. vesselId: '',
  222. },
  223. success: (uploadFileRes) => {
  224. console.log(JSON.parse(uploadFileRes.data))
  225. var data = JSON.parse(uploadFileRes.data).data
  226. data.compId = pcUserInfo.compId
  227. this.$api.doRequest('post',
  228. '/appendix/api/saveFilesApp', {
  229. newAppendixs: [data],
  230. oldAppendixIds: ""
  231. }).then(res => {
  232. console.log(res.data.data)
  233. this.imgList.push(res.data.data[0])
  234. })
  235. console.log(uploadFileRes.data);
  236. },
  237. fail(res) {
  238. console.log(res);
  239. }
  240. });
  241. } else {
  242. break;
  243. }
  244. }
  245. }
  246. });
  247. },
  248. clear() {
  249. this.dataObj.publishingContent = ''
  250. },
  251. async init() {
  252. let _obj = {
  253. id: this.id
  254. }
  255. uni.showLoading({
  256. title: '数据加载中',
  257. mask: true
  258. })
  259. await this.$api.doRequest('get', '/transactionExchangeInfo/selectExchangeInfo', _obj).then(res => {
  260. console.log(res.data)
  261. if (res.data.code == 200) {
  262. this.dataObj = res.data.data
  263. if (this.dataObj.tranType == '销售') {
  264. this.placeTitle = '货源地'
  265. this.searchPlaceHolder = '选择货源地区'
  266. } else {
  267. this.placeTitle = '交货地'
  268. this.searchPlaceHolder = '选择交货地区'
  269. }
  270. this.imgList = res.data.data.urlImg.split(',')
  271. // for (let i = 0; i < this.imgList.length; i++) {
  272. // this.businesslicense.push({
  273. // url: this.imgList[i]
  274. // })
  275. // }
  276. // console.log("this.businesslicense", this.businesslicense)
  277. }
  278. uni.hideLoading()
  279. })
  280. if (this.imgList.length > 0) {
  281. this.businesslicense = []
  282. console.log(this.imgList)
  283. let _imgList = []
  284. for (let i = 0; i < this.imgList.length; i++) {
  285. await this.$api.doRequest('get', 'appendix/query/getFileList', {
  286. appendixIds: this.imgList[i]
  287. }).then(res1 => {
  288. console.log(res1)
  289. _imgList.push({
  290. url: res1.data.data[0].appendixPath
  291. })
  292. if (i == this.imgList.length - 1) {
  293. uni.hideLoading()
  294. }
  295. // for (let q = 0; q < res1.data.data.length; q++) {
  296. // }
  297. })
  298. }
  299. this.businesslicense = _imgList
  300. console.log("this.businesslicense", this.businesslicense)
  301. }
  302. },
  303. closePopup() {
  304. this.dataObj.publisher = this.userInfo.wechatNo
  305. },
  306. nickNamesubmit() {
  307. if (this.dataObj.publisher == null || this.dataObj.publisher == "") {
  308. this.$api.msg('请输入昵称!')
  309. return
  310. }
  311. if (this.dataObj.publisher.length < 2 || this.dataObj.publisher.length > 24) {
  312. this.$api.msg('请正确输入昵称!')
  313. return
  314. }
  315. let _obj = {
  316. wechatNo: this.dataObj.publisher,
  317. id: this.userInfo.id
  318. }
  319. uni.showLoading({
  320. title: '数据加载中',
  321. mask: true
  322. })
  323. let that = this
  324. that.$api.doRequest('post', '/commonUser/editUserInfo', _obj).then(
  325. res => {
  326. if (res.data.code == 200) {
  327. uni.showToast({
  328. title: '修改成功!',
  329. icon: 'success',
  330. duration: 2000,
  331. success() {
  332. setTimeout(() => {
  333. var _student = uni.getStorageSync('userInfo');
  334. _student.wechatNo = that.dataObj.publisher;
  335. uni.setStorageSync('userInfo', _student);
  336. var name = 'userInfo';
  337. var value = _student;
  338. that.$store.commit('$uStore', {
  339. name,
  340. value
  341. });
  342. uni.hideLoading()
  343. that.showNickname = false
  344. }, 2000)
  345. }
  346. })
  347. }
  348. })
  349. .catch(res => {
  350. if (res.errmsg) {
  351. uni.showToast({
  352. title: res.errmsg,
  353. icon: 'none',
  354. duration: 2000
  355. })
  356. } else {
  357. uni.showToast({
  358. title: "系统异常,请联系管理员",
  359. icon: 'none',
  360. duration: 2000
  361. })
  362. }
  363. });
  364. },
  365. editNicknamee() {
  366. this.showNickname = true
  367. },
  368. submit() {
  369. uni.showLoading({
  370. title: '数据加载中',
  371. mask: true
  372. })
  373. this.dataObj.urlImg = this.imgList.toString()
  374. this.dataObj.flag = 3
  375. this.dataObj.remark3 = new Date().getTime()
  376. this.$api.doRequest('post', '/transactionExchangeInfo/editInfo', this.dataObj).then(res => {
  377. console.log(res)
  378. if (res.data.code == 200) {
  379. uni.navigateBack({
  380. delta: 1
  381. })
  382. } else {
  383. uni.showToast({
  384. title: "系统异常,请联系管理员",
  385. icon: 'none',
  386. duration: 2000
  387. })
  388. }
  389. })
  390. },
  391. selectAddress(val) {
  392. console.log(val)
  393. console.log(this.dataObj.tranType)
  394. if (!val.check) {
  395. uni.showToast({
  396. title: '地点必须选到区县一级',
  397. icon: 'none',
  398. duration: 2000
  399. })
  400. return
  401. }
  402. try {
  403. uni.setStorageSync('transactionPlace', val);
  404. this.dataObj.placeDelivery = val.address
  405. } catch (e) {
  406. // error
  407. }
  408. },
  409. radioChange(e) {
  410. // console.log(e);
  411. console.log(e);
  412. if (e == '销售') {
  413. this.placeTitle = '货源地'
  414. this.searchPlaceHolder = '选择货源地区'
  415. } else {
  416. this.placeTitle = '交货地'
  417. this.searchPlaceHolder = '选择交货地区'
  418. }
  419. },
  420. filterFileType(index, lists) {
  421. if (lists[index].fileType != 'jpg' && lists[index].fileType != 'png' && lists[index].fileType != 'gif') {
  422. lists.splice(index, 1);
  423. // 当前文件不支持
  424. uni.showModal({
  425. title: '暂不支持当前图片类型',
  426. showCancel: false
  427. });
  428. } else {
  429. this.isAdd = false;
  430. }
  431. },
  432. onRemove(index) {
  433. console.log("index", index)
  434. this.imgList.splice(index, 1)
  435. console.log(this.imgList)
  436. },
  437. getImgUrl(res) {
  438. console.log("this.businesslicense", this.businesslicense)
  439. console.log(res)
  440. console.log('------------res-----------')
  441. this.imgList.push(res)
  442. console.log(this.imgList)
  443. },
  444. onUploaded(lists) {
  445. this.filesArr = lists;
  446. let res = lists[0];
  447. if (res.response === undefined) {
  448. uni.showToast({
  449. title: '文件错误',
  450. icon: 'none'
  451. })
  452. }
  453. },
  454. },
  455. }
  456. </script>
  457. <style lang="scss" scoped>
  458. .content {
  459. // overflow: hidden;
  460. padding-bottom: 100rpx;
  461. }
  462. .content1 {
  463. background: #fff;
  464. margin: 20rpx;
  465. border-radius: 20rpx;
  466. padding-bottom: 40rpx;
  467. }
  468. /deep/.placeholder-class {
  469. color: #C5CAD4;
  470. font-size: 28rpx;
  471. }
  472. .textarea {
  473. padding: 20rpx 20rpx 50rpx 20rpx;
  474. width: 100%;
  475. font-size: 28rpx;
  476. }
  477. .top {
  478. position: relative;
  479. .number {
  480. position: absolute;
  481. right: 32rpx;
  482. bottom: 0;
  483. color: #C5CAD4;
  484. font-size: 26rpx;
  485. }
  486. }
  487. .content2 {
  488. padding: 20rpx;
  489. }
  490. /deep/.u-cell-item-box,
  491. /deep/.u-cell-box {
  492. border-radius: 20rpx;
  493. }
  494. .submit {
  495. margin: 40rpx auto;
  496. width: 654rpx;
  497. height: 92rpx;
  498. background: #22C572;
  499. border-radius: 46rpx;
  500. font-size: 34rpx;
  501. font-weight: 400;
  502. color: #FFFFFF;
  503. line-height: 92rpx;
  504. text-align: center;
  505. // position: fixed;
  506. // bottom: 76rpx;
  507. // left: 0;
  508. // right: 0;
  509. // margin: auto;
  510. }
  511. .edit-nickname {
  512. padding: 40rpx 80rpx;
  513. }
  514. .nickname-input {
  515. margin: 20rpx 0;
  516. }
  517. .nickname-btn {
  518. margin-top: 20rpx;
  519. }
  520. .row {
  521. display: flex;
  522. justify-content: space-between;
  523. position: relative;
  524. background: #fff;
  525. border-radius: 20rpx;
  526. input {
  527. font-size: 28rpx;
  528. // color: #333333;
  529. }
  530. .left {
  531. display: flex;
  532. align-items: center;
  533. color: #333333;
  534. font-size: 34rpx;
  535. font-weight: 600;
  536. }
  537. }
  538. .row_css {
  539. font-size: 26rpx;
  540. color: #333333;
  541. margin-top: 60rpx;
  542. font-weight: 500;
  543. }
  544. .textarea {
  545. background: #F9F9FA;
  546. font-size: 28rpx;
  547. text-align: left;
  548. width: 100%;
  549. padding: 30rpx 30rpx;
  550. border-radius: 5px;
  551. margin: 30rpx;
  552. height: 46vh;
  553. padding-bottom: 20rpx;
  554. color: #333;
  555. }
  556. .textarea textarea {
  557. height: 90%;
  558. }
  559. .textarea-left {
  560. position: absolute;
  561. bottom: 40rpx;
  562. left: 50rpx;
  563. color: #606266;
  564. }
  565. .textarea-bottom {
  566. position: absolute;
  567. bottom: 40rpx;
  568. right: 40rpx;
  569. color: #AFB3BF;
  570. }
  571. .clear {
  572. /* width: 90%; */
  573. // background: #ffffff;
  574. color: #22C572;
  575. // border: 1px solid #22C572;
  576. // border-radius: 50rpx;
  577. // font-size: 28rpx;
  578. // padding: 9rpx 24rpx;
  579. }
  580. .biankuang {
  581. // border: 1px dashed #AFB3BF;
  582. border-radius: 10rpx;
  583. width: 200rpx;
  584. height: 200rpx;
  585. margin-left: 20rpx;
  586. text-align: center;
  587. line-height: 220rpx;
  588. background: #F5F6FA;
  589. .upload {
  590. width: 46rpx;
  591. height: 46rpx;
  592. }
  593. }
  594. .delete_img {
  595. position: absolute;
  596. z-index: 100;
  597. right: 0px;
  598. border-radius: 0 5rpx 0 10px;
  599. color: #ffffff;
  600. font-size: 28rpx;
  601. border: 1px;
  602. // border-radius: 5rpx;
  603. width: 40rpx;
  604. height: 38rpx;
  605. background-color: rgba(17, 26, 52, 0.50);
  606. text-align: center;
  607. }
  608. /deep/.pickerClass {
  609. width: 80%;
  610. position: absolute;
  611. right: 11px;
  612. padding: 0 30px 0 0;
  613. top: 50%;
  614. transform: translateY(-50%);
  615. z-index: 2
  616. }
  617. </style>