review.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <view>
  3. <use-tabbar :tabbar="false" />
  4. <view class="margin-bottom-xl" v-if="fetch && fetch.info">
  5. <view class="padding margin-lr margin-tb-sm bg-main border-radius">
  6. <view class="goods-area" v-for="(item, index) in fetch.info.detail"
  7. :key="index">
  8. <view class="dflex pos-r">
  9. <view class="img" @click="Dever.pic.preview([item.pic], item.pic)">
  10. <image :src="item.pic" mode="aspectFit"></image>
  11. </view>
  12. <view class="margin-left-sm"><text class="clamp-2">{{ item.name }}</text>
  13. <view class="ft-dark fs-xs padding-top-xs"><text class="margin-right">× {{item.num}}</text>{{ item.sku_name || '&nbsp;&nbsp;' }}</view>
  14. <view class="margin-top-sm"><text class="price">{{ item.cash_text }}</text></view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="evaluate-kps">
  20. <view class="padding margin-lr margin-tb-sm bg-main border-radius dflex-b">
  21. <view><text>宝贝评分</text><text
  22. class="margin-left ft-base fs-xs">{{rate_name}}</text>
  23. </view>
  24. <view class="use-rate dflex">
  25. <u-rate count="5" v-model="rate" @change="setRate"></u-rate>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="evaluate-area">
  30. <view class="padding margin-lr margin-tb-sm bg-main border-radius">
  31. <u--textarea :focus="true" :height="120" v-model="content" border="none"
  32. placeholder="请输入评价内容"></u--textarea>
  33. <!--
  34. <view class="use-upload dgrid dgrid-col-3 pos-r">
  35. <u-upload :fileList="pic" @afterRead="afterRead" @delete="deletePic" name="1" multiple
  36. :maxCount="5"></u-upload>
  37. </view>-->
  38. </view>
  39. </view>
  40. <view>
  41. <view class="padding margin-lr margin-tb-sm bg-main border-radius dflex-b">
  42. <text>公开显示您的头像、昵称</text>
  43. <view>
  44. <u-switch v-model="open" @change="setOpen" activeColor="#f56c6c"></u-switch>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="padding w-full margin-top">
  49. <view class="dflex-b border-radius-big">
  50. <view class="tac padding-tb-sm flex1 bg-base" @click="submit">提交评价</view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. export default {
  58. data() {
  59. return {
  60. fetch: {},
  61. id: 0,
  62. open: true,
  63. rate: 5,
  64. rate_name: '好评',
  65. content: '',
  66. pic: [],
  67. }
  68. },
  69. onLoad(options) {
  70. this.id = options.id;
  71. if (!this.id) {
  72. return Dever.goHome()
  73. }
  74. this.loadData();
  75. },
  76. methods: {
  77. loadData() {
  78. this.DeverApi.get(this, 'order.info', {
  79. id: this.id
  80. });
  81. },
  82. setRate(e) {
  83. if (e > 4) {
  84. this.rate_name = '好评';
  85. } else if (e > 1) {
  86. this.rate_name = '中评';
  87. } else {
  88. this.rate_name = '差评';
  89. }
  90. },
  91. setOpen(e) {
  92. },
  93. // 删除图片
  94. deletePic(event) {
  95. this[`fileList${event.name}`].splice(event.index, 1);
  96. },
  97. // 新增图片
  98. async afterRead(event) {
  99. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  100. let lists = [].concat(event.file);
  101. let fileListLen = this[`fileList${event.name}`].length;
  102. lists.map((item) => {
  103. this[`fileList${event.name}`].push({
  104. ...item,
  105. status: "uploading",
  106. message: "上传中",
  107. });
  108. });
  109. for (let i = 0; i < lists.length; i++) {
  110. const result = await this.uploadFilePromise(lists[i].url);
  111. let item = this[`fileList${event.name}`][fileListLen];
  112. this[`fileList${event.name}`].splice(
  113. fileListLen,
  114. 1,
  115. Object.assign(item, {
  116. status: "success",
  117. message: "",
  118. url: result,
  119. })
  120. );
  121. fileListLen++;
  122. }
  123. },
  124. uploadFilePromise(url) {
  125. return new Promise((resolve, reject) => {
  126. let a = uni.uploadFile({
  127. url: "http://192.168.2.21:7001/upload", // 仅为示例,非真实的接口地址
  128. filePath: url,
  129. name: "file",
  130. formData: {
  131. user: "test",
  132. },
  133. success: (res) => {
  134. setTimeout(() => {
  135. resolve(res.data.data);
  136. }, 1000);
  137. },
  138. });
  139. });
  140. },
  141. submit() {
  142. if (!this.content) {
  143. return this.Dever.alert('请输入评价内容');
  144. }
  145. //const pic = this.pic.join(',');
  146. const pic = '';
  147. this.DeverApi.post('order.review', {content:this.content,pic:pic,open:this.open,rate:this.rate,id:this.id}, res => {
  148. this.Dever.success('评价成功', () => {
  149. this.Dever.location('order/info?id=' + this.id, 'go');
  150. });
  151. });
  152. },
  153. }
  154. }
  155. </script>
  156. <style lang="scss">
  157. .goods-area:last-child {
  158. margin-bottom: 0;
  159. }
  160. .goods-area image {
  161. width: 180rpx;
  162. height: 180rpx;
  163. }
  164. textarea {
  165. width: 300px;
  166. height: 150px;
  167. display: block;
  168. position: relative;
  169. font-size: 16px;
  170. line-height: normal;
  171. white-space: pre-wrap;
  172. word-break: break-all;
  173. }
  174. .dgrid-col-3 {
  175. grid-gap: 9px 9px;
  176. grid-template-columns: repeat(3, 1fr);
  177. }
  178. .use-upload .item {
  179. width: 200rpx;
  180. height: 200rpx;
  181. border: 1px solid #f0f0f0;
  182. }
  183. </style>