shaitu.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view class="shaitu">
  3. <!-- <view class="shaitu_head flex">
  4. <image src="/static/image/publice/fanhui@2x.png" mode="" @click="retutnTop"></image>
  5. <text>提交晒图</text>
  6. <view></view>
  7. </view> -->
  8. <view class="shaitu_ul">
  9. <view class="shaitu_li">
  10. <view class="shaitu_name">描述</view>
  11. <view class="shaitu_ipt shaitu_ipts flex">
  12. <textarea placeholder="请输入描述" v-model="formData.box_zw" placeholder-style="color:#999999" maxlength="-1"></textarea>
  13. </view>
  14. </view>
  15. <view class="shaitu_li">
  16. <view class="shaitu_name">图片</view>
  17. <uni-file-picker
  18. v-model="imageValue"
  19. file-mediatype="image"
  20. mode="grid"
  21. file-extname="png,jpg,jpeg"
  22. :limit="3"
  23. @success="success"
  24. @fail="fail"
  25. @select="selectImg"
  26. />
  27. </view>
  28. </view>
  29. <button class="shaitu_btn" hover-class="hover-view" @click="submit">提交晒图</button>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. return {
  36. formData: {
  37. token: uni.getStorageSync('token'),
  38. box_zw: '',
  39. box_img:'',
  40. },
  41. imageValue: [],
  42. flag:true,//
  43. shaitu:'',
  44. };
  45. },
  46. methods:{
  47. retutnTop () {
  48. uni.navigateBack()
  49. },
  50. //选择图片
  51. selectImg(imgList){
  52. this.imageValue.push(...imgList.tempFiles)
  53. },
  54. async submit () {
  55. if (!this.flag) return
  56. if (!this.formData.box_zw) return uni.showToast({title:'请输入描述',icon:'none'})
  57. if (!this.imageValue || this.imageValue.length < 1) return uni.showToast({title:'请上传图片',icon:'none'})
  58. //上传图片
  59. let imgUrlList = []
  60. for(let i = 0 ; i < this.imageValue.length ; i++){
  61. const img = this.imageValue[i]
  62. const res = await this.$api.upload_image({path: img.path})
  63. imgUrlList.push(res.url)
  64. }
  65. this.formData.box_img = imgUrlList.join(",")
  66. this.flag = false
  67. uni.showLoading({title:'数据提交中'})
  68. this.$api.setShai(this.formData).then(res=>{
  69. uni.hideLoading()
  70. if (res.code === 1) {
  71. uni.showToast({title: '提交成功!'})
  72. setTimeout(()=>{
  73. this.retutnTop()
  74. }, 800)
  75. } else {
  76. this.flag = true
  77. }
  78. })
  79. }
  80. },
  81. onLoad () {
  82. },
  83. onShow() {
  84. }
  85. }
  86. </script>
  87. <style lang="scss">
  88. .shaitu_head {
  89. width: 100%;
  90. height: 88rpx;
  91. padding: 0 30rpx;
  92. background: #FFFFFF;
  93. image {
  94. width: 44rpx;
  95. height: 44rpx;
  96. }
  97. text {
  98. font-size: 36rpx;
  99. font-weight: bold;
  100. }
  101. }
  102. .shaitu_ul {
  103. padding: 20rpx 30rpx 0 30rpx;
  104. .shaitu_li {
  105. .shaitu_name {
  106. font-size: 30rpx;
  107. font-weight: bold;
  108. padding: 30rpx 0;
  109. }
  110. .shaitu_ipt {
  111. height: 80rpx;
  112. padding: 0 30rpx;
  113. background: #FFFFFF;
  114. border-radius: 10rpx;
  115. input {
  116. font-size: 28rpx;
  117. }
  118. image {
  119. width: 22rpx;
  120. height: 22rpx;
  121. }
  122. }
  123. .shaitu_ipts {
  124. padding: 30rpx;
  125. height: 160rpx;
  126. textarea {
  127. font-size: 28rpx;
  128. }
  129. }
  130. }
  131. }
  132. .shaitu_btn {
  133. width: 690rpx;
  134. height: 98rpx;
  135. color: #333333;
  136. margin: 20rpx auto;
  137. font-size: 30rpx;
  138. font-weight: bold;
  139. background: #FFFFFF;
  140. box-shadow: 0rpx 0rpx 121rpx 0rpx rgba(63, 52, 2, 0.12);
  141. border-radius: 10rpx;
  142. }
  143. </style>