evaluate.vue 8.7 KB

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