学员端小程序
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.

227 lines
5.1 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year 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">{{ this.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.$store.state.user.vuex_loginInfo.userId,
  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. chooseImages(type) {
  82. let imgNum = 3 - (this.imgArr.length)
  83. uni.chooseImage({
  84. count: imgNum, //允许选择的数量
  85. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  86. sourceType: ['album', 'camera'], //从相册选择
  87. success: res => {
  88. uni.showLoading({
  89. title: '图片上传中...'
  90. });
  91. console.log(res)
  92. console.log('图片信息')
  93. res.tempFiles.forEach(async (item,index)=>{
  94. // 用索引做名字吧,小程序里获取不到文件名
  95. const imgLink = await uploadImgApi(item.path, index)
  96. this.imgArr.push(imgLink)
  97. })
  98. }
  99. })
  100. },
  101. }
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .pageBgImg {
  106. .pad {}
  107. .card {
  108. padding: 0 24rpx 24rpx 24rpx ;
  109. .h2 {
  110. font-size: 32rpx;
  111. font-weight: 600;
  112. line-height: 96rpx;
  113. }
  114. .textareaBg {
  115. min-height: 364rpx;
  116. background: #F8F8F8;
  117. border-radius: 16rpx;
  118. border: 2rpx solid #E8E9EC;
  119. display: flex;
  120. flex-direction: column;
  121. justify-content: space-between;
  122. .flex {
  123. padding: 20rpx;
  124. align-items: flex-start;
  125. .icon {
  126. width: 24rpx;
  127. height: 24rpx;
  128. margin: 0 14rpx 0 24rpx;
  129. }
  130. .inputBox {
  131. flex: 1;
  132. }
  133. /deep/ .inputBox .u-textarea {
  134. padding: 0 !important;
  135. border: none !important;
  136. background: none !important;
  137. font-size: 24rpx
  138. }
  139. }
  140. .phoneBox {
  141. display: flex;
  142. padding: 0 10rpx 20rpx 20rpx;
  143. .imgBox {
  144. display: flex;
  145. .img {
  146. margin-right: 14rpx;
  147. position: relative;
  148. image {
  149. width: 160rpx;
  150. height: 160rpx;
  151. border-radius: 8rpx;
  152. overflow: hidden;
  153. }
  154. .minusCircle {
  155. position: absolute;
  156. right: -14rpx;
  157. top: -20rpx;
  158. z-index: 9;
  159. }
  160. }
  161. }
  162. .phone {
  163. border: 2rpx dashed #CDCED0;
  164. width: 160rpx;
  165. height: 160rpx;
  166. background: #F8F8F8;
  167. border-radius: 8rpx;
  168. overflow: hidden;
  169. display: flex;
  170. align-items: center;
  171. justify-content: center;
  172. flex-direction: column;
  173. .phoneIcon {
  174. width: 60rpx;
  175. height: 60rpx;
  176. }
  177. .lab {
  178. font-size: 20rpx;
  179. color: #686B73;
  180. margin-top: 8rpx;
  181. }
  182. }
  183. }
  184. }
  185. }
  186. .phone_row {
  187. display: flex;
  188. height: 104rpx;
  189. padding: 0 28rpx;
  190. line-height: 104rpx;
  191. .label {
  192. font-size: 32rpx;
  193. font-weight: 600;
  194. margin-right: 50rpx;
  195. }
  196. .uInput {
  197. flex: 1;
  198. }
  199. }
  200. .btn {
  201. width: 396rpx;
  202. height: 72rpx;
  203. background: #D1E7FE;
  204. border-radius: 8rpx;
  205. font-size: 28rpx;
  206. text-align: center;
  207. line-height: 72rpx;
  208. margin: 100rpx auto 114rpx auto;
  209. color: #fff;
  210. &.active {
  211. background: $themC;
  212. }
  213. }
  214. }
  215. </style>