evaluate.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  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 v-if="rateValue1 != ''">
  20. <uniRate text="1" size="20" margin="10" :value="rateValue1" @change="rateChange1"></uniRate>
  21. </view>
  22. </view>
  23. <view class="flex_item zhil">
  24. <view>服务态度</view>
  25. <view v-if="rateValue2 != ''">
  26. <uniRate text="1" size="20" margin="10" :value="rateValue2" @change="rateChange2"></uniRate>
  27. </view>
  28. </view>
  29. <view class="list">
  30. <view class="list-left">标题:</view>
  31. <input type="text" v-model="title" placeholder-class="placeholder" class="list-input"
  32. placeholder="请填写评论的标题" />
  33. </view>
  34. <view class="upload-box">
  35. <view class="upload-left">主图</view>
  36. <view class="upload-right" @click.stop="scImgMian()">
  37. <image v-if="!main_pic" class="upload-img " src="/static/img/add.png"></image>
  38. <image v-if="main_pic" class="upload-img " :src="main_pic"></image>
  39. </view>
  40. </view>
  41. <view class="equity_box">
  42. <view class="text-box uni-textarea"><textarea placeholder-style="color:#999"
  43. :placeholder="placeholder" v-model="text"></textarea></view>
  44. <view class="">
  45. <view class="add-img-box flex_item">
  46. <view class="add-img-item" v-for="(item, index) in imgList" :key="index">
  47. <image class="add-img" @click.stop="imgInfo(index)" :src="item.url" mode="aspectFill">
  48. </image>
  49. <image class="add-img-del" @click.stop="delImg(index)" src="/static/img/delete.png">
  50. </image>
  51. </view>
  52. <view v-if="imgList.length < 9" class="add-img-item" @click.stop="scImg()">
  53. <image class="add-img" src="/static/img/add.png"></image>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <view @click.stop="submit" class="address-box submit-box"><text class="submit-btn">提交评论</text></view>
  61. <!-- <view @click.stop="submit1" class="address-box submit-box"><text class="submit-btn gren">保存草稿</text></view> -->
  62. </view>
  63. </template>
  64. <script>
  65. import {
  66. product,
  67. upload,
  68. order_comment
  69. } from '@/api/order.js';
  70. import {
  71. save_comment,
  72. reply_save
  73. } from '@/api/activity.js';
  74. import uniRate from '@/components/uni-rate/uni-rate.vue';
  75. export default {
  76. components: {
  77. uniRate
  78. },
  79. data() {
  80. return {
  81. id: '',
  82. title: '', //标题
  83. main_pic: '', //主图
  84. list: '', //订单详情
  85. productInfo: '',
  86. text: '', //评论内容
  87. placeholder: '商品满足你的期待么?说说你的想法,分享给想买的他们吧~',
  88. imgList: [],
  89. unique: '', //商品唯一标识码
  90. cloudimgList: [],
  91. rateValue1: '', //商品质量
  92. rateValue2: '', //服务态度
  93. imgCount: 9 //最多支持9张上传,可以修改
  94. };
  95. },
  96. onLoad(option) {
  97. if (option.unique) {
  98. this.unique = option.unique;
  99. this.rateValue1 = '0';
  100. this.rateValue2 = '0';
  101. this.loadOrder();
  102. }
  103. if (option.id) {
  104. this.id = option.id;
  105. this.loadData();
  106. }
  107. },
  108. onShow() {},
  109. methods: {
  110. //text
  111. bindTextAreaBlur: function(e) {
  112. this.text = e.detail.value;
  113. },
  114. //获取收入支出信息
  115. async loadOrder() {
  116. product({
  117. unique: this.unique
  118. }).then(e => {
  119. this.list = e.data;
  120. this.productInfo = e.data.productInfo;
  121. });
  122. },
  123. loadData() {
  124. reply_save({}, this.id).then(({
  125. data
  126. }) => {
  127. this.unique = data.unique;
  128. this.title = data.title;
  129. this.main_pic = data.main_pic;
  130. for (let i = 0; i < data.pics.length; i++) {
  131. let url = {
  132. url: data.pics[i]
  133. };
  134. this.imgList.push(url);
  135. }
  136. this.text = data.comment;
  137. this.rateValue1 = data.product_score + '';
  138. this.rateValue2 = data.service_score + '';
  139. this.loadOrder();
  140. console.log(this.rateValue1, '12456');
  141. });
  142. },
  143. //商品质量评分
  144. rateChange1(val) {
  145. this.rateValue1 = val.value;
  146. },
  147. //服务态度评分
  148. rateChange2(val) {
  149. this.rateValue2 = val.value;
  150. },
  151. //单张上传图片
  152. scImg() {
  153. let obj = this;
  154. console.log(obj.imgCount, 11);
  155. if (obj.imgCount == 0) {
  156. uni.showToast({
  157. title: '最多添加9张图片',
  158. icon: 'none'
  159. });
  160. return;
  161. }
  162. upload({
  163. file: ''
  164. })
  165. .then(e => {
  166. console.log(e, 'e');
  167. obj.imgList = [...obj.imgList, ...e];
  168. console.log(obj.imgList, 'imgList');
  169. obj.imgCount = 10 - obj.imgList.length;
  170. console.log(obj.imgCount, 'imgCount ');
  171. })
  172. .catch(e => {});
  173. },
  174. scImgMian() {
  175. let obj = this;
  176. upload({
  177. file: ''
  178. })
  179. .then(e => {
  180. console.log(e, 'e');
  181. obj.main_pic = e[0].url;
  182. })
  183. .catch(e => {});
  184. },
  185. //提交评论
  186. submit(e) {
  187. let obj = this;
  188. if (obj.imgList.length < 1) {
  189. uni.showToast({
  190. title: '请添加图片',
  191. icon: 'none'
  192. });
  193. return;
  194. }
  195. for (let i = 0; i < obj.imgList.length; i++) {
  196. obj.cloudimgList.push(obj.imgList[i].url);
  197. }
  198. let arr = obj.cloudimgList.join(',');
  199. order_comment({
  200. pics: arr,
  201. comment: obj.text,
  202. product_score: obj.rateValue1,
  203. service_score: obj.rateValue2,
  204. unique: obj.unique,
  205. main_pic: obj.main_pic,
  206. title: obj.title
  207. })
  208. .then(e => {
  209. uni.navigateTo({
  210. url: '/pages/order/order?state=4'
  211. });
  212. })
  213. .catch(e => {
  214. uni.navigateTo({
  215. url: '/pages/order/order?state=4'
  216. });
  217. });
  218. },
  219. // 保存草稿
  220. submit1(e) {
  221. let obj = this;
  222. if (obj.imgList.length < 1) {
  223. uni.showToast({
  224. title: '请添加图片',
  225. icon: 'none'
  226. });
  227. return;
  228. }
  229. for (let i = 0; i < obj.imgList.length; i++) {
  230. obj.cloudimgList.push(obj.imgList[i].url);
  231. }
  232. let arr = obj.cloudimgList.join(',');
  233. save_comment({
  234. pics: arr,
  235. comment: obj.text,
  236. product_score: obj.rateValue1,
  237. service_score: obj.rateValue2,
  238. unique: obj.unique,
  239. main_pic: obj.main_pic,
  240. title: obj.title
  241. })
  242. .then(e => {
  243. uni.navigateTo({
  244. url: '/pages/user/creation?id=0'
  245. });
  246. })
  247. .catch(e => {});
  248. },
  249. //点击图片显示大图
  250. imgInfo(i) {
  251. let tempList = [];
  252. console.log(111);
  253. this.imgList.forEach(e => {
  254. tempList.push(e.url);
  255. });
  256. console.log(tempList);
  257. //显示图片
  258. uni.previewImage({
  259. current: i,
  260. loop: false,
  261. urls: tempList,
  262. indicator: 'default'
  263. });
  264. },
  265. //删除图片
  266. delImg(i) {
  267. uni.showModal({
  268. content: '确定删除这张吗',
  269. success: res => {
  270. if (res.confirm) {
  271. this.imgList.splice(i, 1);
  272. this.imgCount++;
  273. } else if (res.cancel) {}
  274. }
  275. });
  276. },
  277. // 页面跳转
  278. navto(e) {
  279. uni.navigateTo({
  280. url: e
  281. });
  282. }
  283. }
  284. };
  285. </script>
  286. <style lang="scss">
  287. page {
  288. background: #ffffff;
  289. height: 100%;
  290. .content {
  291. background: #ffffff;
  292. height: 100%;
  293. }
  294. }
  295. /* 多条商品 */
  296. .order-item {
  297. display: flex;
  298. flex-direction: column;
  299. padding: 0rpx 30rpx;
  300. background: #fff;
  301. margin-top: 20rpx;
  302. /* 单条商品 */
  303. .goods-box-single {
  304. display: flex;
  305. padding: 20rpx 0;
  306. .goods-img {
  307. display: block;
  308. width: 120rpx;
  309. height: 120rpx;
  310. }
  311. .right {
  312. flex: 1;
  313. display: flex;
  314. flex-direction: column;
  315. padding: 0 30rpx 0 24rpx;
  316. overflow: hidden;
  317. height: 100%;
  318. .title {
  319. align-self: flex-start;
  320. font-size: $font-base + 2rpx;
  321. color: $font-color-dark;
  322. height: 80rpx;
  323. overflow: hidden;
  324. text-overflow: ellipsis;
  325. display: -webkit-box;
  326. -webkit-box-orient: vertical;
  327. -webkit-line-clamp: 2;
  328. }
  329. .title-right {
  330. flex-shrink: 0;
  331. text-align: right;
  332. align-self: flex-start;
  333. }
  334. .attr-box {
  335. font-size: $font-sm + 2rpx;
  336. color: $font-color-light;
  337. }
  338. .price {
  339. font-size: $font-base + 2rpx;
  340. color: $font-color-dark;
  341. &:before {
  342. content: '¥';
  343. font-size: $font-sm;
  344. margin: 0 2rpx 0 8rpx;
  345. }
  346. }
  347. }
  348. }
  349. }
  350. .equity_box {
  351. background-color: #fafafa;
  352. border-radius: 10rpx;
  353. padding: 25rpx 25rpx;
  354. margin: 25rpx 0rpx;
  355. .text-box {
  356. height: 200rpx;
  357. textarea {
  358. font-size: 25rpx;
  359. width: 100%;
  360. height: 100%;
  361. overflow: hidden;
  362. text-overflow: ellipsis;
  363. display: -webkit-box;
  364. -webkit-box-orient: vertical;
  365. -webkit-line-clamp: 5;
  366. }
  367. }
  368. }
  369. .zhil {
  370. font-size: 28rpx !important;
  371. padding: 15rpx 15rpx;
  372. }
  373. .submit-box {
  374. bottom: 0;
  375. left: 0;
  376. width: 750rpx;
  377. }
  378. .submit-btn {
  379. margin-top: 10px;
  380. display: inline-block;
  381. width: 670rpx;
  382. height: 96rpx;
  383. line-height: 96rpx;
  384. text-align: center;
  385. background-color: #000000;
  386. opacity: 1;
  387. box-shadow: 0rpx 8rpx 12rpx rgba(0, 0, 0, 0.16);
  388. border-radius: 56rpx;
  389. font-size: 39rpx;
  390. font-weight: bold;
  391. color: rgba(255, 255, 255, 1);
  392. }
  393. .gren {
  394. background: #ffffff;
  395. color: #000000;
  396. border: 1px solid #000000;
  397. }
  398. .submit-btn-txt {
  399. font-size: 39rpx;
  400. font-weight: bold;
  401. line-height: 47rpx;
  402. color: rgba(255, 255, 255, 1);
  403. opacity: 1;
  404. }
  405. .map-box {
  406. width: 484rpx;
  407. height: 256rpx;
  408. border-width: 4rpx;
  409. border-color: rgba(255, 255, 255, 1);
  410. box-shadow: 0rpx 0rpx 24rpx rgba(0, 0, 0, 0.16);
  411. /* border-radius: 12rpx; */
  412. position: relative;
  413. }
  414. .map {
  415. position: absolute;
  416. top: 0;
  417. left: 0;
  418. right: 0;
  419. bottom: 0;
  420. width: 476rpx;
  421. height: 250rpx;
  422. }
  423. .map-img {
  424. position: absolute;
  425. top: 90rpx;
  426. left: 156rpx;
  427. width: 230rpx;
  428. height: 68rpx;
  429. background-color: rgba(51, 51, 51, 0.64);
  430. border-width: 1rpx;
  431. border-color: rgba(0, 0, 0, 0);
  432. border-radius: 34px;
  433. font-size: 28rpx;
  434. font-weight: bold;
  435. line-height: 66rpx;
  436. color: rgba(255, 255, 255, 1);
  437. text-align: center;
  438. }
  439. .address-box {
  440. padding: 15rpx 40rpx;
  441. margin-bottom: 10px;
  442. }
  443. .label {
  444. font-size: 36rpx;
  445. font-weight: bold;
  446. line-height: 50rpx;
  447. color: #222222;
  448. }
  449. .label-img {
  450. padding-left: 40rpx;
  451. }
  452. .add-img-box {
  453. width: 100%;
  454. flex-direction: row;
  455. flex-wrap: wrap;
  456. margin-top: 50rpx;
  457. }
  458. .add-img-item {
  459. width: 180rpx;
  460. height: 180rpx;
  461. border-radius: 24rpx;
  462. position: relative;
  463. margin: 0rpx 20rpx;
  464. margin-bottom: 25rpx;
  465. .add-img {
  466. width: 100%;
  467. height: 100%;
  468. border-radius: 24rpx;
  469. }
  470. }
  471. .add-img-camera {
  472. flex: 1;
  473. }
  474. .add-img-del {
  475. position: absolute;
  476. width: 40rpx;
  477. height: 40rpx;
  478. left: 155rpx;
  479. bottom: 155rpx;
  480. //background-color: rgba(238, 0, 0, 1);
  481. border-radius: 20rpx;
  482. }
  483. .address-time {
  484. width: 484rpx;
  485. height: 88rpx;
  486. background-color: rgba(245, 245, 245, 1);
  487. opacity: 1;
  488. border-radius: 24rpx;
  489. text-align: center;
  490. font-size: 35rpx;
  491. font-weight: 500;
  492. color: rgba(51, 51, 51, 1);
  493. }
  494. .line {
  495. width: 750rpx;
  496. height: 1px;
  497. transform: scaleY(0.3);
  498. background-color: rgba(0, 0, 0, 0.5);
  499. }
  500. .list {
  501. display: flex;
  502. flex-direction: column;
  503. align-items: center;
  504. width: 100%;
  505. margin-top: 32rpx;
  506. // height: 133rpx;
  507. .list-left {
  508. width: 100%;
  509. text-align: left;
  510. font-size: 28rpx;
  511. }
  512. input {
  513. height: 66rpx;
  514. margin-top: 32rpx;
  515. }
  516. .list-input {
  517. padding: 10rpx 24rpx;
  518. // margin: 12rpx 0 ;
  519. display: flex;
  520. justify-content: center;
  521. // line-height: 66rpx;
  522. display: flex;
  523. align-items: center;
  524. width: 100%;
  525. flex: 1;
  526. color: #000000;
  527. border: 1rpx solid #000000;
  528. border-radius: 22rpx;
  529. text-align: left;
  530. padding-right: 24rpx;
  531. .input-placeholder {
  532. height: 70rpx;
  533. color: #000000;
  534. }
  535. }
  536. }
  537. .upload-box {
  538. width: 100%;
  539. background: #ffffff;
  540. // border: 1px solid #E63931;
  541. border-radius: 27rpx;
  542. display: flex;
  543. flex-direction: column;
  544. padding: 30rpx 40rpx 30rpx 0;
  545. margin: 0 auto 30rpx;
  546. .upload-left {
  547. font-weight: 400;
  548. font-size: 28rpx;
  549. }
  550. .upload-right {
  551. flex: 1;
  552. display: flex;
  553. align-items: center;
  554. justify-content: center;
  555. .upload-img {
  556. width: 200rpx;
  557. height: 200rpx;
  558. margin-top: 20rpx;
  559. }
  560. }
  561. }
  562. </style>