index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <view class="bg">
  3. <view class="header">
  4. <radio-group class="option" @change="radioChange">
  5. <label class="radio">
  6. <radio checked color="#498ef5" value="1" /><text
  7. style="font-weight: 600; padding-left: 10rpx"
  8. >遇到问题</text
  9. >
  10. </label>
  11. <label class="radio">
  12. <radio color="#498ef5" value="2" /><text
  13. style="font-weight: 600; padding-left: 10rpx"
  14. >使用建议</text
  15. >
  16. </label>
  17. </radio-group>
  18. </view>
  19. <view>
  20. <view class="form">
  21. <view class="content">
  22. <textarea
  23. maxlength="250"
  24. :placeholder="placeholder"
  25. class=""
  26. v-model="form.content"
  27. ></textarea>
  28. <view class="uplaod">
  29. <van-uploader
  30. accept="image"
  31. @delete="deleteAdviseImg"
  32. :max-count="4"
  33. :file-list="fileList"
  34. @after-read="afterRead"
  35. >
  36. <image style="width: 80px; height: 80px" :src="i"></image>
  37. </van-uploader>
  38. </view>
  39. </view>
  40. <view class="phone">
  41. <input
  42. v-model="form.phone"
  43. placeholder="请填写手机号码"
  44. class="phone-input"
  45. />
  46. </view>
  47. </view>
  48. </view>
  49. <view class="submit">
  50. <view @click="submitAdvise" class="submit-button">提交</view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import store from "@/store";
  56. import api from "@/api";
  57. export default {
  58. data() {
  59. return {
  60. form: {
  61. content: "",
  62. phone: "",
  63. type: "1",
  64. imgs: "",
  65. },
  66. uploadUrl:
  67. process.env.NODE_ENV === "development"
  68. ? "https://nbjk1.zzxcx.net/nbjk-admin/"
  69. : "https://nbjk.zzxcx.net/nbjk-admin/",
  70. i: "https://ct-1305573081.cos.ap-shanghai.myqcloud.com/ctjk/mp-wx/userAdvise/upload_icon.png",
  71. fileList: [],
  72. placeholder:
  73. "遇到的问题如下:1、打开了某个页面2、执行某个操作遇到了什么问题3、其他附加描述",
  74. };
  75. },
  76. methods: {
  77. deleteAdviseImg(e){
  78. console.log(e)
  79. let fileList= this.fileList.filter((item,index)=>{
  80. return e.detail.index!==index
  81. })
  82. this.fileList =fileList
  83. },
  84. submitAdvise(e) {
  85. console.log(e);
  86. let that = this;
  87. var res = /^[1][3,4,5,6.7,8,9][0-9]{9}$/;
  88. if (!res.test(this.form.phone)) {
  89. uni.showToast({
  90. icon: "error",
  91. title: "手机号格式错误",
  92. });
  93. return;
  94. }
  95. api.advise
  96. .studentFeedBack({
  97. ...that.form,
  98. imgIds: that.fileList.map((item) => item.id).join(","),
  99. })
  100. .then((res) => {
  101. uni.showToast({
  102. title: "成功",
  103. });
  104. });
  105. },
  106. afterRead(e) {
  107. console.log(e);
  108. let that = this;
  109. uni.uploadFile({
  110. url: that.uploadUrl + "/student/file/info/uploadImage",
  111. filePath: e.detail.file.url,
  112. name: "img",
  113. header: {
  114. Authorization: store.state.user.tokenObj.token
  115. ? "Bearer " + store.state.user.tokenObj.token
  116. : "",
  117. "Content-Type": "application/json;charset=utf8",
  118. },
  119. formData: {
  120. businessType: that.form.type,
  121. },
  122. success(res) {
  123. var resData = JSON.parse(res.data);
  124. if (resData.code == 200) {
  125. that.fileList.push({
  126. url: e.detail.file.url,
  127. id: resData.data,
  128. name: resData.data,
  129. isImage:true
  130. });
  131. } else {
  132. uni.showToast({
  133. icon: "error",
  134. title: "上传失败",
  135. });
  136. }
  137. },
  138. });
  139. },
  140. radioChange(e) {
  141. this.form.type = e.detail.value;
  142. this.placeholder =
  143. e.detail.value == "1"
  144. ? "遇到的问题如下:1、打开了某个页面2、执行某个操作遇到了什么问题3、其他附加描述"
  145. : "请详细描述您在使用视频APP时的想法和建议";
  146. },
  147. },
  148. };
  149. </script>
  150. <style lang="scss" scoped>
  151. .bg {
  152. background: #fff;
  153. width: 100vw;
  154. height: 100vh;
  155. }
  156. .inline-block {
  157. display: inline-block;
  158. }
  159. .header {
  160. padding-left: 114rpx;
  161. padding-right: 114rpx;
  162. display: flex;
  163. justify-content: space-between;
  164. .option {
  165. width: 100%;
  166. display: flex;
  167. justify-content: space-between;
  168. margin-top: 56rpx;
  169. }
  170. }
  171. .form {
  172. padding-left: 30rpx;
  173. padding-right: 30rpx;
  174. margin-top: 30rpx;
  175. .phone {
  176. margin-top: 50rpx;
  177. .phone-input {
  178. height: 108rpx;
  179. line-height: 108rpx;
  180. background: rgba(242, 243, 245, 1);
  181. overflow: hidden;
  182. border-radius: 54rpx;
  183. padding-left: 40rpx;
  184. }
  185. }
  186. .content {
  187. width: 100%;
  188. background: rgba(242, 243, 245, 1);
  189. height: 456rpx;
  190. position: relative;
  191. .uplaod {
  192. // position: absolute;
  193. // bottom: 32rpx;
  194. padding-left: 30rpx;
  195. z-index: 999;
  196. margin-top: 20px;
  197. }
  198. }
  199. .content > textarea {
  200. width: 630rpx;
  201. height: 220rpx;
  202. padding-top: 20rpx;
  203. padding-left: 30rpx;
  204. padding-right: 30rpx;
  205. border-radius: 5rpx;
  206. }
  207. }
  208. .submit {
  209. position: absolute;
  210. bottom: 80rpx;
  211. width: 100%;
  212. .submit-button {
  213. width: 530rpx;
  214. line-height: 80rpx;
  215. text-align: center;
  216. margin: 0 auto;
  217. background: rgba(73, 142, 245, 1);
  218. color: #fff;
  219. border-radius: 40rpx;
  220. }
  221. }
  222. </style>