postMessage.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <view>
  3. <u-navbar back-text="发布信息" back-icon-size="28" back-icon-color="#ffffff" :background="{backgroundColor: '#2795FD',}"
  4. :back-text-style="{color: '#ffffff'}"></u-navbar>
  5. <!-- 发布标题 -->
  6. <view class="post-title">
  7. <view class="title">
  8. 发布标题
  9. </view>
  10. <view class="title-content">
  11. <input v-model="form.title" class="input" type="text" value="" placeholder="请填写标题内容" />
  12. </view>
  13. <!-- 类型选择 -->
  14. <view class="type">
  15. <view class="name">
  16. <text>*</text>共享类型
  17. </view>
  18. <!-- 单选框 -->
  19. <u-radio-group v-model="form.type">
  20. <u-radio v-for="(item, index) in list" :key="index" :name="item.type"
  21. :disabled="item.disabled">
  22. {{item.name}}
  23. </u-radio>
  24. </u-radio-group>
  25. </view>
  26. </view>
  27. <!-- 内容描述 -->
  28. <view class="content-description">
  29. <view class="title">
  30. 内容描述
  31. </view>
  32. <view class="content-textarea">
  33. <textarea v-model="form.content" class="textarea" value="" placeholder="请描述共享用工需求内容,并留下您的联系方式。" />
  34. </view>
  35. </view>
  36. <!-- 底部按钮 -->
  37. <button class="btn" @click="publishInformation">发布信息</button>
  38. </view>
  39. </template>
  40. <script>
  41. import * as API_packages from '@/apis/pagejs/packages.js'
  42. export default {
  43. data() {
  44. return {
  45. list: [{
  46. name: '急需用工',
  47. type: '1',
  48. disabled: false
  49. },
  50. {
  51. name: '资源共享',
  52. type: '2',
  53. disabled: false
  54. },
  55. ],
  56. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  57. form: {
  58. id: '',
  59. type: '1',
  60. title: '',
  61. content: ''
  62. },
  63. current: 0
  64. };
  65. },
  66. onLoad(op) {
  67. if(op.id) {
  68. this.form.id = op.id;
  69. this.getShareWorksDetail();
  70. }
  71. },
  72. methods: {
  73. getShareWorksDetail() {
  74. uni.showLoading({
  75. title: "加载中",
  76. mask: true,
  77. })
  78. API_packages.shareWorksDetail({id: this.form.id}).then((res) => {
  79. this.form = res.data.shareWorksInfo;
  80. uni.hideLoading();
  81. }).catch(error => {
  82. uni.showToast({icon: 'none',
  83. title: error,
  84. icon: "none"
  85. })
  86. })
  87. },
  88. publishInformation() {
  89. if(!this.form.title) {
  90. uni.showToast({icon: 'none',
  91. title: "请填写标题内容",
  92. icon: "none"
  93. })
  94. return
  95. }
  96. if(!this.form.content) {
  97. uni.showToast({icon: 'none',
  98. title: "请描述共享用工需求内容",
  99. icon: "none"
  100. })
  101. return
  102. }
  103. uni.showLoading({
  104. title: "加载中",
  105. mask: true,
  106. })
  107. API_packages.createShareWork(this.form).then((res) => {
  108. uni.hideLoading();
  109. const eventChannel = this.getOpenerEventChannel();
  110. eventChannel.emit('refreshData');
  111. uni.navigateBack()
  112. }).catch(error => {
  113. uni.showToast({icon: 'none',
  114. title: error,
  115. icon: "none"
  116. })
  117. })
  118. }
  119. }
  120. };
  121. </script>
  122. <style>
  123. page {
  124. background: #F0F0F2;
  125. padding-bottom: 50px;
  126. }
  127. </style>
  128. <style scoped lang="scss">
  129. // 发布标题
  130. .post-title {
  131. margin: 24rpx 32rpx 0;
  132. padding: 24rpx 32rpx;
  133. color: rgba(16, 16, 16, 1);
  134. font-size: 36rpx;
  135. background-color: #fff;
  136. border-radius: 24rpx;
  137. .title {
  138. font-family: 'PingFangSC-medium';
  139. }
  140. .title-content {
  141. .input {
  142. width: 100%;
  143. height: 96rpx;
  144. line-height: 96rpx;
  145. color: rgba(136, 136, 136, 1);
  146. font-family: Microsoft Yahei;
  147. }
  148. }
  149. // 类型选择
  150. .type {
  151. display: flex;
  152. align-items: center;
  153. margin-top: 16rpx;
  154. .name {
  155. font-size: 32rpx;
  156. color: #101010;
  157. margin-right: 40rpx;
  158. text {
  159. color: #EE3138
  160. }
  161. }
  162. }
  163. }
  164. // 内容描述
  165. .content-description {
  166. margin: 24rpx 32rpx 0;
  167. padding: 24rpx 32rpx;
  168. color: rgba(16, 16, 16, 1);
  169. font-size: 36rpx;
  170. background-color: #fff;
  171. border-radius: 24rpx;
  172. .title {
  173. font-family: 'PingFangSC-medium';
  174. }
  175. .content-textarea {
  176. margin-top: 24rpx;
  177. .textarea {
  178. width: 100%;
  179. height: 640rpx;
  180. color: rgba(136, 136, 136, 1);
  181. font-family: Microsoft Yahei;
  182. line-height: 40rpx;
  183. }
  184. }
  185. }
  186. // 底部按钮
  187. .btn {
  188. position: fixed;
  189. bottom: 32rpx;
  190. left: 0;
  191. right: 0;
  192. background-color: #F0F0F2;
  193. padding: 0 32rpx;
  194. border-radius: 50px;
  195. background-color: rgba(34, 149, 255, 1);
  196. color: rgba(241, 241, 241, 1);
  197. font-size: 36rpx;
  198. margin: 0 32rpx;
  199. box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.03);
  200. }
  201. </style>