feedback.vue 10 KB

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