RefundForm.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <member-base :show="false"><view class="div member-information">
  3. <view class="div common-header-wrap">
  4. <view :style="'height:'+navHeight+'px'"></view>
  5. <view class="common-header-holder"></view>
  6. <view class="common-header-fixed">
  7. <title-header />
  8. <uni-nav-bar title="新增退款" class="common-header" left-icon="back" @clickLeft="goBack()">
  9. </uni-nav-bar>
  10. </view>
  11. </view>
  12. <view class="div form">
  13. <view class="div field-line-right" ><textarea class="order-message field-input" v-model="buyer_message" placeholder="退款说明:" ></textarea></view>
  14. <flex-line><text class="span line-name">退款凭证</text></flex-line>
  15. <view class="div image-wrapper">
  16. <view class="div user-avatar">
  17. <uni-file-picker v-model="image" fileMediatype="image" mode="grid" :limit="3" :auto-upload="false"
  18. @select="uploadRefundImage" @delete="deleteRefundImage"></uni-file-picker>
  19. </view>
  20. </view>
  21. <view class="div pt-10 pb-10"><view class="div common-btn ds-button-large mt-10" @click="submitInformation">保存</view></view>
  22. </view>
  23. <tui-picture-cropper v-if="cropperOption.imgUrl" :width="cropperOption.autoCropWidth" :height="cropperOption.autoCropHeight" :imageUrl="cropperOption.img" @ready="cropReady" @cropper="useCrop" @back="cropBack"></tui-picture-cropper>
  24. </view></member-base>
  25. </template>
  26. <script>
  27. import {getFontSize} from '@/util/common'
  28. import TitleHeader from '../../TitleHeader'
  29. import MemberBase from '../MemberBase'
  30. import tuiPictureCropper from "@/components/thorui/tui-picture-cropper/tui-picture-cropper"
  31. import { uploadRefundImage, addRefundAll } from '../../../api/memberRefund'
  32. import flexLine from '../../flexLine'
  33. export default {
  34. components:{
  35. TitleHeader,
  36. MemberBase,
  37. flexLine,
  38. tuiPictureCropper
  39. },
  40. name:'MemberRefundForm',
  41. data(){
  42. return {
  43. navHeight: 0,
  44. screenWidth:0,
  45. screenHeight:0,
  46. cropperOption: {
  47. img: '',
  48. canMove: false,
  49. autoCrop: true,
  50. autoCropWidth: 100,
  51. autoCropHeight: 100,
  52. maxImgSize: 500,
  53. outputType: 'png'
  54. },
  55. cropType: '',
  56. order_id: 0,
  57. image: [],
  58. buyer_message: '',
  59. file_value: {}
  60. }
  61. },
  62. mounted(){
  63. // #ifdef MP-WEIXIN
  64. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  65. // #endif
  66. const res = uni.getSystemInfoSync()
  67. this.screenWidth = res.windowWidth
  68. this.screenHeight = res.windowHeight
  69. },
  70. computed:{
  71. fontSize(){
  72. return getFontSize()
  73. },
  74. },
  75. onLoad: function (option) {
  76. this.order_id=option.order_id
  77. },
  78. methods:{
  79. showPopup(id){
  80. this.$refs[id].open()
  81. },
  82. hidePopup(id){
  83. this.$refs[id].close()
  84. },
  85. goBack(){uni.navigateBack({delta:1})},
  86. submitInformation () {
  87. var file_value = []
  88. for (var i in this.file_value) {
  89. file_value.push(this.file_value[i])
  90. }
  91. addRefundAll(this.order_id, this.buyer_message, file_value).then(res => {
  92. uni.showToast({icon:'none',title: res.message})
  93. uni.navigateTo({url:'/pages/member/refund/RefundList'})
  94. }).catch(function (error) {
  95. uni.showToast({icon:'none',title: error.message})
  96. })
  97. },
  98. useCrop(res) {
  99. let index = this.cropType
  100. var formdata = {
  101. filePath: res.url,
  102. name: 'refund_pic'
  103. }
  104. uploadRefundImage(formdata).then(res => {
  105. this.file_value[index] = res.result.file_name
  106. this.image[index] = [{
  107. name: index,
  108. extname: 'jpg',
  109. url: res.result.pic
  110. }]
  111. this.cropperOption.imgUrl = ''
  112. this.$forceUpdate()
  113. uni.hideLoading()
  114. }).catch(function(error) {
  115. uni.showToast({
  116. icon: 'none',
  117. title: error.message
  118. })
  119. uni.hideLoading()
  120. this.cropperOption.imgUrl = ''
  121. this.$forceUpdate()
  122. })
  123. },
  124. deleteRefundImage(event) {
  125. let file = event.tempFile
  126. var index = file.uuid
  127. delete this.file_value[index]
  128. },
  129. cropReady() {
  130. this.cropperOption.img = this.cropperOption.imgUrl
  131. },
  132. cropBack(){
  133. this.cropperOption.imgUrl=''
  134. this.$forceUpdate()
  135. },
  136. uploadRefundImage(event) {
  137. let that = this
  138. let file = event.tempFiles[0]
  139. this.cropType = file.uuid
  140. that.cropperOption.imgUrl = file.path
  141. that.cropperOption.autoCropWidth = uni.getSystemInfoSync().windowWidth
  142. that.cropperOption.autoCropHeight = uni.getSystemInfoSync().windowWidth
  143. that.cropperOption.maxImgSize = uni.getSystemInfoSync().windowHeight - 40
  144. that.$forceUpdate()
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang="scss" scoped>
  150. .common-header{
  151. .btn{background: #000;color: #fff;box-shadow: 0px 2px 4px #d2d2d2;}
  152. }
  153. .form{background: #fff;padding:0 $pageSpace}
  154. .member-information {
  155. background: #fff;
  156. .order-message{
  157. background: #fbfbfb;
  158. margin: .5rem 0;
  159. font-size: .7rem;
  160. padding: .5rem;
  161. height: 4rem;
  162. border: 0;
  163. box-sizing: border-box;
  164. width: 100%;
  165. }
  166. }
  167. </style>