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

254 lines
5.9 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 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.mobile }}</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 { WX_API, H5_API, prefix } from '@/config/site.config.js';
  46. import { createconsult } from '@/config/api.js'
  47. var _url = H5_API+ WX_API
  48. // let url = 'api'
  49. export default {
  50. data() {
  51. return {
  52. value: '',
  53. imgArr: [],
  54. }
  55. },
  56. onLoad() {
  57. },
  58. methods: {
  59. async submintFn() {
  60. let images = this.imgArr.join(',')
  61. if(!this.value.trim()) return this.$u.toast('请输入内容')
  62. let obj = {
  63. images,
  64. studentPhone: this.vuex_userInfo.mobile,
  65. type: 1,
  66. studentId: this.$store.state.user.vuex_loginInfo.userId,
  67. content: this.value
  68. }
  69. const {data: res} = await createconsult(obj)
  70. this.$u.toast('发布成功')
  71. this.value = ''
  72. this.imgArr = []
  73. setTimeout(()=>{
  74. this.$goPage('/pages/indexEntry/consult/record/record?tab=1')
  75. },1500)
  76. },
  77. deleteImg(item) {
  78. let index = this.imgArr.findIndex(val=>val==item)
  79. this.imgArr.splice(index, 1)
  80. },
  81. //选择图片
  82. chooseImages(type) {
  83. let imgNum = 3 - (this.imgArr.length)
  84. uni.chooseImage({
  85. count: imgNum, //允许选择的数量
  86. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  87. sourceType: ['album', 'camera'], //从相册选择
  88. success: res => {
  89. uni.showLoading({
  90. title: '图片上传中...'
  91. });
  92. res.tempFiles.forEach( (item,index)=>{
  93. this.uploadImgApi(item.path, item.name)
  94. })
  95. }
  96. })
  97. },
  98. uploadImgApi(filePath, imgNamme) {
  99. console.log(filePath)
  100. let token = 'Bearer '+ this.$store.state.user.vuex_loginInfo.accessToken
  101. let _this = this
  102. let timer = new Date() * 1
  103. // 上传图片到服务器
  104. uni.uploadFile({
  105. url: _url + 'app-api/infra/file/upload',//接口
  106. filePath: filePath,//要上传的图片的本地路径
  107. name: 'file',
  108. formData: {
  109. path: 'complain/'+ uni.$u.date(name, 'yyyy-mm-dd')+timer + '-'+ imgName,
  110. type: 1,
  111. fileSuffix: "png"
  112. },
  113. header: {
  114. Authorization: token,
  115. 'tenant-id': 1
  116. },
  117. success(res) {
  118. console.log('上传成功')
  119. let res2 = JSON.parse(res.data)
  120. _this.imgArr.push(res2.data)
  121. console.log(res2)
  122. uni.hideLoading();
  123. },
  124. complete: (err)=> {
  125. console.log(err)
  126. }
  127. })
  128. },
  129. }
  130. }
  131. </script>
  132. <style lang="scss" scoped>
  133. .pageBgImg {
  134. .pad {}
  135. .card {
  136. padding: 0 24rpx 24rpx 24rpx ;
  137. .h2 {
  138. font-size: 32rpx;
  139. font-weight: 600;
  140. line-height: 96rpx;
  141. }
  142. .textareaBg {
  143. min-height: 364rpx;
  144. background: #F8F8F8;
  145. border-radius: 16rpx;
  146. border: 2rpx solid #E8E9EC;
  147. display: flex;
  148. flex-direction: column;
  149. justify-content: space-between;
  150. .flex {
  151. padding: 20rpx;
  152. align-items: flex-start;
  153. .icon {
  154. width: 24rpx;
  155. height: 24rpx;
  156. margin: 0 14rpx 0 24rpx;
  157. }
  158. .inputBox {
  159. flex: 1;
  160. }
  161. /deep/ .inputBox .u-textarea {
  162. padding: 0 !important;
  163. border: none !important;
  164. background: none !important;
  165. font-size: 24rpx
  166. }
  167. }
  168. .phoneBox {
  169. display: flex;
  170. padding: 0 10rpx 20rpx 20rpx;
  171. .imgBox {
  172. display: flex;
  173. .img {
  174. margin-right: 14rpx;
  175. position: relative;
  176. image {
  177. width: 160rpx;
  178. height: 160rpx;
  179. border-radius: 8rpx;
  180. overflow: hidden;
  181. }
  182. .minusCircle {
  183. position: absolute;
  184. right: -14rpx;
  185. top: -20rpx;
  186. z-index: 9;
  187. }
  188. }
  189. }
  190. .phone {
  191. border: 2rpx dashed #CDCED0;
  192. width: 160rpx;
  193. height: 160rpx;
  194. background: #F8F8F8;
  195. border-radius: 8rpx;
  196. overflow: hidden;
  197. display: flex;
  198. align-items: center;
  199. justify-content: center;
  200. flex-direction: column;
  201. .phoneIcon {
  202. width: 60rpx;
  203. height: 60rpx;
  204. }
  205. .lab {
  206. font-size: 20rpx;
  207. color: #686B73;
  208. margin-top: 8rpx;
  209. }
  210. }
  211. }
  212. }
  213. }
  214. .phone_row {
  215. display: flex;
  216. height: 104rpx;
  217. padding: 0 28rpx;
  218. line-height: 104rpx;
  219. .label {
  220. font-size: 32rpx;
  221. font-weight: 600;
  222. margin-right: 50rpx;
  223. }
  224. .uInput {
  225. flex: 1;
  226. }
  227. }
  228. .btn {
  229. width: 396rpx;
  230. height: 72rpx;
  231. background: #D1E7FE;
  232. border-radius: 8rpx;
  233. font-size: 28rpx;
  234. text-align: center;
  235. line-height: 72rpx;
  236. margin: 100rpx auto 114rpx auto;
  237. color: #fff;
  238. &.active {
  239. background: $themC;
  240. }
  241. }
  242. }
  243. </style>