evaluate.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <view class="content">
  3. <view class="equity_box">
  4. <view class="text-box uni-textarea"><textarea placeholder-style="color:#999" :placeholder="placeholder" v-model="text"></textarea></view>
  5. <view class="">
  6. <view class="add-img-box flex_item">
  7. <view class="add-img-item" v-for="(item, index) in imgList" :key="index">
  8. <image class="add-img" @click.stop="imgInfo(index)" :src="item" mode="aspectFill"></image>
  9. <image class="add-img-del" @click.stop="delImg(index)" src="/static/img/delete.png"></image>
  10. </view>
  11. <view v-if="imgList.length < 9" class="add-img-item" @click.stop="scImg()"><image class="add-img" src="/static/img/add.png"></image></view>
  12. </view>
  13. </view>
  14. </view>
  15. <view @click.stop="submit" class="submit-btn" v-if="type == 0">提交</view>
  16. </view>
  17. </template>
  18. <script>
  19. import { after_sales, upload, orderDetail } from '@/api/order.js';
  20. import uniRate from '@/components/uni-rate/uni-rate.vue';
  21. export default {
  22. components: {
  23. uniRate
  24. },
  25. data() {
  26. return {
  27. type: 1, //1查看0申请
  28. text: '', //评论内容
  29. placeholder: '请详细描述您的售后理由...',
  30. imgList: [],
  31. unique: '', //商品唯一标识码
  32. imgCount: 3 //最多支持9张上传,可以修改
  33. };
  34. },
  35. onLoad(option) {
  36. this.unique = option.unique;
  37. },
  38. onShow() {
  39. this.loadData();
  40. },
  41. methods: {
  42. loadData() {
  43. orderDetail({}, this.unique).then(({ data }) => {
  44. this.type = data.after_sales;
  45. if (this.type == 1) {
  46. this.placeholder = data.after_remarks;
  47. this.imgList = data.after_images;
  48. }
  49. });
  50. },
  51. //单张上传图片
  52. scImg() {
  53. let obj = this;
  54. console.log(obj.imgCount, 11);
  55. if (obj.imgCount == 0) {
  56. uni.showToast({
  57. title: '最多添加6张图片',
  58. icon: 'none'
  59. });
  60. return;
  61. }
  62. upload({
  63. file: ''
  64. })
  65. .then(e => {
  66. obj.imgList.push(e[0].url);
  67. obj.imgCount = 3 - obj.imgList.length;
  68. })
  69. .catch(e => {});
  70. },
  71. //提交评论
  72. submit(e) {
  73. let obj = this;
  74. if (obj.imgList.length < 1) {
  75. uni.showToast({
  76. title: '请添加图片',
  77. icon: 'none'
  78. });
  79. return;
  80. }
  81. after_sales(
  82. {
  83. after_images: obj.imgList,
  84. after_remarks: obj.text
  85. },
  86. obj.unique
  87. )
  88. .then(e => {
  89. uni.showModal({
  90. title: '提示',
  91. content: '申请售后成功,是否前往个人中心页',
  92. success: function(res) {
  93. if (res.confirm) {
  94. uni.switchTab({
  95. url: '/pages/user/my'
  96. });
  97. } else if (res.cancel) {
  98. console.log('用户点击取消');
  99. }
  100. }
  101. });
  102. })
  103. .catch(e => {});
  104. },
  105. //点击图片显示大图
  106. imgInfo(i) {
  107. let tempList = [];
  108. console.log(111);
  109. this.imgList.forEach(e => {
  110. tempList.push(e);
  111. });
  112. console.log(tempList);
  113. //显示图片
  114. uni.previewImage({
  115. current: i,
  116. loop: false,
  117. urls: tempList,
  118. indicator: 'default'
  119. });
  120. },
  121. //删除图片
  122. delImg(i) {
  123. uni.showModal({
  124. content: '确定删除这张吗',
  125. success: res => {
  126. if (res.confirm) {
  127. this.imgList.splice(i, 1);
  128. this.imgCount++;
  129. } else if (res.cancel) {
  130. }
  131. }
  132. });
  133. },
  134. // 页面跳转
  135. navto(e) {
  136. uni.navigateTo({
  137. url: e
  138. });
  139. }
  140. }
  141. };
  142. </script>
  143. <style lang="scss">
  144. page {
  145. background: #f8f6f6;
  146. height: 100%;
  147. .content {
  148. background: #f8f6f6;
  149. height: 100%;
  150. }
  151. }
  152. .equity_box {
  153. border-radius: 10rpx;
  154. padding: 25rpx 25rpx;
  155. margin: 25rpx 0rpx;
  156. background: #ffffff;
  157. .text-box {
  158. height: 200rpx;
  159. textarea {
  160. font-size: 25rpx;
  161. width: 100%;
  162. height: 100%;
  163. overflow: hidden;
  164. text-overflow: ellipsis;
  165. display: -webkit-box;
  166. -webkit-box-orient: vertical;
  167. -webkit-line-clamp: 5;
  168. }
  169. }
  170. }
  171. .submit-btn {
  172. margin: 102rpx auto 0;
  173. width: 560rpx;
  174. height: 85rpx;
  175. background: #24a17d;
  176. border-radius: 43px;
  177. text-align: center;
  178. font-size: 36rpx;
  179. font-family: PingFangSC;
  180. font-weight: 500;
  181. color: #ffffff;
  182. line-height: 85rpx;
  183. }
  184. .add-img-box {
  185. width: 100%;
  186. flex-direction: row;
  187. flex-wrap: wrap;
  188. margin-top: 50rpx;
  189. }
  190. .add-img-item {
  191. width: 180rpx;
  192. height: 180rpx;
  193. border-radius: 24rpx;
  194. position: relative;
  195. margin: 0rpx 20rpx;
  196. margin-bottom: 25rpx;
  197. .add-img {
  198. width: 100%;
  199. height: 100%;
  200. }
  201. }
  202. .add-img-camera {
  203. flex: 1;
  204. }
  205. .add-img-del {
  206. position: absolute;
  207. width: 40rpx;
  208. height: 40rpx;
  209. left: 155rpx;
  210. bottom: 155rpx;
  211. //background-color: rgba(238, 0, 0, 1);
  212. border-radius: 20rpx;
  213. }
  214. .address-time {
  215. width: 484rpx;
  216. height: 88rpx;
  217. background-color: rgba(245, 245, 245, 1);
  218. opacity: 1;
  219. border-radius: 24rpx;
  220. text-align: center;
  221. font-size: 35rpx;
  222. font-weight: 500;
  223. color: rgba(51, 51, 51, 1);
  224. }
  225. .line {
  226. width: 750rpx;
  227. height: 1px;
  228. transform: scaleY(0.3);
  229. background-color: rgba(0, 0, 0, 0.5);
  230. }
  231. </style>