editRelease.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  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. <upload :file-list='businesslicense' class="upload" ref="upload" :action="action" :max-size="maxSize"
  28. delIconSize='30' delBgColor='rgba(0,0,0,0.4)' delIcon="trash" :max-count="9"
  29. :size-type="['compressed']" @on-success="getImgUrl" @on-remove="onRemove"
  30. :before-upload="filterFileType"></upload>
  31. </view>
  32. </view>
  33. <view class="content2">
  34. <u-cell-group class='wrap'>
  35. <u-cell-item title="交易类型" :arrow="false" :title-style="titleStyle">
  36. <u-radio-group v-model="dataObj.tranType">
  37. <u-radio @change="radioChange" v-for="(item, index) in list" :key="index" :name="item.name"
  38. :disabled="item.disabled" active-color="#303030">
  39. {{item.name}}
  40. </u-radio>
  41. </u-radio-group>
  42. </u-cell-item>
  43. <u-cell-item :title="placeTitle" :title-style="titleStyle">
  44. <selectAddress @selectAddress='selectAddress' series='3' :textStyle='textStyle' :edit='true'
  45. :text='dataObj.placeDelivery'></selectAddress>
  46. </u-cell-item>
  47. <u-cell-item title="发布者昵称" :title-style="titleStyle" :border-bottom='false' @click="editNicknamee">
  48. <view :style='textStyle'>
  49. {{dataObj.publisher}}
  50. </view>
  51. <!-- <selectAddress @selectAddress='selectAddress' series='3' :textStyle='textStyle'></selectAddress> -->
  52. </u-cell-item>
  53. </u-cell-group>
  54. </view>
  55. <view class="submit" @click="submit">
  56. 发布
  57. </view>
  58. <u-popup v-model="showNickname" mode='center' border-radius="14" width='70%' @close='closePopup'>
  59. <view class="edit-nickname">
  60. <view>昵称长度限制在2-24个字符内</view>
  61. <u-input v-model="dataObj.publisher" border class='nickname-input' />
  62. <view style="text-align: center;">
  63. <u-button type="success" size="medium" class="nickname-btn" @click="nickNamesubmit">保存</u-button>
  64. </view>
  65. </view>
  66. </u-popup>
  67. </view>
  68. </template>
  69. <script>
  70. import upload from '@/components/upload_small.vue';
  71. import selectAddress from "@/components/selectAddress.vue"
  72. import {
  73. mapState
  74. } from 'vuex';
  75. export default {
  76. components: {
  77. upload,
  78. selectAddress
  79. },
  80. data() {
  81. return {
  82. searchPlaceHolder: '选择交货地区',
  83. placeTitle: '交货地',
  84. id: '',
  85. imgList: [],
  86. showNickname: false,
  87. dataObj: {
  88. userId: '',
  89. tranType: '采购',
  90. placeDelivery: '',
  91. urlImg: '',
  92. publishingContent: '',
  93. publisher: '',
  94. },
  95. titleStyle: {
  96. "font-size": "28rpx",
  97. "color": "#333333",
  98. // "font-weight": 700
  99. },
  100. textStyle: {
  101. "font-size": "32rpx",
  102. "color": "#333333",
  103. "margin-right": '27rpx'
  104. },
  105. list: [{
  106. name: '采购',
  107. disabled: false
  108. },
  109. {
  110. name: '销售',
  111. disabled: false
  112. }
  113. ],
  114. businesslicense: [],
  115. value: '',
  116. action: this.$uploadUrl,
  117. maxSize: 50 * 1024 * 1024, //限制文件大小 50M
  118. isAdd: false,
  119. };
  120. },
  121. onLoad(options) {
  122. this.id = options.id
  123. console.log(this.id)
  124. this.init()
  125. // this.dataObj.userId = this.userInfo.id
  126. // this.dataObj.publisher = this.userInfo.wechatNo
  127. },
  128. onNavigationBarButtonTap(e) {
  129. console.log(e)
  130. uni.navigateTo({
  131. url: 'record'
  132. })
  133. },
  134. computed: {
  135. ...mapState(['hasLogin', 'userInfo', 'clientId']),
  136. },
  137. onShow() {
  138. let _tl = uni.getStorageSync('transactionPlace')
  139. if (_tl) {
  140. this.dataObj.placeDelivery = _tl.address
  141. } else {
  142. }
  143. },
  144. methods: {
  145. clear() {
  146. this.dataObj.publishingContent = ''
  147. },
  148. init() {
  149. let _obj = {
  150. id: this.id
  151. }
  152. uni.showLoading({
  153. title: '数据加载中',
  154. mask: true
  155. })
  156. this.$api.doRequest('get', '/transactionExchangeInfo/selectExchangeInfo', _obj).then(res => {
  157. console.log(res.data)
  158. if (res.data.code == 200) {
  159. this.dataObj = res.data.data
  160. if (this.dataObj.tranType == '销售') {
  161. this.placeTitle = '货源地'
  162. this.searchPlaceHolder = '选择货源地区'
  163. } else {
  164. this.placeTitle = '交货地'
  165. this.searchPlaceHolder = '选择交货地区'
  166. }
  167. this.imgList = res.data.data.urlImg.split(',')
  168. for (let i = 0; i < this.imgList.length; i++) {
  169. this.businesslicense.push({
  170. url: this.imgList[i]
  171. })
  172. }
  173. console.log("this.businesslicense", this.businesslicense)
  174. }
  175. uni.hideLoading()
  176. })
  177. },
  178. closePopup() {
  179. this.dataObj.publisher = this.userInfo.wechatNo
  180. },
  181. nickNamesubmit() {
  182. if (this.dataObj.publisher == null || this.dataObj.publisher == "") {
  183. this.$api.msg('请输入昵称!')
  184. return
  185. }
  186. if (this.dataObj.publisher.length < 2 || this.dataObj.publisher.length > 24) {
  187. this.$api.msg('请正确输入昵称!')
  188. return
  189. }
  190. let _obj = {
  191. wechatNo: this.dataObj.publisher,
  192. id: this.userInfo.id
  193. }
  194. uni.showLoading({
  195. title: '数据加载中',
  196. mask: true
  197. })
  198. let that = this
  199. that.$api.doRequest('post', '/commonUser/editUserInfo', _obj).then(
  200. res => {
  201. if (res.data.code == 200) {
  202. uni.showToast({
  203. title: '修改成功!',
  204. icon: 'success',
  205. duration: 2000,
  206. success() {
  207. setTimeout(() => {
  208. var _student = uni.getStorageSync('userInfo');
  209. _student.wechatNo = that.dataObj.publisher;
  210. uni.setStorageSync('userInfo', _student);
  211. var name = 'userInfo';
  212. var value = _student;
  213. that.$store.commit('$uStore', {
  214. name,
  215. value
  216. });
  217. uni.hideLoading()
  218. that.showNickname = false
  219. }, 2000)
  220. }
  221. })
  222. }
  223. })
  224. .catch(res => {
  225. if (res.errmsg) {
  226. uni.showToast({
  227. title: res.errmsg,
  228. icon: 'none',
  229. duration: 2000
  230. })
  231. } else {
  232. uni.showToast({
  233. title: "系统异常,请联系管理员",
  234. icon: 'none',
  235. duration: 2000
  236. })
  237. }
  238. });
  239. },
  240. editNicknamee() {
  241. this.showNickname = true
  242. },
  243. submit() {
  244. uni.showLoading({
  245. title: '数据加载中',
  246. mask: true
  247. })
  248. this.dataObj.urlImg = this.imgList.toString()
  249. this.dataObj.flag = 3
  250. this.dataObj.remark3 = new Date().getTime()
  251. this.$api.doRequest('post', '/transactionExchangeInfo/editInfo', this.dataObj).then(res => {
  252. console.log(res)
  253. if (res.data.code == 200) {
  254. uni.navigateBack({
  255. delta: 1
  256. })
  257. } else {
  258. uni.showToast({
  259. title: "系统异常,请联系管理员",
  260. icon: 'none',
  261. duration: 2000
  262. })
  263. }
  264. })
  265. },
  266. selectAddress(val) {
  267. console.log(val)
  268. console.log(this.dataObj.tranType)
  269. if (!val.check) {
  270. uni.showToast({
  271. title: '地点必须选到区县一级',
  272. icon: 'none',
  273. duration: 2000
  274. })
  275. return
  276. }
  277. try {
  278. uni.setStorageSync('transactionPlace', val);
  279. this.dataObj.placeDelivery = val.address
  280. } catch (e) {
  281. // error
  282. }
  283. },
  284. radioChange(e) {
  285. // console.log(e);
  286. console.log(e);
  287. if (e == '销售') {
  288. this.placeTitle = '货源地'
  289. this.searchPlaceHolder = '选择货源地区'
  290. } else {
  291. this.placeTitle = '交货地'
  292. this.searchPlaceHolder = '选择交货地区'
  293. }
  294. },
  295. filterFileType(index, lists) {
  296. if (lists[index].fileType != 'jpg' && lists[index].fileType != 'png' && lists[index].fileType != 'gif') {
  297. lists.splice(index, 1);
  298. // 当前文件不支持
  299. uni.showModal({
  300. title: '暂不支持当前图片类型',
  301. showCancel: false
  302. });
  303. } else {
  304. this.isAdd = false;
  305. }
  306. },
  307. onRemove(index) {
  308. console.log("index", index)
  309. this.imgList.splice(index, 1)
  310. console.log(this.imgList)
  311. },
  312. getImgUrl(res) {
  313. console.log("this.businesslicense", this.businesslicense)
  314. console.log(res)
  315. console.log('------------res-----------')
  316. this.imgList.push(res)
  317. console.log(this.imgList)
  318. },
  319. onUploaded(lists) {
  320. this.filesArr = lists;
  321. let res = lists[0];
  322. if (res.response === undefined) {
  323. uni.showToast({
  324. title: '文件错误',
  325. icon: 'none'
  326. })
  327. }
  328. },
  329. },
  330. }
  331. </script>
  332. <style lang="scss" scoped>
  333. .content {
  334. // overflow: hidden;
  335. padding-bottom: 100rpx;
  336. }
  337. .content1 {
  338. background: #fff;
  339. margin: 20rpx;
  340. border-radius: 20rpx;
  341. padding-bottom: 40rpx;
  342. }
  343. /deep/.placeholder-class {
  344. color: #C5CAD4;
  345. font-size: 28rpx;
  346. }
  347. .textarea {
  348. padding: 20rpx 20rpx 50rpx 20rpx;
  349. width: 100%;
  350. font-size: 28rpx;
  351. }
  352. .top {
  353. position: relative;
  354. .number {
  355. position: absolute;
  356. right: 32rpx;
  357. bottom: 0;
  358. color: #C5CAD4;
  359. font-size: 26rpx;
  360. }
  361. }
  362. .content2 {
  363. padding: 20rpx;
  364. }
  365. /deep/.u-cell-item-box,
  366. /deep/.u-cell-box {
  367. border-radius: 20rpx;
  368. }
  369. .submit {
  370. margin: 40rpx auto;
  371. width: 654rpx;
  372. height: 92rpx;
  373. background: #22C572;
  374. border-radius: 46rpx;
  375. font-size: 34rpx;
  376. font-weight: 400;
  377. color: #FFFFFF;
  378. line-height: 92rpx;
  379. text-align: center;
  380. // position: fixed;
  381. // bottom: 76rpx;
  382. // left: 0;
  383. // right: 0;
  384. // margin: auto;
  385. }
  386. .edit-nickname {
  387. padding: 40rpx 80rpx;
  388. }
  389. .nickname-input {
  390. margin: 20rpx 0;
  391. }
  392. .nickname-btn {
  393. margin-top: 20rpx;
  394. }
  395. .row {
  396. display: flex;
  397. justify-content: space-between;
  398. position: relative;
  399. background: #fff;
  400. border-radius: 20rpx;
  401. input {
  402. font-size: 28rpx;
  403. // color: #333333;
  404. }
  405. .left {
  406. display: flex;
  407. align-items: center;
  408. color: #333333;
  409. font-size: 34rpx;
  410. font-weight: 600;
  411. }
  412. }
  413. .row_css {
  414. font-size: 26rpx;
  415. color: #333333;
  416. margin-top: 60rpx;
  417. font-weight: 500;
  418. }
  419. .textarea {
  420. background: #F9F9FA;
  421. font-size: 28rpx;
  422. text-align: left;
  423. width: 100%;
  424. padding: 30rpx 30rpx;
  425. border-radius: 5px;
  426. margin: 30rpx;
  427. height: 46vh;
  428. padding-bottom: 20rpx;
  429. color: #333;
  430. }
  431. .textarea textarea {
  432. height: 90%;
  433. }
  434. .textarea-left {
  435. position: absolute;
  436. bottom: 40rpx;
  437. left: 50rpx;
  438. color: #606266;
  439. }
  440. .textarea-bottom {
  441. position: absolute;
  442. bottom: 40rpx;
  443. right: 40rpx;
  444. color: #AFB3BF;
  445. }
  446. .clear {
  447. /* width: 90%; */
  448. // background: #ffffff;
  449. color: #22C572;
  450. // border: 1px solid #22C572;
  451. // border-radius: 50rpx;
  452. // font-size: 28rpx;
  453. // padding: 9rpx 24rpx;
  454. }
  455. </style>