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

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