evaluate.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. <template>
  2. <view class="content">
  3. <view class="order-item">
  4. <view class="goods-box-single">
  5. <image class="goods-img" :src="productInfo.image" mode="aspectFill"></image>
  6. <view class="right position-relative">
  7. <view class="flex">
  8. <text class="title">{{ productInfo.store_name }}</text>
  9. <view class="title-right">
  10. <view class="price">{{ productInfo.price }}</view>
  11. <view class="attr-box">x{{ list.cart_num }}</view>
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. <view>
  17. <view class="flex_item zhil">
  18. <view>商品质量</view>
  19. <view><uniRate text="1" size="20" margin="10" :value="rateValue1" @change="rateChange1"></uniRate></view>
  20. </view>
  21. <view class="flex_item zhil">
  22. <view>服务态度</view>
  23. <view><uniRate text="1" size="20" margin="10" :value="rateValue2" @change="rateChange2"></uniRate></view>
  24. </view>
  25. <view class="equity_box">
  26. <view class="text-box uni-textarea">
  27. <textarea placeholder-style="color:#999" :placeholder="placeholder" @blur="bindTextAreaBlur"></textarea>
  28. </view>
  29. <view class="">
  30. <view class="add-img-box flex_item">
  31. <view class="add-img-item" v-for="(item, index) in imgList" :key="index">
  32. <image class="add-img" @click.stop="imgInfo(index)" :src="item.url" mode="aspectFill"></image>
  33. <image class="add-img-del" @click.stop="delImg(index)" src="/static/img/delete.png"></image>
  34. </view>
  35. <view v-if="imgList.length < 9" class="add-img-item" @click.stop="scImg()">
  36. <image class="add-img" src="/static/img/add.png"></image>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <view @click.stop="submit" class="address-box submit-box"><text class="submit-btn">提交评论</text></view>
  44. <canvas canvas-id="canvas" v-if="canvasStatus"
  45. :style="{width: canvasWidth + 'px', height: canvasHeight + 'px',position: 'absolute',left:'-100000px',top:'-100000px'}"></canvas>
  46. <uni-popup ref="popup" type="center">
  47. <view class="alertprogress">
  48. {{progress}}%
  49. </view>
  50. </uni-popup>
  51. </view>
  52. </template>
  53. <script>
  54. import { product, upload, order_comment } from '@/api/order.js';
  55. import uniRate from '@/components/uni-rate/uni-rate.vue';
  56. export default {
  57. components: {
  58. uniRate
  59. },
  60. data() {
  61. return {
  62. list: '', //订单详情
  63. productInfo: '',
  64. text: '', //评论内容
  65. placeholder: '商品满足你的期待么?说说你的想法,分享给想买的他们吧~',
  66. imgList: [],
  67. unique: '', //商品唯一标识码
  68. cloudimgList: [],
  69. rateValue1: '', //商品质量
  70. rateValue2: '', //服务态度
  71. imgCount: 6 ,//最多支持9张上传,可以修改
  72. upFileLoding:false,
  73. canvasStatus: false,
  74. canvasWidth:0,
  75. canvasHeight:0,
  76. progress:0,
  77. };
  78. },
  79. onLoad(option) {
  80. this.unique = option.unique;
  81. this.loadOrder();
  82. },
  83. onShow() {},
  84. methods: {
  85. //text
  86. bindTextAreaBlur: function(e) {
  87. this.text = e.detail.value;
  88. },
  89. //获取收入支出信息
  90. async loadOrder() {
  91. product({
  92. unique: this.unique
  93. }).then(e => {
  94. this.list = e.data;
  95. this.productInfo = e.data.productInfo;
  96. });
  97. },
  98. //商品质量评分
  99. rateChange1(val) {
  100. this.rateValue1 = val.value;
  101. },
  102. //服务态度评分
  103. rateChange2(val) {
  104. this.rateValue2 = val.value;
  105. },
  106. //单张上传图片
  107. scImg() {
  108. const that = this;
  109. if (that.upFileLoding) {
  110. return
  111. }
  112. that.upFileLoding = true;
  113. setTimeout(()=>{
  114. that.upFileLoding = false;
  115. },1000);
  116. if (that.imgCount == 0) {
  117. uni.showToast({
  118. title: '最多添加6张图片',
  119. icon: 'none'
  120. });
  121. return;
  122. }
  123. that.canvasStatus = true;
  124. upload({
  125. filename: ''
  126. }, (res) => {
  127. that.imgList = [...that.imgList, ...res];
  128. that.imgCount = 10 - that.imgList.length;
  129. that.canvasStatus = false
  130. }, (res) => {
  131. that.canvasStatus = false
  132. }, (res) => {
  133. that.canvasWidth = res.w
  134. that.canvasHeight = res.h
  135. },(res)=>{
  136. // console.log(res,'res');
  137. if(res.progress==100){
  138. this.$refs.popup.close()
  139. uni.showToast({
  140. title: '上传成功'
  141. });
  142. }else if(res.progress==0){
  143. this.$refs.popup.open()
  144. }
  145. that.progress = res.progress;
  146. // console.log(res,'进度条');
  147. })
  148. },
  149. //提交评论
  150. submit(e) {
  151. let obj = this;
  152. if (obj.imgList.length < 1) {
  153. uni.showToast({
  154. title: '请添加图片',
  155. icon: 'none'
  156. });
  157. return;
  158. }
  159. for (let i = 0; i < obj.imgList.length; i++) {
  160. obj.cloudimgList.push(obj.imgList[i].url);
  161. }
  162. let arr = obj.cloudimgList.join(',');
  163. order_comment({
  164. pics: arr,
  165. comment: obj.text,
  166. product_score: obj.rateValue1,
  167. service_score: obj.rateValue2,
  168. unique: obj.unique,
  169. })
  170. .then(e => {
  171. uni.navigateTo({
  172. url: '/pages/order/order?state=4'
  173. });
  174. })
  175. .catch(e => {
  176. uni.navigateTo({
  177. url: '/pages/order/order?state=4'
  178. });
  179. });
  180. },
  181. //点击图片显示大图
  182. imgInfo(i) {
  183. let tempList = [];
  184. console.log(111);
  185. this.imgList.forEach(e => {
  186. tempList.push(e.url);
  187. });
  188. console.log(tempList);
  189. //显示图片
  190. uni.previewImage({
  191. current: i,
  192. loop: false,
  193. urls: tempList,
  194. indicator: 'default'
  195. });
  196. },
  197. //删除图片
  198. delImg(i) {
  199. uni.showModal({
  200. content: '确定删除这张吗',
  201. success: res => {
  202. if (res.confirm) {
  203. this.imgList.splice(i, 1);
  204. this.imgCount++;
  205. } else if (res.cancel) {
  206. }
  207. }
  208. });
  209. },
  210. // 页面跳转
  211. navto(e) {
  212. uni.navigateTo({
  213. url: e
  214. });
  215. }
  216. }
  217. };
  218. </script>
  219. <style lang="scss">
  220. page {
  221. background: #ffffff;
  222. height: 100%;
  223. .content {
  224. background: #ffffff;
  225. height: 100%;
  226. }
  227. }
  228. /* 多条商品 */
  229. .order-item {
  230. display: flex;
  231. flex-direction: column;
  232. padding: 0rpx 30rpx;
  233. background: #fff;
  234. margin-top: 20rpx;
  235. /* 单条商品 */
  236. .goods-box-single {
  237. display: flex;
  238. padding: 20rpx 0;
  239. .goods-img {
  240. display: block;
  241. width: 120rpx;
  242. height: 120rpx;
  243. }
  244. .right {
  245. flex: 1;
  246. display: flex;
  247. flex-direction: column;
  248. padding: 0 30rpx 0 24rpx;
  249. overflow: hidden;
  250. height: 100%;
  251. .title {
  252. align-self: flex-start;
  253. font-size: $font-base + 2rpx;
  254. color: $font-color-dark;
  255. height: 80rpx;
  256. overflow:hidden;
  257. text-overflow:ellipsis;
  258. display:-webkit-box;
  259. -webkit-box-orient:vertical;
  260. -webkit-line-clamp:2;
  261. }
  262. .title-right {
  263. flex-shrink: 0;
  264. text-align: right;
  265. align-self: flex-start;
  266. }
  267. .attr-box {
  268. font-size: $font-sm + 2rpx;
  269. color: $font-color-light;
  270. }
  271. .price {
  272. font-size: $font-base + 2rpx;
  273. color: $font-color-dark;
  274. &:before {
  275. content: '¥';
  276. font-size: $font-sm;
  277. margin: 0 2rpx 0 8rpx;
  278. }
  279. }
  280. }
  281. }
  282. }
  283. .equity_box {
  284. background-color: #fafafa;
  285. border-radius: 10rpx;
  286. padding: 25rpx 25rpx;
  287. margin: 25rpx 0rpx;
  288. .text-box {
  289. height: 200rpx;
  290. textarea {
  291. font-size: 25rpx;
  292. width: 100%;
  293. height: 100%;
  294. overflow: hidden;
  295. text-overflow: ellipsis;
  296. display: -webkit-box;
  297. -webkit-box-orient: vertical;
  298. -webkit-line-clamp: 5;
  299. }
  300. }
  301. }
  302. .zhil {
  303. font-size: 28rpx !important;
  304. padding: 15rpx 15rpx;
  305. }
  306. .submit-box {
  307. bottom: 0;
  308. left: 0;
  309. width: 750rpx;
  310. }
  311. .submit-btn {
  312. margin-top: 10px;
  313. display: inline-block;
  314. width: 670rpx;
  315. height: 96rpx;
  316. line-height: 96rpx;
  317. text-align: center;
  318. background-color: #1BCC26 !important;
  319. opacity: 1;
  320. border-radius: 32rpx;
  321. border-width: 8rpx;
  322. border-color: rgba(255, 255, 255, 1);
  323. box-shadow: 0rpx 8rpx 12rpx rgba(0, 0, 0, 0.16);
  324. border-radius: 56rpx;
  325. font-size: 39rpx;
  326. font-weight: bold;
  327. color: rgba(255, 255, 255, 1);
  328. }
  329. .submit-btn-txt {
  330. font-size: 39rpx;
  331. font-weight: bold;
  332. line-height: 47rpx;
  333. color: rgba(255, 255, 255, 1);
  334. opacity: 1;
  335. }
  336. .map-box {
  337. width: 484rpx;
  338. height: 256rpx;
  339. border-width: 4rpx;
  340. border-color: rgba(255, 255, 255, 1);
  341. box-shadow: 0rpx 0rpx 24rpx rgba(0, 0, 0, 0.16);
  342. /* border-radius: 12rpx; */
  343. position: relative;
  344. }
  345. .map {
  346. position: absolute;
  347. top: 0;
  348. left: 0;
  349. right: 0;
  350. bottom: 0;
  351. width: 476rpx;
  352. height: 250rpx;
  353. }
  354. .map-img {
  355. position: absolute;
  356. top: 90rpx;
  357. left: 156rpx;
  358. width: 230rpx;
  359. height: 68rpx;
  360. background-color: rgba(51, 51, 51, 0.64);
  361. border-width: 1rpx;
  362. border-color: rgba(0, 0, 0, 0);
  363. border-radius: 34px;
  364. font-size: 28rpx;
  365. font-weight: bold;
  366. line-height: 66rpx;
  367. color: rgba(255, 255, 255, 1);
  368. text-align: center;
  369. }
  370. .address-box {
  371. padding: 15rpx 40rpx;
  372. margin-bottom: 10px;
  373. }
  374. .label {
  375. font-size: 36rpx;
  376. font-weight: bold;
  377. line-height: 50rpx;
  378. color: #222222;
  379. }
  380. .label-img {
  381. padding-left: 40rpx;
  382. }
  383. .add-img-box {
  384. width: 100%;
  385. flex-direction: row;
  386. flex-wrap: wrap;
  387. margin-top: 50rpx;
  388. }
  389. .add-img-item {
  390. width: 180rpx;
  391. height: 180rpx;
  392. border-radius: 24rpx;
  393. position: relative;
  394. margin: 0rpx 20rpx;
  395. margin-bottom: 25rpx;
  396. .add-img {
  397. width: 100%;
  398. height: 100%;
  399. border-radius: 24rpx;
  400. }
  401. }
  402. .add-img-camera {
  403. flex: 1;
  404. }
  405. .add-img-del {
  406. position: absolute;
  407. width: 40rpx;
  408. height: 40rpx;
  409. left: 155rpx;
  410. bottom: 155rpx;
  411. //background-color: rgba(238, 0, 0, 1);
  412. border-radius: 20rpx;
  413. }
  414. .address-time {
  415. width: 484rpx;
  416. height: 88rpx;
  417. background-color: rgba(245, 245, 245, 1);
  418. opacity: 1;
  419. border-radius: 24rpx;
  420. text-align: center;
  421. font-size: 35rpx;
  422. font-weight: 500;
  423. color: rgba(51, 51, 51, 1);
  424. }
  425. .line {
  426. width: 750rpx;
  427. height: 1px;
  428. transform: scaleY(0.3);
  429. background-color: rgba(0, 0, 0, 0.5);
  430. }
  431. </style>