瑶都万能墙
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

343 lines
6.4 KiB

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
  1. <template>
  2. <view class="publishPost">
  3. <navbar
  4. leftClick
  5. @leftClick="$utils.navigateBack"
  6. title="发布动态"/>
  7. <view class="title-input box">
  8. <input type="text" placeholder="添加标题" v-model="form.title"/>
  9. </view>
  10. <view class="content-input">
  11. <uv-textarea
  12. v-model="form.content"
  13. :maxlength="200"
  14. autoHeight
  15. count
  16. placeholder="添加正文"></uv-textarea>
  17. </view>
  18. <view class="images box">
  19. <uv-upload
  20. :fileList="fileList"
  21. :maxCount="4"
  22. multiple
  23. width="150rpx"
  24. height="150rpx"
  25. @delete="deleteImage"
  26. @afterRead="afterRead"
  27. :previewFullImage="true"></uv-upload>
  28. </view>
  29. <!-- <view class="upTop"
  30. >
  31. <view class="title">
  32. <uv-icon name="pushpin-fill"></uv-icon>
  33. 是否置顶
  34. </view>
  35. <uv-radio-group v-model="form.topId">
  36. <view class="list">
  37. <view class="item">
  38. <view class="left">
  39. 不需要置顶
  40. </view>
  41. <view class="right">
  42. <uv-radio
  43. size="35rpx"
  44. icon-size="35rpx"
  45. :disabled="!!id"
  46. :name="0">
  47. </uv-radio>
  48. </view>
  49. </view>
  50. <view class="item"
  51. v-for="(item, index) in upTopList"
  52. :key="index">
  53. <view class="left">
  54. 置顶{{ item.day }}{{ item.money }}
  55. </view>
  56. <view class="right">
  57. <uv-radio
  58. size="35rpx"
  59. :disabled="!!id"
  60. icon-size="35rpx"
  61. :name="item.id">
  62. </uv-radio>
  63. </view>
  64. </view>
  65. </view>
  66. </uv-radio-group>
  67. </view> -->
  68. <view class="configBtn"
  69. @click="$refs.configPopup.open('getPublishPostNotice')">
  70. 发布须知
  71. </view>
  72. <!-- <submit
  73. @submit="submit"
  74. @preview="preview"
  75. @draft="draft"
  76. :submitTitle="id ? '修改帖子' : '发布帖子'"
  77. /> -->
  78. <configPopup
  79. ref="configPopup"
  80. />
  81. </view>
  82. </template>
  83. <script>
  84. // import submit from '@/components/content/submit.vue'
  85. export default {
  86. components : {
  87. // submit,
  88. },
  89. data() {
  90. return {
  91. upTopList : [],
  92. form : {
  93. // image : [],
  94. content : '',
  95. topId : 0,
  96. title : '',
  97. },
  98. fileList: [
  99. // {
  100. // url: 'https://cdn.uviewui.com/uview/swiper/2.jpg'
  101. // },
  102. ],
  103. id : 0,
  104. };
  105. },
  106. computed : {
  107. topInfo(){
  108. for (var i = 0; i < this.upTopList.length; i++) {
  109. if(this.upTopList[i].id == this.form.topId){
  110. return this.upTopList[i]
  111. }
  112. }
  113. return {}
  114. },
  115. },
  116. onLoad(args) {
  117. this.id = args.id
  118. },
  119. onShow() {
  120. this.indexTopPayList()
  121. this.getDateil()
  122. },
  123. methods : {
  124. getDateil(){
  125. if(!this.id){
  126. return
  127. }
  128. let self = this
  129. this.$api('indexGetTrendsDetail', {
  130. id : this.id
  131. }, res => {
  132. if (res.code == 200) {
  133. res.result.details.image.split(',')
  134. .forEach(url => {
  135. self.fileList.push({
  136. url
  137. })
  138. })
  139. res.result.details.topId = res.result.details.topId || 0
  140. this.form = res.result.details
  141. }
  142. })
  143. },
  144. deleteImage(e){
  145. this.fileList.splice(e.index, 1)
  146. },
  147. afterRead(e){
  148. let self = this
  149. e.file.forEach(file => {
  150. self.$Oss.ossUpload(file.url).then(url => {
  151. self.fileList.push({
  152. url
  153. })
  154. })
  155. })
  156. },
  157. indexTopPayList(){
  158. this.$api('indexTopPayList', res => {
  159. if(res.code == 200){
  160. this.upTopList = res.result
  161. }
  162. })
  163. },
  164. // 发起支付
  165. payOrder(){
  166. let self = this
  167. let data = {
  168. // ...this.form,
  169. content : this.form.content,
  170. topId : this.form.topId,
  171. title : this.form.title,
  172. isCard : 'Y',
  173. state : 0,
  174. image : this.fileList.map((item) => item.url).join(","),
  175. isTop : this.form.topId ? 'Y' : 'N',
  176. }
  177. if(this.id){
  178. data.id = this.id
  179. }
  180. this.$api('infoReleaseTrends', data,
  181. res => {
  182. if(res.code == 200){
  183. if(self.form.topId && !this.id){
  184. uni.requestPayment({
  185. provider: 'wxpay', // 服务提提供商
  186. timeStamp: res.result.timeStamp, // 时间戳
  187. nonceStr: res.result.nonceStr, // 随机字符串
  188. package: res.result.packageValue,
  189. signType: res.result.signType, // 签名算法
  190. paySign: res.result.paySign, // 签名
  191. success: function (res) {
  192. console.log('支付成功',res);
  193. self.$refs.confirmationPopupUpload.open()
  194. // self.$refs.confirmationPopup.close()
  195. },
  196. fail: function (err) {
  197. console.log('支付失败',err);
  198. self.$refs.confirmationPopup.close()
  199. uni.showToast({
  200. icon:'none',
  201. title:"支付失败"
  202. })
  203. }
  204. });
  205. }else{
  206. self.$refs.confirmationPopupUpload.open()
  207. }
  208. }
  209. })
  210. },
  211. // 提交
  212. submit(){
  213. if(this.fileList.length == 0){
  214. return uni.showToast({
  215. title: '请上传图片',
  216. icon : 'none'
  217. })
  218. }
  219. if (this.$utils.verificationAll(this.form, {
  220. title: '请输入标题',
  221. content: '请输入正文',
  222. })) {
  223. return
  224. }
  225. if(this.form.topId && !this.id){
  226. // 选择付费模式
  227. this.$refs.confirmationPopup.open()
  228. }else{
  229. // 没有选择付费
  230. this.payOrder()
  231. }
  232. },
  233. preview(){},
  234. draft(){},
  235. }
  236. }
  237. </script>
  238. <style lang="scss" scoped>
  239. .publishPost{
  240. background-color: #fff;
  241. min-height: 100vh;
  242. font-size: 28rpx;
  243. padding-bottom: 150rpx;
  244. /deep/ .uv-textarea{
  245. background-color: transparent;
  246. border: none;
  247. }
  248. /deep/ .uv-textarea__count{
  249. background-color: transparent !important;
  250. }
  251. .box{
  252. padding: 0 20rpx;
  253. }
  254. .images{
  255. display: flex;
  256. flex-wrap: wrap;
  257. padding: 20rpx;
  258. }
  259. .title-input{
  260. border-bottom: 1px solid #00000015;
  261. padding-bottom: 25rpx;
  262. margin-bottom: 15rpx;
  263. }
  264. .content-input{
  265. min-height: 400rpx;
  266. }
  267. .upTop{
  268. .title{
  269. padding-top: 20rpx;
  270. padding-left: 20rpx;
  271. border-top: 1px solid #00000015;
  272. display: flex;
  273. align-items: center;
  274. }
  275. .list{
  276. padding-top: 30rpx;
  277. width: 100%;
  278. .item{
  279. display: flex;
  280. padding: 20rpx;
  281. padding-left: 80rpx;
  282. justify-content: space-between;
  283. width: 600rpx;
  284. border-bottom: 1px solid #00000015;
  285. align-items: center;
  286. }
  287. }
  288. }
  289. .configBtn{
  290. padding: 20rpx;
  291. color: #777;
  292. padding-top: 40rpx;
  293. font-size: 28rpx;
  294. }
  295. .confirmationPopup{
  296. display: flex;
  297. flex-direction: column;
  298. align-items: center;
  299. justify-content: center;
  300. width: 100%;
  301. height: 300rpx;
  302. image{
  303. margin-top: 40rpx;
  304. }
  305. .info{
  306. margin-top: 40rpx;
  307. font-size: 26rpx;
  308. }
  309. }
  310. }
  311. </style>