洛阳学员端
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.

234 lines
5.4 KiB

10 months ago
10 months ago
  1. <template>
  2. <view class="pageBgImg">
  3. <topNavbar title="我要咨询"></topNavbar>
  4. <view class="pad">
  5. <view class="card">
  6. <view class="h2">咨询内容</view>
  7. <view class="textareaBg">
  8. <view class="flex">
  9. <view class="icon">
  10. <image src="@/static/images/index/edit.png" mode=""></image>
  11. </view>
  12. <view class="inputBox">
  13. <u-textarea v-model.trim="value" ref="textarea" placeholder="详细说明问题,以便获得更好的回答~"></u-textarea>
  14. </view>
  15. </view>
  16. <view class="phoneBox">
  17. <view class="imgBox">
  18. <view class="img" v-for="(item,index) in imgArr" :key="item">
  19. <view class="minusCircle" @click="deleteImg(item,index)">
  20. <u-icon name="close-circle-fill" size="20" color="#b9061d"></u-icon>
  21. </view>
  22. <image :src="item" mode=""></image>
  23. </view>
  24. </view>
  25. <view class="phone" @click="chooseImages" v-if="imgArr.length<3">
  26. <view class="phoneIcon">
  27. <image src="@/static/images/index/btn_tupian.png" mode=""></image>
  28. </view>
  29. <view class="lab">添加图片</view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="card" style="padding-bottom: 0; margin-top: 24rpx;">
  35. <view class="phone_row">
  36. <view class="label">联系电话</view>
  37. <view class="uInput my">{{ vuex_userInfo.phone }}</view>
  38. </view>
  39. </view>
  40. <view class="btn" :class="{active: value.length}" @click="submintFn">提交</view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import { createconsult } from '@/config/api.js'
  46. import { uploadImgApi } from '@/config/utils.js'
  47. // let url = 'api'
  48. export default {
  49. data() {
  50. return {
  51. value: '',
  52. imgArr: [],
  53. }
  54. },
  55. onLoad() {
  56. },
  57. methods: {
  58. async submintFn() {
  59. let images = this.imgArr.join(',')
  60. if(!this.value.trim()) return this.$u.toast('请输入内容')
  61. let obj = {
  62. images,
  63. studentPhone: this.vuex_userInfo.phone,
  64. type: 1,
  65. studentId: this.studentId,
  66. content: this.value
  67. }
  68. const {data: res} = await createconsult(obj)
  69. this.$u.toast('发布成功')
  70. this.value = ''
  71. this.imgArr = []
  72. setTimeout(()=>{
  73. this.$goPage('/pages/indexEntry/consult/record/record?tab=1')
  74. },1500)
  75. },
  76. deleteImg(item) {
  77. let index = this.imgArr.findIndex(val=>val==item)
  78. this.imgArr.splice(index, 1)
  79. },
  80. //选择图片
  81. async chooseImages(type) {
  82. /* #ifdef APP-PLUS */
  83. // let result2 = await this.$store.dispatch("requestPermissions",'CAMERA',)
  84. // if (result2 !== 1) return
  85. // let result = await this.$store.dispatch("requestPermissions",'WRITE_EXTERNAL_STORAGE',)
  86. // if (result !== 1) return
  87. /* #endif */
  88. let imgNum = 3 - (this.imgArr.length)
  89. uni.chooseImage({
  90. count: imgNum, //允许选择的数量
  91. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  92. sourceType: ['album', 'camera'], //从相册选择
  93. success: res => {
  94. uni.showLoading({
  95. title: '图片上传中...'
  96. });
  97. console.log(res)
  98. console.log('图片信息')
  99. res.tempFiles.forEach(async (item,index)=>{
  100. // 用索引做名字吧,小程序里获取不到文件名
  101. const imgLink = await uploadImgApi(item.path, index)
  102. this.imgArr.push(imgLink)
  103. })
  104. }
  105. })
  106. },
  107. }
  108. }
  109. </script>
  110. <style lang="scss" scoped>
  111. .pageBgImg {
  112. .pad {}
  113. .card {
  114. padding: 0 24rpx 24rpx 24rpx ;
  115. .h2 {
  116. font-size: 32rpx;
  117. font-weight: 600;
  118. line-height: 96rpx;
  119. }
  120. .textareaBg {
  121. min-height: 364rpx;
  122. background: #F8F8F8;
  123. border-radius: 16rpx;
  124. border: 2rpx solid #E8E9EC;
  125. display: flex;
  126. flex-direction: column;
  127. justify-content: space-between;
  128. .flex {
  129. padding: 20rpx;
  130. align-items: flex-start;
  131. .icon {
  132. width: 24rpx;
  133. height: 24rpx;
  134. margin: 0 14rpx 0 24rpx;
  135. }
  136. .inputBox {
  137. flex: 1;
  138. }
  139. /deep/ .inputBox .u-textarea {
  140. padding: 0 !important;
  141. border: none !important;
  142. background: none !important;
  143. font-size: 24rpx
  144. }
  145. }
  146. .phoneBox {
  147. display: flex;
  148. padding: 0 10rpx 20rpx 20rpx;
  149. .imgBox {
  150. display: flex;
  151. .img {
  152. margin-right: 14rpx;
  153. position: relative;
  154. image {
  155. width: 160rpx;
  156. height: 160rpx;
  157. border-radius: 8rpx;
  158. overflow: hidden;
  159. }
  160. .minusCircle {
  161. position: absolute;
  162. right: -14rpx;
  163. top: -20rpx;
  164. z-index: 9;
  165. }
  166. }
  167. }
  168. .phone {
  169. border: 2rpx dashed #CDCED0;
  170. width: 160rpx;
  171. height: 160rpx;
  172. background: #F8F8F8;
  173. border-radius: 8rpx;
  174. overflow: hidden;
  175. display: flex;
  176. align-items: center;
  177. justify-content: center;
  178. flex-direction: column;
  179. .phoneIcon {
  180. width: 60rpx;
  181. height: 60rpx;
  182. }
  183. .lab {
  184. font-size: 20rpx;
  185. color: #686B73;
  186. margin-top: 8rpx;
  187. }
  188. }
  189. }
  190. }
  191. }
  192. .phone_row {
  193. display: flex;
  194. height: 104rpx;
  195. padding: 0 28rpx;
  196. line-height: 104rpx;
  197. .label {
  198. font-size: 32rpx;
  199. font-weight: 600;
  200. margin-right: 50rpx;
  201. }
  202. .uInput {
  203. flex: 1;
  204. }
  205. }
  206. .btn {
  207. width: 396rpx;
  208. height: 72rpx;
  209. background: #D1E7FE;
  210. border-radius: 8rpx;
  211. font-size: 28rpx;
  212. text-align: center;
  213. line-height: 72rpx;
  214. margin: 100rpx auto 114rpx auto;
  215. color: #fff;
  216. &.active {
  217. background: $themC;
  218. }
  219. }
  220. }
  221. </style>