index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <view class="container">
  3. <text class="title">问题类型</text>
  4. <view class="title-wrapper">
  5. <view v-for="(item, index) in typeList" @tap="tapType(item)" :key="index"
  6. :class="item.type_id == typeId ? 'text-wrapper text-wrapper-i' : 'text-wrapper text-wrapper-s'"
  7. >{{ item.type_name }}</view>
  8. </view>
  9. <view style="margin: 64rpx 0;">
  10. <view class="title">问题描述</view>
  11. <view class="text-description-input">
  12. <textarea :enableNative="false" @input="inputContent" :value="content"
  13. placeholder-class="description-placeholder" placeholder="请详细说明,以便我们解决问题,最多可填写300字。"
  14. maxlength="300"></textarea>
  15. </view>
  16. </view>
  17. <view>
  18. <view class="title-img">
  19. <view class="title-img-text">问题图片</view>
  20. <view class="img-text">{{ imgList.length }} / 3</view>
  21. </view>
  22. <view class="upload-img-row">
  23. <view class="upload-img-view" v-for="(item, index) in imgList" :key="index">
  24. <img @tap="bindChangeImg" :data-index="index" class="upload-img" :src="item" alt="">
  25. </view>
  26. <view class="upload-img-view" v-if="imgList.length < 3">
  27. <img @tap="bindUpImg" class="upload-img" src="https://qiniu.bms16.com/Fv3KFmim5gle_kWR9g1Mym56lJpC"
  28. alt="">
  29. </view>
  30. </view>
  31. </view>
  32. <view class="submit-btn-view">
  33. <view v-if="typeId != '' && imgList.length != 0 && content != ''" class="submit" @tap="submitFeedback">提交
  34. </view>
  35. <view v-else class="submit-btn">提交</view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. const http = require('../../common/http.js');
  41. const config = require('../../common/config.js');
  42. const common = require('../../common/common.js');
  43. export default {
  44. data() {
  45. return {
  46. typeList: [
  47. { type_id: 1, type_name: '车辆' },
  48. { type_id: 2, type_name: '电池' },
  49. { type_id: 3, type_name: '电柜' },
  50. { type_id: 4, type_name: '应用操作' },
  51. { type_id: 5, type_name: '其他' },
  52. ],
  53. typeId: '',
  54. content: '',
  55. imgList: [],
  56. isDiabled: false,
  57. };
  58. },
  59. /**
  60. * 生命周期函数--监听页面加载
  61. */
  62. onLoad: function (options) {
  63. // this.loadTypeList()
  64. },
  65. /**
  66. * 生命周期函数--监听页面显示
  67. */
  68. onShow: function () {
  69. },
  70. methods: {
  71. loadTypeList() {
  72. http.postApi(config.API_DAYHIRE_REPORT_REPORT_TYPE, {}, (resp) => {
  73. if (resp.data.code === 200) {
  74. this.setData({
  75. typeList: resp.data.data.list
  76. });
  77. } else {
  78. common.simpleToast(resp.data.msg)
  79. }
  80. })
  81. },
  82. tapType({ type_id }) {
  83. this.setData({
  84. typeId: type_id
  85. })
  86. },
  87. inputContent(e) {
  88. const content_text = e.detail.value
  89. if (content_text.length >= 300) {
  90. common.simpleToast('最多输入300字');
  91. } else {
  92. this.setData({
  93. content: content_text
  94. })
  95. }
  96. },
  97. bindUpImg: function () {
  98. const that = this;
  99. let _imgList = this.imgList
  100. common.upLoadImgQiNiu(function (imgUrl) {
  101. _imgList.push(imgUrl)
  102. that.setData({
  103. imgList: _imgList
  104. });
  105. });
  106. },
  107. bindChangeImg(e) {
  108. const that = this;
  109. const index = e.currentTarget.dataset.index
  110. let _imgList1 = this.imgList
  111. common.upLoadImgQiNiu(function (imgUrl) {
  112. _imgList1.splice(index, 1, imgUrl)
  113. that.setData({
  114. imgList: _imgList1
  115. });
  116. });
  117. },
  118. submitFeedback() {
  119. const imgs = this.imgList.join(',')
  120. const pData = {
  121. content: this.content,
  122. imgs: imgs,
  123. type_id: this.typeId
  124. }
  125. const that = this
  126. http.postApi(config.API_DAYHIRE_REPORT_REPORT, pData, (resp) => {
  127. if (resp.data.code === 200) {
  128. // that.setData({
  129. // isDiabled:true
  130. // })
  131. common.simpleToast('上传成功')
  132. setTimeout(() => {
  133. wx.navigateBack({
  134. delta: 1 // 返回上一级页面
  135. })
  136. }, 1000)
  137. } else {
  138. common.simpleToast(resp.data.msg)
  139. }
  140. })
  141. }
  142. }
  143. };
  144. </script>
  145. <style scoped lang="scss">
  146. .container {
  147. padding: 48rpx 32rpx 0;
  148. background-color: white;
  149. height: 100vh;
  150. }
  151. .title {
  152. font-size: 40rpx;
  153. color: #2A3A5A;
  154. font-weight: 600;
  155. margin-bottom: 40rpx;
  156. }
  157. .title-wrapper {
  158. display: flex;
  159. flex-wrap: wrap;
  160. margin-right: -32rpx;
  161. }
  162. .text-wrapper {
  163. padding: 24rpx 0;
  164. text-align: center;
  165. width: 218rpx;
  166. background: #F3F8FF;
  167. border-radius: 16rpx;
  168. margin: 0 16rpx 16rpx 0;
  169. font-size: 32rpx;
  170. border: 4rpx solid transparent
  171. }
  172. .text-wrapper-s {
  173. background-color: #F3F8FF;
  174. color: #2A3A5A;
  175. }
  176. .text-wrapper-i {
  177. color: #0A59F7;
  178. background: #FFFFFF;
  179. border-color: #0A59F7;
  180. }
  181. .text-description-input {
  182. background: #F3F8FF;
  183. padding-left: 32rpx;
  184. padding-top: 24rpx;
  185. }
  186. .description-placeholder {
  187. color: #828DA2;
  188. font-size: 28rpx;
  189. }
  190. .title-img {
  191. font-size: 40rpx;
  192. color: #2A3A5A;
  193. font-weight: 600;
  194. display: flex;
  195. justify-content: space-between;
  196. align-items: center;
  197. margin-bottom: 40rpx;
  198. }
  199. .img-text {
  200. font-size: 32rpx;
  201. color: #9FA7B7;
  202. font-weight: 400;
  203. }
  204. .upload-img-row {
  205. display: flex;
  206. justify-content: flex-start;
  207. flex-wrap: wrap;
  208. }
  209. .upload-img-view {
  210. margin-right: 20rpx;
  211. }
  212. .upload-img {
  213. width: 218rpx;
  214. height: 218rpx;
  215. }
  216. .submit-btn-view {
  217. border-top: 2rpx solid #F4F5F6;
  218. padding-top: 24rpx;
  219. position: fixed;
  220. bottom: 0;
  221. width: 93%
  222. }
  223. .submit-btn {
  224. background: #0074FF;
  225. opacity: 0.2;
  226. border-radius: 70rpx;
  227. color: #FFF;
  228. font-size: 32rpx;
  229. text-align: center;
  230. padding: 24rpx 0;
  231. margin: 0 0 24rpx 0;
  232. }
  233. .submit {
  234. background: #0074FF;
  235. border-radius: 40rpx;
  236. color: #FFF;
  237. font-size: 32rpx;
  238. text-align: center;
  239. padding: 24rpx 0;
  240. margin: 0 32rpx 24rpx 32rpx;
  241. }
  242. </style>