release.vue 10 KB

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