index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <view class="page-box">
  3. <navBar title="我要反馈" color="#000" />
  4. <view class="page-content">
  5. <view class="page" style="background-color: #ffffff">
  6. <view class="feedback-title">
  7. <text>问题和意见</text>
  8. <text @tap="chooseMsg">快速键入</text>
  9. </view>
  10. <view class="feedback-body">
  11. <textarea placeholder="请详细描述你的问题和意见..." v-model="sendDate.content" class="feedback-textare" />
  12. </view>
  13. <view class="feedback-title"><text>联系方式</text></view>
  14. <view class="feedback-body"><input class="feedback-input" v-model="sendDate.contact" placeholder="方便我们联系你 " />
  15. </view>
  16. <button style="" class="feedback-submit" @tap="send">提交</button>
  17. </view>
  18. </view>
  19. <!-- 权限说明弹窗 -->
  20. <u-popup mode="top" ref="permission">
  21. <view class="popup-content">
  22. <view class="popup-text-permission">选择/拍摄照片需要相机/相册权限,用于上传用户头像</view>
  23. </view>
  24. </u-popup>
  25. </view>
  26. </template>
  27. <script>
  28. import navBar from "@/components/nav-bar/index.vue";
  29. export default {
  30. data() {
  31. return {
  32. msgContents: [
  33. "界面显示错乱",
  34. "启动缓慢,卡出翔了",
  35. "UI无法直视,丑哭了",
  36. "偶发性崩溃",
  37. ],
  38. stars: [1, 2, 3, 4, 5],
  39. imageList: [],
  40. sendDate: {
  41. score: 5,
  42. content: "",
  43. contact: "",
  44. },
  45. };
  46. },
  47. components: {
  48. navBar,
  49. },
  50. onLoad() {
  51. let deviceInfo = {
  52. appid: plus.runtime.appid,
  53. imei: plus.device.imei, //设备标识
  54. p: plus.os.name === "Android" ? "a" : "i", //平台类型,i表示iOS平台,a表示Android平台。
  55. md: plus.device.model, //设备型号
  56. app_version: plus.runtime.version,
  57. plus_version: plus.runtime.innerVersion, //基座版本号
  58. os: plus.os.version,
  59. net: "" + plus.networkinfo.getCurrentType(),
  60. };
  61. this.sendDate = Object.assign(deviceInfo, this.sendDate);
  62. },
  63. methods: {
  64. close(e) {
  65. this.imageList.splice(e, 1);
  66. },
  67. chooseMsg() {
  68. //快速输入
  69. uni.showActionSheet({
  70. itemList: this.msgContents,
  71. success: (res) => {
  72. this.sendDate.content = this.msgContents[res.tapIndex];
  73. },
  74. });
  75. },
  76. async chooseImg() {
  77. // // 1. 先判断系统类型,区分Android/iOS权限
  78. // const systemInfo = uni.getSystemInfoSync();
  79. // const isAndroid = systemInfo.system.includes('Android');
  80. // const permissionType = isAndroid ? 'storage' : 'photos'; // Android=存储,iOS=相册
  81. // // 2. 权限检查(复用之前封装的 checkPermission 函数)
  82. // const hasPermission = this.$queue.checkPermission(
  83. // permissionType,
  84. // isAndroid
  85. // ? '选择/拍摄照片需要相机/相册权限,用于上传简历/求职资料' // Android 专属提示
  86. // : '选择/拍摄照片需要相机/相册权限,用于上传简历/求职资料'
  87. // );
  88. // if (!hasPermission) {
  89. // uni.showToast({ title: '未获取权限,无法选择照片', icon: 'none' });
  90. // return;
  91. // }
  92. // 1. 检查权限状态
  93. const hasPermission = await this.$queue.checkPermission(
  94. 'camera',
  95. '选择/拍摄照片需要相机/相册权限,用于上传用户头像',
  96. this
  97. );
  98. // 2. 如果未授权或者用户拒绝,显示提示
  99. if (!hasPermission) {
  100. return;
  101. }
  102. //选择图片
  103. uni.chooseImage({
  104. sourceType: ["camera", "album"],
  105. sizeType: "compressed",
  106. count: 8 - this.imageList.length,
  107. success: (res) => {
  108. this.imageList = this.imageList.concat(res.tempFilePaths);
  109. },
  110. });
  111. },
  112. chooseStar(e) {
  113. //点击评星
  114. this.sendDate.score = e;
  115. },
  116. previewImage() {
  117. //预览图片
  118. uni.previewImage({
  119. urls: this.imageList,
  120. });
  121. },
  122. send() {
  123. //发送反馈
  124. console.log(JSON.stringify(this.sendDate));
  125. if (!this.sendDate.content) {
  126. uni.showToast({
  127. icon: "none",
  128. title: "请输入反馈内容",
  129. });
  130. return;
  131. }
  132. if (!this.sendDate.contact) {
  133. uni.showToast({
  134. icon: "none",
  135. title: "请填写QQ或邮箱",
  136. });
  137. return;
  138. }
  139. this.$queue.showLoading("加载中...");
  140. this.$Request
  141. .postJson("/app/message/insertMessage", {
  142. title: this.sendDate.contact,
  143. content: JSON.stringify(this.sendDate),
  144. state: 2,
  145. })
  146. .then((res) => {
  147. if (res.code === 0) {
  148. uni.showToast({
  149. title: "投诉成功",
  150. });
  151. setTimeout(function () {
  152. uni.navigateBack();
  153. }, 1000);
  154. } else {
  155. uni.hideLoading();
  156. uni.showModal({
  157. showCancel: false,
  158. title: "投诉失败",
  159. content: res.msg,
  160. });
  161. }
  162. });
  163. },
  164. },
  165. };
  166. </script>
  167. <style lang="scss" scoped>
  168. @font-face {
  169. font-family: uniicons;
  170. font-weight: normal;
  171. font-style: normal;
  172. src: url("https://img-cdn-qiniu.dcloud.net.cn/fonts/uni.ttf") format("truetype");
  173. }
  174. page {
  175. .page-box {
  176. position: absolute;
  177. left: 0;
  178. bottom: 0;
  179. right: 0;
  180. top: 0;
  181. overflow: hidden;
  182. display: flex;
  183. flex-direction: column;
  184. .page-content {
  185. flex: 1;
  186. overflow: hidden;
  187. overflow-y: auto;
  188. }
  189. }
  190. }
  191. view {
  192. font-size: 28upx;
  193. }
  194. /*问题反馈*/
  195. .feedback-title {
  196. display: flex;
  197. flex-direction: row;
  198. justify-content: space-between;
  199. align-items: center;
  200. padding: 20upx;
  201. color: #8f8f94;
  202. font-size: 28upx;
  203. }
  204. .feedback-star-view.feedback-title {
  205. justify-content: flex-start;
  206. margin: 0;
  207. }
  208. .feedback-body {
  209. font-size: 32upx;
  210. padding: 16upx;
  211. margin: 16upx;
  212. border-radius: 16upx;
  213. background: #ffffff;
  214. /* color: #FFF; */
  215. }
  216. .feedback-textare {
  217. height: 200upx;
  218. font-size: 34upx;
  219. line-height: 50upx;
  220. width: 100%;
  221. box-sizing: border-box;
  222. padding: 20upx 30upx 0;
  223. }
  224. .feedback-input {
  225. font-size: 32upx;
  226. height: 60upx;
  227. padding: 15upx 20upx;
  228. line-height: 60upx;
  229. }
  230. .feedback-submit {
  231. background: #016bf6;
  232. color: #ffffff;
  233. margin: 20upx;
  234. margin-top: 32upx;
  235. }
  236. </style>