appraise.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <view class="page">
  3. <view v-for="(item, index) in orderDetail.productList" :key="index">
  4. <view class="goods-box-single">
  5. <image class="goods-img" :src="JSON.parse(item.img)[0].url" mode="aspectFill"></image>
  6. <view class="right">
  7. <text class="title clamp">{{item.productTitle}}</text>
  8. <text class="attr-box">{{item.productTitle}} x {{item.num}}</text>
  9. <text class="price">{{item.price}}</text>
  10. </view>
  11. </view>
  12. <view class='appraise-title appraise-star-view'>
  13. <text>宝贝评分</text>
  14. <view class="appraise-star-view">
  15. <text class="appraise-star" v-for="(value,key) in stars" :key="key" :class="key < orderDetail.productList[index].score ? 'active' : ''"
  16. @tap="chooseStar(value,index)"></text>
  17. </view>
  18. </view>
  19. <view class="appraise-body">
  20. <textarea placeholder="请输入评价(可空)..." v-model="item.content" class="appraise-textare" />
  21. </view>
  22. <view class="appraise-body appraise-uploader">
  23. <view class="uni-uploader">
  24. <view class="uni-uploader-head">
  25. <view class="uni-uploader-title" style="color: #6f6f74;">晒一晒</view>
  26. <view class="uni-uploader-info">{{item.imgs.length}}/8</view>
  27. </view>
  28. <view class="uni-uploader-body">
  29. <view class="uni-uploader__files">
  30. <block v-for="(image,imgIndex) in item.imgs" :key="imgIndex">
  31. <view class="uni-uploader__file" style="position: relative;">
  32. <image class="uni-uploader__img" :src="image" @tap="previewImage"></image>
  33. <view class="close-view" @click="close(item, index, imgIndex)">x</view>
  34. </view>
  35. </block>
  36. <!-- <view class="uni-uploader__input-box" v-show="imageList.length < 8">-->
  37. <!-- <view class="uni-uploader__input" @tap="chooseImg(item,index)"></view>-->
  38. <!-- </view>-->
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <button type="primary" class="appraise-submit" @tap="send">提交</button>
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. data() {
  50. return {
  51. stars: [1, 2, 3, 4, 5],
  52. imageList: [],
  53. sendDate: {
  54. score: 0,
  55. content: "",
  56. contact: ""
  57. },
  58. orderDetail: {
  59. productList: []
  60. },
  61. appraiseRequest: {
  62. appraiseDTOList: []
  63. }
  64. }
  65. },
  66. onLoad(option) {
  67. const that = this
  68. uni.showLoading({
  69. title: '正在加载'
  70. })
  71. that.$api.request('get', 'order/app/getOrderDetail', {
  72. orderId : option.orderid
  73. }, failres => {
  74. uni.hideLoading()
  75. that.$api.msg(failres.msg)
  76. }).then(res => {
  77. uni.hideLoading()
  78. that.orderDetail = res.data
  79. that.orderDetail.productList.forEach(item => {
  80. item.score = 0
  81. item.content = ''
  82. item.imgs = []
  83. })
  84. })
  85. },
  86. methods: {
  87. close(item, index, imgIndex){
  88. item.imgs.splice(imgIndex,1);
  89. this.orderDetail.productList.splice(index, item)
  90. },
  91. chooseImg(item,index) { //选择图片
  92. const that = this
  93. that.$api.uploadImg(4,(res => {
  94. item.imgs.push(res)
  95. that.orderDetail.productList.splice(index, that.orderDetail.productList[index])
  96. }))
  97. },
  98. chooseStar(e,index) { //点击评星
  99. const that = this
  100. that.orderDetail.productList[index].score = e
  101. that.orderDetail.productList.splice(index, that.orderDetail.productList[index])
  102. },
  103. previewImage() { //预览图片
  104. uni.previewImage({
  105. urls: this.imageList
  106. });
  107. },
  108. send() { //发送反馈
  109. const that = this
  110. let msg = ''
  111. let requestItems = []
  112. that.orderDetail.productList.forEach(item => {
  113. if (item.content && item.score <= 0) {
  114. msg = '有评论内容的商品,请为宝贝点上星星!';
  115. return
  116. }
  117. if (item.score <= 0) {
  118. return
  119. }
  120. requestItems.push({
  121. productAttrId: item.productAttrId,
  122. productId: item.productId,
  123. score: item.score,
  124. content: item.content,
  125. imgUrl: item.imgs.length > 0 ? item.imgs.join(',') : ''
  126. })
  127. })
  128. if(msg){
  129. that.$api.msg('有评论内容的商品,请为宝贝点上星星!');
  130. return;
  131. }
  132. that.appraiseRequest.orderId = that.orderDetail.id
  133. that.appraiseRequest.storageId = that.orderDetail.storeId
  134. that.appraiseRequest.appraiseDTOList = requestItems
  135. that.$api.request('post', 'appraise/app/addAppraise', JSON.stringify(that.appraiseRequest)).then(res => {
  136. that.$api.msg('评价成功!')
  137. that.$api.prePage().loadData('refresh')
  138. uni.navigateBack()
  139. })
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="scss">
  145. page {
  146. background-color: #FFFFFF;
  147. }
  148. @font-face {
  149. font-family: uniicons;
  150. font-weight: normal;
  151. font-style: normal;
  152. src: url('https://img-cdn-qiniu.dcloud.net.cn/fonts/uni.ttf') format('truetype');
  153. }
  154. view{
  155. font-size: 28upx;
  156. }
  157. .input-view {
  158. font-size: 28upx;
  159. }
  160. .close-view{
  161. text-align: center;line-height:14px;height: 16px;width: 16px;border-radius: 50%;background: #FF5053;color: #FFFFFF;position: absolute;top: -6px;right: -4px;font-size: 12px;
  162. }
  163. /* 上传 */
  164. .uni-uploader {
  165. flex: 1;
  166. flex-direction: column;
  167. }
  168. .uni-uploader-head {
  169. display: flex;
  170. flex-direction: row;
  171. justify-content: space-between;
  172. }
  173. .uni-uploader-info {
  174. color: #B2B2B2;
  175. }
  176. .uni-uploader-body {
  177. margin-top: 16upx;
  178. }
  179. .uni-uploader__files {
  180. display: flex;
  181. flex-direction: row;
  182. flex-wrap: wrap;
  183. }
  184. .uni-uploader__file {
  185. margin: 10upx;
  186. width: 210upx;
  187. height: 210upx;
  188. }
  189. .uni-uploader__img {
  190. display: block;
  191. width: 210upx;
  192. height: 210upx;
  193. }
  194. .uni-uploader__input-box {
  195. position: relative;
  196. margin:10upx;
  197. width: 208upx;
  198. height: 208upx;
  199. border: 2upx solid #D9D9D9;
  200. }
  201. .uni-uploader__input-box:before,
  202. .uni-uploader__input-box:after {
  203. content: " ";
  204. position: absolute;
  205. top: 50%;
  206. left: 50%;
  207. -webkit-transform: translate(-50%, -50%);
  208. transform: translate(-50%, -50%);
  209. background-color: #D9D9D9;
  210. }
  211. .uni-uploader__input-box:before {
  212. width: 4upx;
  213. height: 79upx;
  214. }
  215. .uni-uploader__input-box:after {
  216. width: 79upx;
  217. height: 4upx;
  218. }
  219. .uni-uploader__input-box:active {
  220. border-color: #999999;
  221. }
  222. .uni-uploader__input-box:active:before,
  223. .uni-uploader__input-box:active:after {
  224. background-color: #999999;
  225. }
  226. .uni-uploader__input {
  227. position: absolute;
  228. z-index: 1;
  229. top: 0;
  230. left: 0;
  231. width: 100%;
  232. height: 100%;
  233. opacity: 0;
  234. }
  235. /*问题反馈*/
  236. .appraise-title {
  237. display: flex;
  238. flex-direction: row;
  239. justify-content: space-between;
  240. align-items: center;
  241. padding: 20upx;
  242. color: #6f6f74;
  243. background-color: #FFFFFF;
  244. font-size: 28upx;
  245. }
  246. .appraise-star-view.appraise-title {
  247. justify-content: flex-start;
  248. margin: 0;
  249. }
  250. .appraise-quick {
  251. position: relative;
  252. padding-right: 40upx;
  253. }
  254. .appraise-quick:after {
  255. font-family: uniicons;
  256. font-size: 40upx;
  257. content: '\e581';
  258. position: absolute;
  259. right: 0;
  260. top: 50%;
  261. color: #bbb;
  262. -webkit-transform: translateY(-50%);
  263. transform: translateY(-50%);
  264. }
  265. .appraise-body {
  266. background: #fff;
  267. }
  268. .appraise-textare {
  269. height: 200upx;
  270. font-size: 28upx;
  271. line-height: 34upx;
  272. width: 100%;
  273. box-sizing: border-box;
  274. padding: 20upx 30upx 0;
  275. }
  276. .appraise-input {
  277. font-size: 34upx;
  278. height: 50upx;
  279. min-height: 50upx;
  280. padding: 15upx 20upx;
  281. line-height: 50upx;
  282. }
  283. .appraise-uploader {
  284. padding: 22upx 20upx;
  285. }
  286. .appraise-star-view {
  287. margin-left: 20upx;
  288. }
  289. .appraise-star.active {
  290. color: #FFB400;
  291. }
  292. .appraise-star {
  293. font-size: 40upx;
  294. margin-left: 6upx;
  295. color: #ccc;
  296. }
  297. .appraise-star:after {
  298. content: '☆'; /* 空心星 */
  299. }
  300. .appraise-star.active:after {
  301. content: '★'; /* 实心星 */
  302. color: #FFB400;
  303. }
  304. .appraise-submit {
  305. background: #007AFF;
  306. color: #FFFFFF;
  307. margin: 20upx;
  308. }
  309. /* 单条商品 */
  310. .goods-box-single {
  311. display: flex;
  312. padding: 20upx;
  313. .goods-img {
  314. display: block;
  315. width: 120upx;
  316. height: 120upx;
  317. }
  318. .right {
  319. flex: 1;
  320. display: flex;
  321. flex-direction: column;
  322. padding: 0 30upx 0 24upx;
  323. overflow: hidden;
  324. .title {
  325. font-size: $font-base + 2upx;
  326. color: $font-color-dark;
  327. line-height: 1;
  328. }
  329. .attr-box {
  330. font-size: $font-sm + 2upx;
  331. color: $font-color-light;
  332. padding: 10upx 12upx;
  333. }
  334. .price {
  335. font-size: $font-base + 2upx;
  336. color: $font-color-dark;
  337. &:before {
  338. content: '¥';
  339. font-size: $font-sm;
  340. margin: 0 2upx 0 8upx;
  341. }
  342. }
  343. }
  344. }
  345. </style>