海南旅游项目 前端仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

321 lines
9.0 KiB

4 years ago
  1. <template>
  2. <view v-if="$isRight(orderDetails)">
  3. <view class="lf-bg-white lf-p-t-30 lf-p-b-30 lf-p-l-32 lf-p-r-32">
  4. <view class="lf-row-between">
  5. <image :src="orderDetails.picture" mode="aspectFill" style="width: 240rpx; height: 240rpx;border-radius: 20rpx;" @click="$url('/pages/goodsDetail/index?goods_id='+orderDetails.agent_product_id)"></image>
  6. <view class="flex-sub padding-left-sm">
  7. <view class="bref-box lf-font-32 lf-color-333 lf-line-2" style="height: 88rpx;line-height: 44rpx;">
  8. {{orderDetails.title}}
  9. </view>
  10. <view class="flex lf-m-t-25 align-center text-center">
  11. <text class="block lf-color-gray lf-font-24" style="line-height: 40rpx;">数量</text>
  12. <text class="lf-m-l-10 lf-color-gray lf-font-24">x {{orderDetails.num}}</text>
  13. </view>
  14. <view class="flex align-center text-center lf-m-t-25">
  15. <lf-price :price="orderDetails.price" />
  16. <!-- <view class="lf-m-l-20 lf-line-through lf-color-gray">
  17. {{orderDetails.price}}
  18. </view> -->
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <self-line/>
  24. <view class="bg-white padding-lr">
  25. <view class="cu-bar lf-border-bottom">
  26. <text class="lf-color-555 lf-font-28">可退金额</text>
  27. <text class="text-price lf-font-36 lf-color-price">{{orderDetails.price}}</text>
  28. </view>
  29. <view class="cu-bar flex justify-between align-center text-center">
  30. <text class="lf-color-555 lf-font-28">订单编号</text>
  31. <view>
  32. <text class="lf-font-28 text-black1">{{orderDetails.order_no}}</text>
  33. <!-- <text class="text-orange lf-font-28" @click="copy(2368492461046128742764)">复制</text> -->
  34. </view>
  35. </view>
  36. </view>
  37. <self-line/>
  38. <view class="bg-white lf-m-b-6">
  39. <view class="lf-p-t-30 lf-p-l-32 lf-p-r-32 lf-p-b-36">
  40. <view class="lf-font-28 lf-color-black">退款说明</view>
  41. <!-- <input type="text" value="" placeholder="请输入退款说明" class="lf-m-t-30 lf-border-bottom" /> -->
  42. <view class="cu-self menu" style="margin-top: 30rpx; position: relative;">
  43. <textarea :cursor-spacing="120" maxlength="300" :adjust-position="true" type="text" v-model="applyInfo" class="text-left lf-font-32 area-self" placeholder="请输入退款说明" />
  44. <view class="font-change">{{ dynamicLength() }}/300</view>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="cu-form-group">
  49. <view class="grid col-4 grid-square flex-sub">
  50. <view style="width: 212rpx;height: 212rpx;border-radius: 10rpx;" class="bg-img" v-for="(item,index) in img_list" :key="index" @tap="showImg(index)" :data-url="img_list[index]">
  51. <image :src="img_list[index]" mode="aspectFill"></image>
  52. <view class="cu-tag bg-red" @tap.stop="DelImg(index)" :data-index="index">
  53. <!-- <text class='cuIcon-close'></text> -->
  54. <text class="lf-iconfont lf-icon-cuowu lf-font-40 lf-color-price"></text>
  55. </view>
  56. </view>
  57. <view style="width: 212rpx;height: 212rpx;border-radius: 10rpx;" class="solids" @tap="ChooseImage" v-if="img_list.length<3">
  58. <text class='cuIcon-cameraadd'></text>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="lf-m-t-40 lf-m-b-40">
  63. <view class="padding-lr-lg">
  64. <button class="cu-btn block lf-bg-blue lg round" @tap="subimitApply()">
  65. <text class="text-df text-white">确认申请</text>
  66. </button>
  67. </view>
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. export default {
  73. data() {
  74. return {
  75. hostImg: '',
  76. img_list: [], // 反馈问题图片
  77. applyInfo: '', // 退款说明
  78. order_id: 0,
  79. orderDetails: {}
  80. }
  81. },
  82. onLoad(e) {
  83. this.order_id = e.order_id
  84. if(this.order_id) {
  85. this.getOrderDetails()
  86. }
  87. },
  88. methods: {
  89. subimitApply() {
  90. if(!this.applyInfo) {
  91. this.$msg('请先输入反馈信息!')
  92. return
  93. }
  94. this.upload()
  95. },
  96. getOrderDetails() {
  97. this.$http(this.API.API_ORDER_DETAILS, {
  98. id: this.order_id
  99. }).then(res => {
  100. this.orderDetails = res.data
  101. console.log(res.data)
  102. }).catch(err => {
  103. setTimeout(() => {
  104. this.$toBack()
  105. }, 1000)
  106. });
  107. },
  108. dynamicLength(){
  109. return parseInt(this.applyInfo.length);
  110. },
  111. checkImgInfo(tempFilePath, suc){
  112. uni.getImageInfo({
  113. src: tempFilePath,
  114. success (res) {
  115. let type = res.type;
  116. console.log('checkImgInfo...', type);
  117. if(type == 'png' || type == 'jpeg' || type == 'jpg'){
  118. suc && suc(true);
  119. } else {
  120. suc && suc(false);
  121. }
  122. },
  123. fail(err) {
  124. suc && suc(false);
  125. }
  126. })
  127. },
  128. // 选择图片
  129. ChooseImage(e) {
  130. let that = this;
  131. uni.chooseImage({
  132. count: 1,
  133. sizeType: ['original'], // 可以指定是原图original还是压缩图compressed ,默认二者都有
  134. sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有
  135. success: res => {
  136. that.hostImg = res.tempFilePaths[0];
  137. let tempFile = res.tempFiles.shift();
  138. let tempFilePath = res.tempFilePaths.shift();
  139. console.log('临时路径',res)
  140. that.checkImgInfo(tempFilePath, (res) => {
  141. // 过滤不是图片不是png、jpeg 格式
  142. if(res){
  143. if(tempFile.size > 10000000){
  144. uni.showModal({
  145. title: '',
  146. content: '您选择的图片过大:'+ (tempFile.size / 1024000).toFixed(2) +"M,请点击确定重新上传",
  147. success: res2 => {
  148. if(res2.confirm){
  149. uni.chooseImage({
  150. count: 1,
  151. sizeType: ['compressed'],
  152. sourceType: ['album', 'camera'],
  153. success: (res3) => {
  154. let tempFilePath = res3.tempFilePaths.shift();
  155. that.is_wx_reduce = true;
  156. that.img_list.push(tempFilePath);
  157. }
  158. })
  159. }
  160. }
  161. })
  162. } else{
  163. that.img_list.push(tempFilePath);
  164. console.log('图片数组',that.img_list)
  165. }
  166. } else {
  167. uni.showModal({
  168. title: '',
  169. content: '选择的图片须为jpg、jpeg或png格式',
  170. showCancel: false,
  171. confirmColor: '#1697EE'
  172. })
  173. }
  174. });
  175. }
  176. });
  177. },
  178. // 上传图片到服务器
  179. upload(url){
  180. let that = this;
  181. let uploads = [];
  182. // 商品banner图上传
  183. if (that.img_list.length > 0) {
  184. for (let i = 0; i < that.img_list.length; i++) {
  185. let upload_img = new Promise((resolve, reject) => {
  186. that.uploadFile(that.img_list[i], (res) => {
  187. resolve(res);
  188. }, (err) => {
  189. reject(err);
  190. });
  191. })
  192. uploads.push(upload_img);
  193. }
  194. }
  195. if(uploads.length == 0) {
  196. that.realSubmitInfo([]);
  197. return
  198. }
  199. Promise.all(uploads).then((result) => {
  200. let img_url_list = [];
  201. if(result.length > 0){
  202. img_url_list = result;
  203. }
  204. if(img_url_list) {
  205. that.realSubmitInfo(img_url_list);
  206. }
  207. }).catch(err => {
  208. that.is_publish = false; // 恢复提交按钮
  209. uni.showModal({
  210. title: '',
  211. content: '图片上传失败,请重新提交',
  212. confirmColor: '#1697EE'
  213. })
  214. })
  215. },
  216. // 提交反馈
  217. realSubmitInfo(img_url_list){
  218. let that = this;
  219. console.log('上次时的图片数组',img_url_list)
  220. let params = {id: that.order_id,desc: that.applyInfo,pictures:img_url_list}
  221. if(img_url_list.length == 0) {
  222. delete params.images;
  223. }
  224. uni.showToast({
  225. title: '请求中',
  226. icon: "loading",
  227. duration: 10000
  228. })
  229. that.$http(that.API.API_APPLYREFUND, params).then(res => {
  230. if(res.code == 0) {
  231. that.$msg('提交成功')
  232. that.img_list = []
  233. that.applyInfo = ''
  234. console.log(that.order_id)
  235. setTimeout(() => {
  236. console.log(that.order_id)
  237. that.$url('/pages/order/refund_detail?order_id='+that.order_id,{type:'launch'})
  238. },1000)
  239. }
  240. }).catch(err => {
  241. });
  242. },
  243. // 预览图片
  244. showImg(index) {
  245. this.$u.throttle(() => {
  246. let goods_banner = this.img_list || [];
  247. let banners = goods_banner.map(item => item);
  248. uni.previewImage({
  249. urls: banners,
  250. current: index
  251. })
  252. }, 200);
  253. },
  254. // 删除图片
  255. DelImg(index) {
  256. uni.showModal({
  257. title: '提示',
  258. content: '即将取消上传这张图片,请确认?',
  259. success: e => {
  260. if (!e.confirm) return;
  261. this.img_list.splice(index, 1);
  262. }
  263. });
  264. },
  265. // 点击复制
  266. copy(text) {
  267. uni.setClipboardData({
  268. data: text
  269. });
  270. },
  271. }
  272. }
  273. </script>
  274. <style>
  275. .btn{
  276. margin: 0;
  277. padding: 0;
  278. width: 212rpx;
  279. height: 82rpx;
  280. background-color: #1998FE;
  281. color: #FFFFFF;
  282. line-height: 80rpx;
  283. font-size: 32rpx;
  284. border-radius: 41rpx;
  285. }
  286. .bref-box {
  287. text-overflow: -o-ellipsis-lastline;
  288. overflow: hidden;
  289. text-overflow: ellipsis;
  290. display: -webkit-box;
  291. -webkit-line-clamp: 2;
  292. -webkit-box-orient: vertical;
  293. }
  294. .area-self {
  295. width: 100%;
  296. padding: 30rpx;
  297. padding-bottom: 36rpx;
  298. color: #333;
  299. border: 1px solid #D0D0D0;
  300. border-radius: 10rpx;
  301. }
  302. .font-change{
  303. position: absolute;
  304. right: 10rpx;
  305. bottom: 10rpx;
  306. width: max-content;
  307. color: #777777;
  308. }
  309. </style>