release.vue 7.4 KB

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