editRelease.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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 style="padding-left: 10rpx;">
  12. <upload :file-list='businesslicense' class="upload" ref="upload" :action="action" :max-size="maxSize"
  13. delIconSize='30' delBgColor='rgba(0,0,0,0.4)' delIcon="trash" :max-count="9"
  14. :size-type="['compressed']" @on-success="getImgUrl" @on-remove="onRemove"
  15. :before-upload="filterFileType"></upload>
  16. </view>
  17. </view>
  18. <view class="content2">
  19. <u-cell-group class='wrap'>
  20. <u-cell-item title="交易类型" :arrow="false" :title-style="titleStyle">
  21. <u-radio-group v-model="dataObj.tranType">
  22. <u-radio @change="radioChange" v-for="(item, index) in list" :key="index" :name="item.name"
  23. :disabled="item.disabled" active-color="#303030">
  24. {{item.name}}
  25. </u-radio>
  26. </u-radio-group>
  27. </u-cell-item>
  28. <u-cell-item title="交易地" :title-style="titleStyle">
  29. <selectAddress @selectAddress='selectAddress' series='3' :textStyle='textStyle' :edit='true'
  30. :text='dataObj.placeDelivery'></selectAddress>
  31. </u-cell-item>
  32. <u-cell-item title="发布者昵称" :title-style="titleStyle" :border-bottom='false' @click="editNicknamee">
  33. <view :style='textStyle'>
  34. {{dataObj.publisher}}
  35. </view>
  36. <!-- <selectAddress @selectAddress='selectAddress' series='3' :textStyle='textStyle'></selectAddress> -->
  37. </u-cell-item>
  38. </u-cell-group>
  39. </view>
  40. <view class="submit" @click="submit">
  41. 发布
  42. </view>
  43. <u-popup v-model="showNickname" mode='center' border-radius="14" width='70%' @close='closePopup'>
  44. <view class="edit-nickname">
  45. <view>昵称长度限制在2-24个字符内</view>
  46. <u-input v-model="dataObj.publisher" border class='nickname-input' />
  47. <view style="text-align: center;">
  48. <u-button type="success" size="medium" class="nickname-btn" @click="nickNamesubmit">保存</u-button>
  49. </view>
  50. </view>
  51. </u-popup>
  52. </view>
  53. </template>
  54. <script>
  55. import upload from '@/components/upload_small.vue';
  56. import selectAddress from "@/components/selectAddress.vue"
  57. import {
  58. mapState
  59. } from 'vuex';
  60. export default {
  61. components: {
  62. upload,
  63. selectAddress
  64. },
  65. data() {
  66. return {
  67. id: '',
  68. imgList: [],
  69. showNickname: false,
  70. dataObj: {
  71. userId: '',
  72. tranType: '采购',
  73. placeDelivery: '',
  74. urlImg: '',
  75. publishingContent: '',
  76. publisher: '',
  77. },
  78. titleStyle: {
  79. "font-size": "28rpx",
  80. "color": "#333333",
  81. // "font-weight": 700
  82. },
  83. textStyle: {
  84. "font-size": "32rpx",
  85. "font-weight": 700,
  86. "color": "#333333",
  87. "margin-right": '27rpx'
  88. },
  89. list: [{
  90. name: '采购',
  91. disabled: false
  92. },
  93. {
  94. name: '销售',
  95. disabled: false
  96. }
  97. ],
  98. businesslicense: [],
  99. value: '',
  100. action: this.$uploadUrl,
  101. maxSize: 50 * 1024 * 1024, //限制文件大小 50M
  102. isAdd: false,
  103. };
  104. },
  105. onLoad(options) {
  106. this.id = options.id
  107. console.log(this.id)
  108. this.init()
  109. // this.dataObj.userId = this.userInfo.id
  110. // this.dataObj.publisher = this.userInfo.wechatNo
  111. },
  112. onNavigationBarButtonTap(e) {
  113. console.log(e)
  114. uni.navigateTo({
  115. url: 'record'
  116. })
  117. },
  118. computed: {
  119. ...mapState(['hasLogin', 'userInfo', 'clientId']),
  120. },
  121. methods: {
  122. init() {
  123. let _obj = {
  124. id: this.id
  125. }
  126. uni.showLoading({
  127. title: '数据加载中',
  128. mask: true
  129. })
  130. this.$api.doRequest('get', '/transactionExchangeInfo/selectExchangeInfo', _obj).then(res => {
  131. console.log(res.data)
  132. if (res.data.code == 200) {
  133. this.dataObj = res.data.data
  134. this.imgList = res.data.data.urlImg.split(',')
  135. for (let i = 0; i < this.imgList.length; i++) {
  136. this.businesslicense.push({
  137. url: this.imgList[i]
  138. })
  139. }
  140. console.log("this.businesslicense", this.businesslicense)
  141. }
  142. uni.hideLoading()
  143. })
  144. },
  145. closePopup() {
  146. this.dataObj.publisher = this.userInfo.wechatNo
  147. },
  148. nickNamesubmit() {
  149. if (this.dataObj.publisher == null || this.dataObj.publisher == "") {
  150. this.$api.msg('请输入昵称!')
  151. return
  152. }
  153. if (this.dataObj.publisher.length < 2 || this.dataObj.publisher.length > 24) {
  154. this.$api.msg('请正确输入昵称!')
  155. return
  156. }
  157. let _obj = {
  158. wechatNo: this.dataObj.publisher,
  159. id: this.userInfo.id
  160. }
  161. uni.showLoading({
  162. title: '数据加载中',
  163. mask: true
  164. })
  165. let that = this
  166. that.$api.doRequest('post', '/commonUser/editUserInfo', _obj).then(
  167. res => {
  168. if (res.data.code == 200) {
  169. uni.showToast({
  170. title: '修改成功!',
  171. icon: 'success',
  172. duration: 2000,
  173. success() {
  174. setTimeout(() => {
  175. var _student = uni.getStorageSync('userInfo');
  176. _student.wechatNo = that.dataObj.publisher;
  177. uni.setStorageSync('userInfo', _student);
  178. var name = 'userInfo';
  179. var value = _student;
  180. that.$store.commit('$uStore', {
  181. name,
  182. value
  183. });
  184. uni.hideLoading()
  185. that.showNickname = false
  186. }, 2000)
  187. }
  188. })
  189. }
  190. })
  191. .catch(res => {
  192. if (res.errmsg) {
  193. uni.showToast({
  194. title: res.errmsg,
  195. icon: 'none',
  196. duration: 2000
  197. })
  198. } else {
  199. uni.showToast({
  200. title: "系统异常,请联系管理员",
  201. icon: 'none',
  202. duration: 2000
  203. })
  204. }
  205. });
  206. },
  207. editNicknamee() {
  208. this.showNickname = true
  209. },
  210. submit() {
  211. uni.showLoading({
  212. title: '数据加载中',
  213. mask: true
  214. })
  215. this.dataObj.urlImg = this.imgList.toString()
  216. this.$api.doRequest('post', '/transactionExchangeInfo/editInfo', this.dataObj).then(res => {
  217. console.log(res)
  218. if (res.data.code == 200) {
  219. uni.navigateBack({
  220. delta: 1
  221. })
  222. } else {
  223. uni.showToast({
  224. title: "系统异常,请联系管理员",
  225. icon: 'none',
  226. duration: 2000
  227. })
  228. }
  229. })
  230. },
  231. selectAddress(val) {
  232. console.log(val)
  233. this.dataObj.placeDelivery = val
  234. },
  235. radioChange(e) {
  236. // console.log(e);
  237. },
  238. filterFileType(index, lists) {
  239. if (lists[index].fileType != 'jpg' && lists[index].fileType != 'png' && lists[index].fileType != 'gif') {
  240. lists.splice(index, 1);
  241. // 当前文件不支持
  242. uni.showModal({
  243. title: '暂不支持当前图片类型',
  244. showCancel: false
  245. });
  246. } else {
  247. this.isAdd = false;
  248. }
  249. },
  250. onRemove(index) {
  251. console.log("index", index)
  252. this.imgList.splice(index, 1)
  253. console.log(this.imgList)
  254. },
  255. getImgUrl(res) {
  256. console.log("this.businesslicense", this.businesslicense)
  257. console.log(res)
  258. console.log('------------res-----------')
  259. this.imgList.push(res)
  260. console.log(this.imgList)
  261. },
  262. onUploaded(lists) {
  263. this.filesArr = lists;
  264. let res = lists[0];
  265. if (res.response === undefined) {
  266. uni.showToast({
  267. title: '文件错误',
  268. icon: 'none'
  269. })
  270. }
  271. },
  272. },
  273. }
  274. </script>
  275. <style lang="scss" scoped>
  276. .content {
  277. // overflow: hidden;
  278. }
  279. .content1 {
  280. background: #fff;
  281. margin: 20rpx;
  282. border-radius: 20rpx;
  283. padding-bottom: 40rpx;
  284. }
  285. /deep/.placeholder-class {
  286. color: #C5CAD4;
  287. font-size: 28rpx;
  288. }
  289. .textarea {
  290. padding: 20rpx 20rpx 50rpx 20rpx;
  291. width: 100%;
  292. font-size: 28rpx;
  293. }
  294. .top {
  295. position: relative;
  296. .number {
  297. position: absolute;
  298. right: 32rpx;
  299. bottom: 0;
  300. color: #C5CAD4;
  301. font-size: 26rpx;
  302. }
  303. }
  304. .content2 {
  305. padding: 20rpx;
  306. }
  307. /deep/.u-cell-item-box,
  308. /deep/.u-cell-box {
  309. border-radius: 20rpx;
  310. }
  311. .submit {
  312. width: 654rpx;
  313. height: 92rpx;
  314. background: #22C572;
  315. border-radius: 46rpx;
  316. font-size: 34rpx;
  317. font-weight: 400;
  318. color: #FFFFFF;
  319. line-height: 92rpx;
  320. text-align: center;
  321. position: fixed;
  322. bottom: 76rpx;
  323. left: 0;
  324. right: 0;
  325. margin: auto;
  326. }
  327. .edit-nickname {
  328. padding: 40rpx 80rpx;
  329. }
  330. .nickname-input {
  331. margin: 20rpx 0;
  332. }
  333. .nickname-btn {
  334. margin-top: 20rpx;
  335. }
  336. </style>