release.vue 7.6 KB

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