feedback.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <view class="page">
  3. <!-- <view class="feedback-title"> -->
  4. <!-- <text>评价</text> -->
  5. <!-- <text @tap="chooseMsg">快速键入</text> -->
  6. <!-- </view> -->
  7. <view class="feedback-body">
  8. <textarea placeholder="请输入你的评价..." v-model="sendDate.content" class="feedback-textare" />
  9. </view>
  10. <!-- <view class="feedback-title"><text>QQ/邮箱</text></view> -->
  11. <!-- <view class="feedback-body"><input class="feedback-input" v-model="sendDate.mail" placeholder="方便我们联系你 " /></view> -->
  12. <view class="text-white padding bg radius margin-tb">
  13. <view>
  14. <view class="text-lg margin-top-sm text-black">商品评价图(可多张)</view>
  15. <view class="flex" style="overflow: hidden; flex-wrap: wrap">
  16. <view>
  17. <view class="margin-top flex margin-right-sm flex-wrap">
  18. <view
  19. class="flex"
  20. style="width: 200rpx; height: 200rpx; margin-right: 2rpx; position: relative"
  21. v-for="(image, index) in shopBanner"
  22. :key="index"
  23. @click="viewImg(index, shopBanner)"
  24. >
  25. <!-- <image :src="image" style="width: 100%;height: 100%;"></image> -->
  26. <image :src="image" mode="aspectFill" style="width: 100%; height: 100%"></image>
  27. <view style="z-index: 9; position: absolute; top: -15rpx; right: -15rpx" @click.stop="removeImg(index)">
  28. <u-icon name="close-circle-fill" color="#2979ff" size="50rpx"></u-icon>
  29. </view>
  30. </view>
  31. <view class="flex" style="width: 200rpx; height: 200rpx; margin-right: 2rpx; position: relative" @click="addImages(2)" v-if="shopBanner.length < 9">
  32. <!-- <image :src="image" style="width: 100%;height: 100%;"></image> -->
  33. <view style="width: 200rpx; height: 200rpx; background: #f4f5f6" class="flex justify-center align-center">
  34. <view>
  35. <view class="text-center">
  36. <image src="/static/images/addimg.png" style="width: 65rpx; height: 55rpx"></image>
  37. </view>
  38. <view class="text-center text-black">添加图片</view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="feedback-title feedback-star-view">
  48. <text>订单评分</text>
  49. <view class="feedback-star-view">
  50. <!-- <text class="feedback-star" v-for="(value, key) in stars" :key="key" :class="key < sendDate.score ? 'active' : ''" @tap="chooseStar(value)"></text> -->
  51. </view>
  52. <u-rate :count="count" min-count="1" active-color="#FCD202" v-model="value"></u-rate>
  53. </view>
  54. <button type="primary" style="background: #fcd202; margin-top: 32upx" class="feedback-submit" @tap="send">提交</button>
  55. <!-- 用于图片压缩的canvas画布 -->
  56. <canvas
  57. :style="{
  58. width: cw + 'px',
  59. height: cw + 'px',
  60. position: 'absolute',
  61. zIndex: -1,
  62. left: '-10000rpx',
  63. top: '-10000rpx'
  64. }"
  65. canvas-id="zipCanvas"
  66. ></canvas>
  67. <!--画布结束-->
  68. </view>
  69. </template>
  70. <script>
  71. import configUrl from '../../common/config.js'
  72. import getLessLimitSizeImage from '@/utils/imageCompress.js'
  73. export default {
  74. data() {
  75. return {
  76. shopBanner: [],
  77. msgContents: ['界面显示错乱', '启动缓慢,卡出翔了', 'UI无法直视,丑哭了', '偶发性崩溃'],
  78. stars: [1, 2, 3, 4, 5],
  79. imageList: [],
  80. sendDate: {
  81. score: 5,
  82. content: '',
  83. contact: '',
  84. goodsId: '',
  85. ordersId: '',
  86. orderNumber: '',
  87. shopId: ''
  88. },
  89. count: 5,
  90. value: 5,
  91. goodsId: '',
  92. ordersId: '',
  93. orderNumber: '',
  94. //画板边长默认是屏幕宽度,正方形画布
  95. cw: uni.getSystemInfoSync().windowWidth
  96. }
  97. },
  98. onLoad(e) {
  99. this.sendDate.goodsId = e.goodsId
  100. this.sendDate.ordersId = e.ordersId
  101. this.sendDate.orderNumber = e.orderNumber
  102. this.sendDate.shopId = e.shopId
  103. // let deviceInfo = {
  104. // appid: plus.runtime.appid,
  105. // imei: plus.device.imei, //设备标识
  106. // p: plus.os.name === 'Android' ? 'a' : 'i', //平台类型,i表示iOS平台,a表示Android平台。
  107. // md: plus.device.model, //设备型号
  108. // app_version: plus.runtime.version,
  109. // plus_version: plus.runtime.innerVersion, //基座版本号
  110. // os: plus.os.version,
  111. // net: '' + plus.networkinfo.getCurrentType()
  112. // };
  113. // this.sendDate = Object.assign(deviceInfo, this.sendDate);
  114. },
  115. methods: {
  116. // 图片上传
  117. addImages(e) {
  118. uni.chooseImage({
  119. count: 9,
  120. sourceType: ['album', 'camera'],
  121. success: (res) => {
  122. for (let i = 0; i < res.tempFiles.length; i++) {
  123. //这里的id和页面中写的html代码的canvas的id要一致
  124. let canvasId = 'zipCanvas'
  125. //原图的路径
  126. let imagePath = res.tempFiles[i].path
  127. //大小限制
  128. let limitSize = 1024 * 2
  129. //初始绘画区域是画布自身的宽度也就是屏幕宽度
  130. let drawWidth = uni.getSystemInfoSync().windowWidth
  131. let that = this
  132. getLessLimitSizeImage(canvasId, imagePath, limitSize, drawWidth, that, (resPath) => {
  133. uni.showLoading({
  134. title: '上传中'
  135. })
  136. uni.uploadFile({
  137. url: configUrl.APIHOST + '/alioss/upload',
  138. filePath: resPath,
  139. name: 'file',
  140. success: (uploadFileRes) => {
  141. if (this.shopBanner.length < 9) {
  142. if (JSON.parse(uploadFileRes.data).data) {
  143. this.shopBanner.push(JSON.parse(uploadFileRes.data).data)
  144. } else {
  145. uni.showToast({
  146. title: '图片上传失败,请重试',
  147. icon: 'none'
  148. })
  149. }
  150. }
  151. console.log(this.shopBanner)
  152. uni.hideLoading()
  153. },
  154. fail: () => {
  155. uni.showToast({
  156. title: '上传失败',
  157. icon: 'error'
  158. })
  159. }
  160. })
  161. })
  162. }
  163. }
  164. })
  165. },
  166. // 评价图删除
  167. removeImg(index) {
  168. this.shopBanner.splice(index, 1)
  169. },
  170. close(e) {
  171. this.imageList.splice(e, 1)
  172. },
  173. chooseMsg() {
  174. //快速输入
  175. uni.showActionSheet({
  176. itemList: this.msgContents,
  177. success: (res) => {
  178. this.sendDate.content = this.msgContents[res.tapIndex]
  179. }
  180. })
  181. },
  182. chooseImg() {
  183. //选择图片
  184. uni.chooseImage({
  185. sourceType: ['camera', 'album'],
  186. sizeType: 'compressed',
  187. count: 8 - this.imageList.length,
  188. success: (res) => {
  189. this.imageList = this.imageList.concat(res.tempFilePaths)
  190. }
  191. })
  192. },
  193. chooseStar(e) {
  194. //点击评星
  195. this.sendDate.score = e
  196. },
  197. previewImage() {
  198. //预览图片
  199. uni.previewImage({
  200. urls: this.imageList
  201. })
  202. },
  203. send() {
  204. //发送反馈
  205. // console.log(this.sendDate,'111111111');
  206. // console.log(this.shopBanner.join(','),'22222222222222222')
  207. if (!this.sendDate.content) {
  208. uni.showToast({
  209. icon: 'none',
  210. title: '请输入评价内容'
  211. })
  212. return
  213. }
  214. if (!this.shopBanner.length) {
  215. uni.showToast({
  216. icon: 'none',
  217. title: '请上传商品评价图'
  218. })
  219. return
  220. }
  221. this.$queue.showLoading('加载中...')
  222. console.log(this.orderNumber)
  223. this.$Request
  224. .postJson('/app/order/insertEvaluate', {
  225. goodsId: this.sendDate.goodsId,
  226. ordersId: this.sendDate.ordersId,
  227. orderNumber: this.sendDate.orderNumber,
  228. evaluateMessage: this.sendDate.content,
  229. score: this.value,
  230. shopId: this.sendDate.shopId,
  231. pictures: this.shopBanner.length > 0 ? this.shopBanner.join(',') : []
  232. })
  233. .then((res) => {
  234. if (res.code === 0) {
  235. uni.showToast({
  236. title: '评价成功'
  237. })
  238. setTimeout(function () {
  239. uni.navigateBack()
  240. }, 1000)
  241. } else {
  242. uni.hideLoading()
  243. uni.showModal({
  244. showCancel: false,
  245. title: '评价失败',
  246. content: res.msg
  247. })
  248. }
  249. })
  250. },
  251. viewImg(i, list) {
  252. uni.previewImage({
  253. urls: list,
  254. current: i
  255. })
  256. }
  257. }
  258. }
  259. </script>
  260. <style>
  261. @font-face {
  262. font-family: uniicons;
  263. font-weight: normal;
  264. font-style: normal;
  265. src: url('https://img-cdn-qiniu.dcloud.net.cn/fonts/uni.ttf') format('truetype');
  266. }
  267. page {
  268. background-color: #ffffff;
  269. }
  270. view {
  271. font-size: 28upx;
  272. }
  273. .input-view {
  274. font-size: 28upx;
  275. }
  276. .close-view {
  277. text-align: center;
  278. line-height: 14px;
  279. height: 16px;
  280. width: 16px;
  281. border-radius: 50%;
  282. background: #ff5053;
  283. color: #ffffff;
  284. position: absolute;
  285. top: -6px;
  286. right: -4px;
  287. font-size: 12px;
  288. }
  289. /* 上传 */
  290. .uni-uploader {
  291. flex: 1;
  292. flex-direction: column;
  293. }
  294. .uni-uploader-head {
  295. display: flex;
  296. flex-direction: row;
  297. justify-content: space-between;
  298. }
  299. .uni-uploader-info {
  300. color: #b2b2b2;
  301. }
  302. .uni-uploader-body {
  303. margin-top: 16upx;
  304. }
  305. .uni-uploader__files {
  306. display: flex;
  307. flex-direction: row;
  308. flex-wrap: wrap;
  309. }
  310. .uni-uploader__file {
  311. margin: 10upx;
  312. width: 210upx;
  313. height: 210upx;
  314. }
  315. .uni-uploader__img {
  316. display: block;
  317. width: 210upx;
  318. height: 210upx;
  319. }
  320. .uni-uploader__input-box {
  321. position: relative;
  322. margin: 10upx;
  323. width: 208upx;
  324. height: 208upx;
  325. border: 2upx solid #d9d9d9;
  326. }
  327. .uni-uploader__input-box:before,
  328. .uni-uploader__input-box:after {
  329. content: ' ';
  330. position: absolute;
  331. top: 50%;
  332. left: 50%;
  333. -webkit-transform: translate(-50%, -50%);
  334. transform: translate(-50%, -50%);
  335. background-color: #d9d9d9;
  336. }
  337. .uni-uploader__input-box:before {
  338. width: 4upx;
  339. height: 79upx;
  340. }
  341. .uni-uploader__input-box:after {
  342. width: 79upx;
  343. height: 4upx;
  344. }
  345. .uni-uploader__input-box:active {
  346. border-color: #999999;
  347. }
  348. .uni-uploader__input-box:active:before,
  349. .uni-uploader__input-box:active:after {
  350. background-color: #999999;
  351. }
  352. .uni-uploader__input {
  353. position: absolute;
  354. z-index: 1;
  355. top: 0;
  356. left: 0;
  357. width: 100%;
  358. height: 100%;
  359. opacity: 0;
  360. }
  361. /*问题反馈*/
  362. .feedback-title {
  363. display: flex;
  364. flex-direction: row;
  365. justify-content: space-between;
  366. align-items: center;
  367. padding: 20upx;
  368. color: #8f8f94;
  369. font-size: 28upx;
  370. }
  371. .feedback-star-view.feedback-title {
  372. justify-content: flex-start;
  373. margin: 0;
  374. }
  375. .feedback-quick {
  376. position: relative;
  377. padding-right: 40upx;
  378. }
  379. .feedback-quick:after {
  380. font-family: uniicons;
  381. font-size: 40upx;
  382. content: '\e581';
  383. position: absolute;
  384. right: 0;
  385. top: 50%;
  386. color: #bbb;
  387. -webkit-transform: translateY(-50%);
  388. transform: translateY(-50%);
  389. }
  390. .feedback-body {
  391. font-size: 32upx;
  392. padding: 16upx;
  393. margin: 16upx;
  394. border-radius: 16upx;
  395. background: #f2f2f2;
  396. color: #fff;
  397. }
  398. .feedback-textare {
  399. height: 200upx;
  400. font-size: 30upx;
  401. line-height: 50upx;
  402. width: 100%;
  403. box-sizing: border-box;
  404. padding: 10upx 0upx 0;
  405. color: #8f8f94;
  406. }
  407. .feedback-input {
  408. font-size: 32upx;
  409. height: 60upx;
  410. padding: 15upx 20upx;
  411. line-height: 60upx;
  412. }
  413. .feedback-uploader {
  414. padding: 22upx 20upx;
  415. }
  416. .feedback-star {
  417. font-family: uniicons;
  418. font-size: 40upx;
  419. margin-left: 6upx;
  420. }
  421. .feedback-star-view {
  422. margin-left: 20upx;
  423. }
  424. .feedback-star:after {
  425. content: '\e408';
  426. }
  427. .feedback-star.active {
  428. color: #ffb400;
  429. }
  430. .feedback-star.active:after {
  431. content: '\e438';
  432. }
  433. .feedback-submit {
  434. background: #007aff;
  435. color: #ffffff;
  436. margin: 20upx;
  437. }
  438. </style>