evaluate.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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 class="padding-l-10"><uni-rate text="1" size="20" margin="10" :value="rateValue1" @change="rateChange1"></uni-rate></view>
  20. </view>
  21. <view class="flex_item zhil">
  22. <view>服务态度</view>
  23. <view class="padding-l-10"><uni-rate text="1" size="20" margin="10" :value="rateValue2" @change="rateChange2"></uni-rate></view>
  24. </view>
  25. <view class="equity_box">
  26. <textarea class="text-box" auto-height placeholder-style="color:#999" :placeholder="placeholder" @blur="bindTextAreaBlur"></textarea>
  27. <view class="add-img-box flex_item">
  28. <view class="add-img-item" v-for="(item, index) in imgList" :key="index">
  29. <image class="add-img" @click.stop="imgInfo(index)" :src="item.url" mode="aspectFill"></image>
  30. <image class="add-img-del" @click.stop="delImg(index)" src="/static/image/delete.png"></image>
  31. </view>
  32. <view v-if="imgList.length < 9" class="add-img-item" @click.stop="scImg()">
  33. <image class="add-img" src="/static/image/upImg.png"></image>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="base-buttom" @click="submit">
  40. 提交评论
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import { product, upload, order_comment } from '@/api/order.js';
  46. export default {
  47. data() {
  48. return {
  49. list: '', //订单详情
  50. productInfo: '',
  51. text: '', //评论内容
  52. placeholder: '商品满足你的期待么?说说你的想法,分享给想买的他们吧~',
  53. imgList: [],
  54. unique: '', //商品唯一标识码
  55. cloudimgList: [],
  56. rateValue1: '', //商品质量
  57. rateValue2: '', //服务态度
  58. imgCount: 6 //最多支持9张上传,可以修改
  59. };
  60. },
  61. onLoad(option) {
  62. this.unique = option.unique;
  63. this.loadOrder();
  64. },
  65. onShow() {},
  66. methods: {
  67. //text
  68. bindTextAreaBlur: function(e) {
  69. this.text = e.detail.value;
  70. },
  71. //获取收入支出信息
  72. async loadOrder() {
  73. product({
  74. unique: this.unique
  75. }).then(e => {
  76. this.list = e.data;
  77. this.productInfo = e.data.productInfo;
  78. });
  79. },
  80. //商品质量评分
  81. rateChange1(val) {
  82. this.rateValue1 = val.value;
  83. },
  84. //服务态度评分
  85. rateChange2(val) {
  86. this.rateValue2 = val.value;
  87. },
  88. //单张上传图片
  89. scImg() {
  90. let obj = this;
  91. console.log(obj.imgCount, 11);
  92. if (obj.imgCount == 0) {
  93. uni.showToast({
  94. title: '最多添加6张图片',
  95. icon: 'none'
  96. });
  97. return;
  98. }
  99. upload({
  100. file: ''
  101. })
  102. .then(e => {
  103. console.log(e,'e')
  104. obj.imgList = [...obj.imgList, ...e];
  105. console.log(obj.imgList,'imgList')
  106. obj.imgCount = 10 - obj.imgList.length;
  107. console.log(obj.imgCount ,'imgCount ')
  108. })
  109. .catch(e => {});
  110. },
  111. //提交评论
  112. submit(e) {
  113. let obj = this;
  114. // if (obj.imgList.length < 1) {
  115. // uni.showToast({
  116. // title: '请添加图片',
  117. // icon: 'none'
  118. // });
  119. // return;
  120. // }
  121. for (let i = 0; i < obj.imgList.length; i++) {
  122. obj.cloudimgList.push(obj.imgList[i].url);
  123. }
  124. let arr = obj.cloudimgList.join(',');
  125. order_comment({
  126. pics: arr,
  127. comment: obj.text,
  128. product_score: obj.rateValue1,
  129. service_score: obj.rateValue2,
  130. unique: obj.unique,
  131. })
  132. .then(e => {
  133. uni.reLaunch({
  134. url: '/pages/home/order'
  135. });
  136. })
  137. .catch(e => {
  138. uni.reLaunch({
  139. url: '/pages/home/order'
  140. });
  141. });
  142. },
  143. //点击图片显示大图
  144. imgInfo(i) {
  145. let tempList = [];
  146. console.log(111);
  147. this.imgList.forEach(e => {
  148. tempList.push(e.url);
  149. });
  150. console.log(tempList);
  151. //显示图片
  152. uni.previewImage({
  153. current: i,
  154. loop: false,
  155. urls: tempList,
  156. indicator: 'default'
  157. });
  158. },
  159. //删除图片
  160. delImg(i) {
  161. uni.showModal({
  162. content: '确定删除这张吗',
  163. success: res => {
  164. if (res.confirm) {
  165. this.imgList.splice(i, 1);
  166. this.imgCount++;
  167. } else if (res.cancel) {
  168. }
  169. }
  170. });
  171. },
  172. // 页面跳转
  173. navto(e) {
  174. uni.navigateTo({
  175. url: e
  176. });
  177. }
  178. }
  179. };
  180. </script>
  181. <style lang="scss">
  182. page {
  183. background: #ffffff;
  184. height: 100%;
  185. .content {
  186. background: #ffffff;
  187. height: 100%;
  188. }
  189. }
  190. /* 多条商品 */
  191. .order-item {
  192. display: flex;
  193. flex-direction: column;
  194. padding: 0rpx 30rpx;
  195. background: #fff;
  196. margin-top: 20rpx;
  197. /* 单条商品 */
  198. .goods-box-single {
  199. display: flex;
  200. padding: 20rpx 0;
  201. .goods-img {
  202. display: block;
  203. width: 120rpx;
  204. height: 120rpx;
  205. }
  206. .right {
  207. flex: 1;
  208. display: flex;
  209. flex-direction: column;
  210. padding: 0 30rpx 0 24rpx;
  211. overflow: hidden;
  212. height: 100%;
  213. .title {
  214. align-self: flex-start;
  215. font-size: $font-base + 2rpx;
  216. color: $font-color-dark;
  217. height: 80rpx;
  218. overflow:hidden;
  219. text-overflow:ellipsis;
  220. display:-webkit-box;
  221. -webkit-box-orient:vertical;
  222. -webkit-line-clamp:2;
  223. }
  224. .title-right {
  225. flex-shrink: 0;
  226. text-align: right;
  227. align-self: flex-start;
  228. }
  229. .attr-box {
  230. font-size: $font-sm + 2rpx;
  231. color: $font-color-light;
  232. }
  233. .price {
  234. font-size: $font-base + 2rpx;
  235. color: $font-color-dark;
  236. &:before {
  237. content: '¥';
  238. font-size: $font-sm;
  239. margin: 0 2rpx 0 8rpx;
  240. }
  241. }
  242. }
  243. }
  244. }
  245. .equity_box {
  246. background-color: #fafafa;
  247. border-radius: 10rpx;
  248. padding: 25rpx 25rpx;
  249. margin: 25rpx 0rpx;
  250. .text-box {
  251. font-size: 25rpx;
  252. width: 100%;
  253. }
  254. }
  255. .zhil {
  256. font-size: 28rpx !important;
  257. padding: 15rpx 15rpx;
  258. }
  259. .add-img-box {
  260. width: 100%;
  261. flex-direction: row;
  262. flex-wrap: wrap;
  263. margin-top: 30rpx;
  264. }
  265. .add-img-item {
  266. width: 190rpx;
  267. height: 190rpx;
  268. border-radius: 24rpx;
  269. position: relative;
  270. margin-right: 20rpx;
  271. margin-bottom: 25rpx;
  272. .add-img {
  273. width: 100%;
  274. height: 100%;
  275. border-radius: 24rpx;
  276. }
  277. }
  278. .add-img-del {
  279. position: absolute;
  280. width: 40rpx;
  281. height: 40rpx;
  282. left: 155rpx;
  283. bottom: 155rpx;
  284. //background-color: rgba(238, 0, 0, 1);
  285. border-radius: 20rpx;
  286. }
  287. </style>