index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <view :style="{ minHeight: sys.windowHeight + 'px' }" :class="[$tm.vx.state().tmVuetify.black ? 'black' : ' ']">
  3. <tm-menubars title="我的评价" :shadow="0" :showback="true"></tm-menubars>
  4. <div class="zhuti">
  5. <tm-sheet class="kuang" style="padding-bottom: 70px !important;">
  6. <view style="width: 94%;margin:0 auto;">
  7. <tm-cartCellListFood class="shangpin" :typeclick="typeclick" :mdata="item"
  8. :cart-num.sync="item.buy"></tm-cartCellListFood>
  9. <view class="tiyan">
  10. <text class="text-white mr-20">产品体验</text>
  11. <tm-rate v-model="rate1"></tm-rate>
  12. <text class="ml-20 text-size-s" v-if="rate1==5">非常满意</text>
  13. <text class="ml-20 text-size-s" v-if="rate1<=4&&rate1>3">比较满意</text>
  14. <text class="ml-20 text-size-s" v-if="rate1<=3&&rate1>0">一般满意</text>
  15. </view>
  16. <view class="tiyan">
  17. <text class="text-white mr-20">派送评价</text>
  18. <tm-rate v-model="rate2"></tm-rate>
  19. <text class="ml-20 text-size-s" v-if="rate2==5">非常满意</text>
  20. <text class="ml-20 text-size-s" v-if="rate2<=4&&rate2>3">比较满意</text>
  21. <text class="ml-20 text-size-s" v-if="rate2<=3&&rate2>0">一般满意</text>
  22. </view>
  23. <view class="tiyan">
  24. <text class="text-white mr-20">服务态度</text>
  25. <tm-rate v-model="rate3"></tm-rate>
  26. <text class="ml-20 text-size-s" v-if="rate3==5">非常满意</text>
  27. <text class="ml-20 text-size-s" v-if="rate3<=4&&rate3>3">比较满意</text>
  28. <text class="ml-20 text-size-s" v-if="rate3<=3&&rate3>0">一般满意</text>
  29. </view>
  30. <tm-input class="shuru" :height="150" title="" :maxlength="144" :border-bottom="false"
  31. placeholder="快来发表评论吧!" input-type="textarea" v-model="val_1" bg-color="grey-lighten-5" clear>
  32. </tm-input>
  33. <view class="mt-30">
  34. <view class="">
  35. <view class="cent-bottom-m">
  36. <view class="uploadImg">
  37. <view v-for="(el, index) in fileList" :key="index">
  38. <view class="uploadImg-image">
  39. <image @click="checkImgbox(fileList, index)" :src="imgUrl+el"
  40. mode="aspectFill" style="width: 100%;height: 100%;border-radius: 4px;">
  41. </image>
  42. <view class="jian" @click="popImg(index)">
  43. <tm-button class="shanchu" theme="white" size="s" icon="icon-times">
  44. </tm-button>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="jia-btn" @click="openImagePage" v-if="uploadFlag">
  49. <view class="jia">
  50. <view>
  51. <tm-button theme="white" size="m" icon="icon-plus"></tm-button>
  52. </view>
  53. <view style="font-size: 12px;">上传图片</view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <!-- <tm-upload :tips="false" :filelist.sync="filelist" max='5'></tm-upload> -->
  60. </view>
  61. <tm-button :round="24" class="sao" block @click="submit">提交</tm-button>
  62. </view>
  63. </tm-sheet>
  64. </div>
  65. <!-- 弹出层消息 -->
  66. <tm-message ref="toast"></tm-message>
  67. </view>
  68. </template>
  69. <script>
  70. import {
  71. myRequest
  72. } from '@/api/request.js'
  73. export default {
  74. data() {
  75. return {
  76. item: {
  77. // img: '../../static/img/83.png',
  78. // title: '丝缎质感纹理风衣',
  79. // label: '黑色 - 6518/320',
  80. // size: 'S',
  81. // price: '1299',
  82. // id: 3,
  83. // buy: 0,
  84. // itemId: 0,
  85. // checked: false,
  86. },
  87. // typeclick:5,//1加入购物车,2购物车
  88. typeclick: 9, //1加入购物车,2购物车
  89. rate1: 0,
  90. rate2: 0,
  91. rate3: 0,
  92. val_1: '',
  93. fileList: [],
  94. imgUrl: "",
  95. sizeType: ['compressed'],
  96. imageList: [], // 申诉图片地址
  97. uploadFlag: true, // 申诉图片大于3张隐藏上传按钮
  98. orId: '',
  99. imgList: []
  100. };
  101. },
  102. onLoad(op) {
  103. console.log(op);
  104. if (op) {
  105. this.orId = op.id;
  106. this.getOrderDetail()
  107. }
  108. },
  109. created() {
  110. if (!uni.getStorageSync("token")) {
  111. uni.navigateTo({
  112. url: "/pages/login/index",
  113. })
  114. }
  115. this.sys = uni.getSystemInfoSync();
  116. },
  117. methods: {
  118. getOrderDetail() {
  119. let that = this;
  120. myRequest({
  121. url: '/api/Order/orderDetails',
  122. method: 'post',
  123. data: {
  124. id: that.orId
  125. }
  126. }).then(res => {
  127. if (res.data.code == 200) {
  128. this.item = res.data.data.goods_details;
  129. this.item.title = res.data.data.goods_details.goods_name;
  130. this.item.img = res.data.data.goods_details.goods_img;
  131. this.item.price = res.data.data.goods_details.goods_price;
  132. this.item.buy = res.data.data.goods_details.buy_num;
  133. console.log(res.data.data.goods_details, '33');
  134. } else {
  135. that.$refs.toast.show({
  136. model: 'error',
  137. label: res.data.msg
  138. })
  139. }
  140. })
  141. },
  142. openImagePage() {
  143. let that = this;
  144. if (that.fileList.length > 5) {
  145. uni.showToast({
  146. title: "最多支持5张图片",
  147. icon: "none"
  148. })
  149. return;
  150. }
  151. uni.chooseImage({
  152. count: 1,
  153. sizeType: ['compressed'],
  154. sourceType: ['album', 'camera'],
  155. success: function(res) {
  156. uni.showLoading({
  157. title: '图片上传中'
  158. });
  159. that.uploadImage(res.tempFilePaths)
  160. }
  161. });
  162. },
  163. uploadImage(tempFilePaths) {
  164. let _this = this;
  165. uni.uploadFile({
  166. url: 'http://yigui.liliju.com/common/uploads/upload', //接口地址
  167. header: {
  168. "token": uni.getStorageSync('token'),
  169. }, //请求token
  170. filePath: tempFilePaths[0],
  171. name: 'file',
  172. success: (res) => {
  173. let data = JSON.parse(res.data);
  174. console.log(data);
  175. let url = data.data.yimg;
  176. console.log(url, 'url');
  177. // 选中图片
  178. if (_this.fileList.indexOf(url) == -1) {
  179. let uu = url.substr(24);
  180. _this.fileList.push(url);
  181. _this.imgList.push(uu)
  182. console.log(_this.fileList, 'haah');
  183. }
  184. uni.hideLoading();
  185. if (_this.fileList.length > 5) {
  186. _this.uploadFlag = false
  187. } else {
  188. _this.uploadFlag = true
  189. }
  190. }
  191. });
  192. },
  193. checkImgbox(fileList, index) { //放大图片
  194. console.log(fileList, index, 999)
  195. let arr = [];
  196. fileList.forEach((el) => {
  197. arr.push(this.imgUrl + el);
  198. })
  199. uni.previewImage({
  200. urls: arr,
  201. current: index
  202. });
  203. },
  204. popImg(index) { //删除图片
  205. this.fileList.splice(index, 1);
  206. this.imgList.splice(index, 1);
  207. if (this.fileList.length < 1) {
  208. this.uploadFlag = true
  209. }
  210. },
  211. aa(num) {
  212. if (num == 1) {
  213. this.checked1 = true;
  214. this.checked2 = false;
  215. this.checked3 = false;
  216. } else if (num == 2) {
  217. this.checked1 = false;
  218. this.checked2 = true;
  219. this.checked3 = false;
  220. } else if (num == 3) {
  221. this.checked1 = false;
  222. this.checked2 = false;
  223. this.checked3 = true;
  224. }
  225. },
  226. // 提交评价
  227. submit() {
  228. if (this.rate1 == 0 || this.rate2 == 0 || this.rate3 == 0) {
  229. uni.showToast({
  230. title: '请选择满意度',
  231. icon: 'none'
  232. })
  233. } else if (this.val_1 == '') {
  234. uni.showToast({
  235. title: '内容不能为空',
  236. icon: 'none'
  237. })
  238. } else {
  239. let that = this;
  240. myRequest({
  241. url: '/api/Order/orderEvaluate',
  242. method: 'post',
  243. data: {
  244. id: that.orId,
  245. experience_value: that.rate1,
  246. delivery_value: that.rate2,
  247. service_value: that.rate3,
  248. atlas: that.imgList.join(','),
  249. content: that.val_1
  250. }
  251. }).then(res => {
  252. if (res.data.code == 200) {
  253. console.log(res.data.data, 'pingjia1!!');
  254. that.$refs.toast.show({
  255. model: 'success',
  256. label: res.data.msg
  257. })
  258. setTimeout(() => {
  259. uni.navigateBack({
  260. delta: 1
  261. })
  262. }, 800)
  263. } else {
  264. that.$refs.toast.show({
  265. model: 'error',
  266. label: res.data.msg
  267. })
  268. }
  269. })
  270. }
  271. }
  272. },
  273. }
  274. </script>
  275. <style lang="scss">
  276. /deep/ .tm-menubars .body {background-color: #1b1b1b !important;}
  277. /deep/ .zhuti {padding: 10px 10px;}
  278. /deep/ .kuang,
  279. /deep/ .jia .tm-button-btn {margin: 0 !important;padding: 0px !important;}
  280. .uploadImg {display: flex;justify-content: flex-start;align-items: flex-start;flex-wrap: wrap;}
  281. .uploadImg-image {width: 70px;height: 70px;margin: 0px 10px 10px 0px;position: relative;}
  282. .shanchu {position: absolute;right: -15px;top: -5px;}
  283. /deep/ .jia .tm-button-btn .px-12 {padding: 0 !important;}
  284. /deep/ .white {background: none !important;}
  285. /deep/ .jia .white,
  286. /deep/ .jian .white {color: #ffffff !important;}
  287. .sao {width: 90%;margin: 20px auto 0px;}
  288. /deep/ .shuliang .text-size-n {color: white !important;}
  289. /deep/ .shangpin .tm-cartCellListFood {margin: 5px 0px 20px !important;padding-bottom: 15px !important;border-bottom: 1px solid #1B1B1B;}
  290. /deep/ .kuang .border-t-1.bk {border-top: 1px solid #1b1b1b !important;}
  291. /deep/ .shangpin .title,
  292. /deep/ .shangpin .text-red {color: white !important;}
  293. /deep/ .shangpin .round-3 {width: 90px !important;height: 90px !important;}
  294. /deep/ .shangpin .tm-cartCellListFood-img {width: 90px !important;height: 90px !important;}
  295. /deep/ .shuliang .text-size-n {color: white !important;}
  296. .tiyan text {vertical-align: middle;}
  297. .tiyan {margin-top: 20px;}
  298. /deep/ .tiyan .text-primary.bk {color: #FFCC00 !important;}
  299. /deep/ .tiyan .opacity-6 {opacity: 1 !important;}
  300. /deep/ .shuru .grey-darken-4 {background: #0D0D0D !important;}
  301. .shuru {padding: 0px !important;margin-top: 20px !important;}
  302. .jia {width: 100%;height: 100%;display: flex;flex-direction: column;
  303. justify-content: center;align-items: center;}
  304. .jia-btn {width: 70px;height: 70px;border: 1px solid #eeeeee;border-radius: 4px;}
  305. </style>