editRelease.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  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.$api.doRequest('post', '/transactionExchangeInfo/editInfo', this.dataObj).then(res => {
  251. console.log(res)
  252. if (res.data.code == 200) {
  253. uni.navigateBack({
  254. delta: 1
  255. })
  256. } else {
  257. uni.showToast({
  258. title: "系统异常,请联系管理员",
  259. icon: 'none',
  260. duration: 2000
  261. })
  262. }
  263. })
  264. },
  265. selectAddress(val) {
  266. console.log(val)
  267. console.log(this.dataObj.tranType)
  268. if (!val.check) {
  269. uni.showToast({
  270. title: '地点必须选到区县一级',
  271. icon: 'none',
  272. duration: 2000
  273. })
  274. return
  275. }
  276. try {
  277. uni.setStorageSync('transactionPlace', val);
  278. this.dataObj.placeDelivery = val.address
  279. } catch (e) {
  280. // error
  281. }
  282. },
  283. radioChange(e) {
  284. // console.log(e);
  285. console.log(e);
  286. if (e == '销售') {
  287. this.placeTitle = '货源地'
  288. this.searchPlaceHolder = '选择货源地区'
  289. } else {
  290. this.placeTitle = '交货地'
  291. this.searchPlaceHolder = '选择交货地区'
  292. }
  293. },
  294. filterFileType(index, lists) {
  295. if (lists[index].fileType != 'jpg' && lists[index].fileType != 'png' && lists[index].fileType != 'gif') {
  296. lists.splice(index, 1);
  297. // 当前文件不支持
  298. uni.showModal({
  299. title: '暂不支持当前图片类型',
  300. showCancel: false
  301. });
  302. } else {
  303. this.isAdd = false;
  304. }
  305. },
  306. onRemove(index) {
  307. console.log("index", index)
  308. this.imgList.splice(index, 1)
  309. console.log(this.imgList)
  310. },
  311. getImgUrl(res) {
  312. console.log("this.businesslicense", this.businesslicense)
  313. console.log(res)
  314. console.log('------------res-----------')
  315. this.imgList.push(res)
  316. console.log(this.imgList)
  317. },
  318. onUploaded(lists) {
  319. this.filesArr = lists;
  320. let res = lists[0];
  321. if (res.response === undefined) {
  322. uni.showToast({
  323. title: '文件错误',
  324. icon: 'none'
  325. })
  326. }
  327. },
  328. },
  329. }
  330. </script>
  331. <style lang="scss" scoped>
  332. .content {
  333. // overflow: hidden;
  334. padding-bottom: 100rpx;
  335. }
  336. .content1 {
  337. background: #fff;
  338. margin: 20rpx;
  339. border-radius: 20rpx;
  340. padding-bottom: 40rpx;
  341. }
  342. /deep/.placeholder-class {
  343. color: #C5CAD4;
  344. font-size: 28rpx;
  345. }
  346. .textarea {
  347. padding: 20rpx 20rpx 50rpx 20rpx;
  348. width: 100%;
  349. font-size: 28rpx;
  350. }
  351. .top {
  352. position: relative;
  353. .number {
  354. position: absolute;
  355. right: 32rpx;
  356. bottom: 0;
  357. color: #C5CAD4;
  358. font-size: 26rpx;
  359. }
  360. }
  361. .content2 {
  362. padding: 20rpx;
  363. }
  364. /deep/.u-cell-item-box,
  365. /deep/.u-cell-box {
  366. border-radius: 20rpx;
  367. }
  368. .submit {
  369. margin: 40rpx auto;
  370. width: 654rpx;
  371. height: 92rpx;
  372. background: #22C572;
  373. border-radius: 46rpx;
  374. font-size: 34rpx;
  375. font-weight: 400;
  376. color: #FFFFFF;
  377. line-height: 92rpx;
  378. text-align: center;
  379. // position: fixed;
  380. // bottom: 76rpx;
  381. // left: 0;
  382. // right: 0;
  383. // margin: auto;
  384. }
  385. .edit-nickname {
  386. padding: 40rpx 80rpx;
  387. }
  388. .nickname-input {
  389. margin: 20rpx 0;
  390. }
  391. .nickname-btn {
  392. margin-top: 20rpx;
  393. }
  394. .row {
  395. display: flex;
  396. justify-content: space-between;
  397. position: relative;
  398. background: #fff;
  399. border-radius: 20rpx;
  400. input {
  401. font-size: 28rpx;
  402. // color: #333333;
  403. }
  404. .left {
  405. display: flex;
  406. align-items: center;
  407. color: #333333;
  408. font-size: 34rpx;
  409. font-weight: 600;
  410. }
  411. }
  412. .row_css {
  413. font-size: 26rpx;
  414. color: #333333;
  415. margin-top: 60rpx;
  416. font-weight: 500;
  417. }
  418. .textarea {
  419. background: #F9F9FA;
  420. font-size: 28rpx;
  421. text-align: left;
  422. width: 100%;
  423. padding: 30rpx 30rpx;
  424. border-radius: 5px;
  425. margin: 30rpx;
  426. height: 46vh;
  427. padding-bottom: 20rpx;
  428. color: #333;
  429. }
  430. .textarea textarea {
  431. height: 90%;
  432. }
  433. .textarea-left {
  434. position: absolute;
  435. bottom: 40rpx;
  436. left: 50rpx;
  437. color: #606266;
  438. }
  439. .textarea-bottom {
  440. position: absolute;
  441. bottom: 40rpx;
  442. right: 40rpx;
  443. color: #AFB3BF;
  444. }
  445. .clear {
  446. /* width: 90%; */
  447. // background: #ffffff;
  448. color: #22C572;
  449. // border: 1px solid #22C572;
  450. // border-radius: 50rpx;
  451. // font-size: 28rpx;
  452. // padding: 9rpx 24rpx;
  453. }
  454. </style>