evaluate.vue 12 KB

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