evaluate.vue 12 KB

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