feedback.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  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. chooseMsg() {
  171. //快速输入
  172. uni.showActionSheet({
  173. itemList: this.msgContents,
  174. success: (res) => {
  175. this.sendDate.content = this.msgContents[res.tapIndex]
  176. }
  177. })
  178. },
  179. chooseStar(e) {
  180. //点击评星
  181. this.sendDate.score = e
  182. },
  183. send() {
  184. //发送反馈
  185. // console.log(this.sendDate,'111111111');
  186. // console.log(this.shopBanner.join(','),'22222222222222222')
  187. if (!this.sendDate.content) {
  188. uni.showToast({
  189. icon: 'none',
  190. title: '请输入评价内容'
  191. })
  192. return
  193. }
  194. if (!this.shopBanner.length) {
  195. uni.showToast({
  196. icon: 'none',
  197. title: '请上传商品评价图'
  198. })
  199. return
  200. }
  201. this.$queue.showLoading('加载中...')
  202. console.log(this.orderNumber)
  203. this.$Request
  204. .postJson('/app/order/insertEvaluate', {
  205. goodsId: this.sendDate.goodsId,
  206. ordersId: this.sendDate.ordersId,
  207. orderNumber: this.sendDate.orderNumber,
  208. evaluateMessage: this.sendDate.content,
  209. score: this.value,
  210. shopId: this.sendDate.shopId,
  211. pictures: this.shopBanner.length > 0 ? this.shopBanner.join(',') : []
  212. })
  213. .then((res) => {
  214. if (res.code === 0) {
  215. uni.showToast({
  216. title: '评价成功'
  217. })
  218. setTimeout(function () {
  219. uni.navigateBack()
  220. }, 1000)
  221. } else {
  222. uni.hideLoading()
  223. uni.showModal({
  224. showCancel: false,
  225. title: '评价失败',
  226. content: res.msg
  227. })
  228. }
  229. })
  230. },
  231. viewImg(i, list) {
  232. uni.previewImage({
  233. urls: list,
  234. current: i
  235. })
  236. }
  237. }
  238. }
  239. </script>
  240. <style>
  241. @font-face {
  242. font-family: uniicons;
  243. font-weight: normal;
  244. font-style: normal;
  245. src: url('https://img-cdn-qiniu.dcloud.net.cn/fonts/uni.ttf') format('truetype');
  246. }
  247. page {
  248. background-color: #ffffff;
  249. }
  250. view {
  251. font-size: 28upx;
  252. }
  253. .input-view {
  254. font-size: 28upx;
  255. }
  256. .close-view {
  257. text-align: center;
  258. line-height: 14px;
  259. height: 16px;
  260. width: 16px;
  261. border-radius: 50%;
  262. background: #ff5053;
  263. color: #ffffff;
  264. position: absolute;
  265. top: -6px;
  266. right: -4px;
  267. font-size: 12px;
  268. }
  269. /* 上传 */
  270. .uni-uploader {
  271. flex: 1;
  272. flex-direction: column;
  273. }
  274. .uni-uploader-head {
  275. display: flex;
  276. flex-direction: row;
  277. justify-content: space-between;
  278. }
  279. .uni-uploader-info {
  280. color: #b2b2b2;
  281. }
  282. .uni-uploader-body {
  283. margin-top: 16upx;
  284. }
  285. .uni-uploader__files {
  286. display: flex;
  287. flex-direction: row;
  288. flex-wrap: wrap;
  289. }
  290. .uni-uploader__file {
  291. margin: 10upx;
  292. width: 210upx;
  293. height: 210upx;
  294. }
  295. .uni-uploader__img {
  296. display: block;
  297. width: 210upx;
  298. height: 210upx;
  299. }
  300. .uni-uploader__input-box {
  301. position: relative;
  302. margin: 10upx;
  303. width: 208upx;
  304. height: 208upx;
  305. border: 2upx solid #d9d9d9;
  306. }
  307. .uni-uploader__input-box:before,
  308. .uni-uploader__input-box:after {
  309. content: ' ';
  310. position: absolute;
  311. top: 50%;
  312. left: 50%;
  313. -webkit-transform: translate(-50%, -50%);
  314. transform: translate(-50%, -50%);
  315. background-color: #d9d9d9;
  316. }
  317. .uni-uploader__input-box:before {
  318. width: 4upx;
  319. height: 79upx;
  320. }
  321. .uni-uploader__input-box:after {
  322. width: 79upx;
  323. height: 4upx;
  324. }
  325. .uni-uploader__input-box:active {
  326. border-color: #999999;
  327. }
  328. .uni-uploader__input-box:active:before,
  329. .uni-uploader__input-box:active:after {
  330. background-color: #999999;
  331. }
  332. .uni-uploader__input {
  333. position: absolute;
  334. z-index: 1;
  335. top: 0;
  336. left: 0;
  337. width: 100%;
  338. height: 100%;
  339. opacity: 0;
  340. }
  341. /*问题反馈*/
  342. .feedback-title {
  343. display: flex;
  344. flex-direction: row;
  345. justify-content: space-between;
  346. align-items: center;
  347. padding: 20upx;
  348. color: #8f8f94;
  349. font-size: 28upx;
  350. }
  351. .feedback-star-view.feedback-title {
  352. justify-content: flex-start;
  353. margin: 0;
  354. }
  355. .feedback-quick {
  356. position: relative;
  357. padding-right: 40upx;
  358. }
  359. .feedback-quick:after {
  360. font-family: uniicons;
  361. font-size: 40upx;
  362. content: '\e581';
  363. position: absolute;
  364. right: 0;
  365. top: 50%;
  366. color: #bbb;
  367. -webkit-transform: translateY(-50%);
  368. transform: translateY(-50%);
  369. }
  370. .feedback-body {
  371. font-size: 32upx;
  372. padding: 16upx;
  373. margin: 16upx;
  374. border-radius: 16upx;
  375. background: #f2f2f2;
  376. color: #fff;
  377. }
  378. .feedback-textare {
  379. height: 200upx;
  380. font-size: 30upx;
  381. line-height: 50upx;
  382. width: 100%;
  383. box-sizing: border-box;
  384. padding: 10upx 0upx 0;
  385. color: #8f8f94;
  386. }
  387. .feedback-input {
  388. font-size: 32upx;
  389. height: 60upx;
  390. padding: 15upx 20upx;
  391. line-height: 60upx;
  392. }
  393. .feedback-uploader {
  394. padding: 22upx 20upx;
  395. }
  396. .feedback-star {
  397. font-family: uniicons;
  398. font-size: 40upx;
  399. margin-left: 6upx;
  400. }
  401. .feedback-star-view {
  402. margin-left: 20upx;
  403. }
  404. .feedback-star:after {
  405. content: '\e408';
  406. }
  407. .feedback-star.active {
  408. color: #ffb400;
  409. }
  410. .feedback-star.active:after {
  411. content: '\e438';
  412. }
  413. .feedback-submit {
  414. background: #007aff;
  415. color: #ffffff;
  416. margin: 20upx;
  417. }
  418. </style>