evaluate.vue 4.3 KB

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