orderEit.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <view class="home-getOrder">
  3. <form class="form" @submit="orderSubmit">
  4. <view v-if="show" class="select-input">
  5. <input class="input" style="display:none;" />
  6. <text>账户余额:</text><input class="input" name="altMainBalance" disabled :value="altMainBalance"/>
  7. </view>
  8. <view class="select-input">
  9. <input class="input" style="display:none;" />
  10. <text>订单编号:</text><input class="input" name="sn" disabled :value="sn"/>
  11. </view>
  12. <view class="select-input">
  13. <input class="input" style="display:none;" />
  14. <text>设备编码:</text><input class="input" name="clientId" :value="clientId" />
  15. </view>
  16. <view class="select-input">
  17. <input class="input" style="display:none;" />
  18. <text>商品名称:</text><input class="input" name="productName" disabled :value="productName" />
  19. </view>
  20. <view class="select-input">
  21. <input class="input" style="display:none;" />
  22. <text>已支付金额:</text><input class="input" name="price" disabled :value="price" />
  23. </view>
  24. <view class="select-input">
  25. <input class="input" style="display:none;" />
  26. <text>支付时间:</text><input class="input" name="payDate" disabled :value="payDate"/>
  27. </view>
  28. <view class="select-input">
  29. <input class="input" style="display:none;" />
  30. <text>明细:</text><input class="input" name="note" disabled :value="note"/>
  31. </view>
  32. <view class="select-input">
  33. <input class="input" style="display:none;" />
  34. <text>退款时间:</text><input class="input" name="refundDate" disabled :value="refundDate"/>
  35. </view>
  36. <view class="select-input">
  37. <input class="input" style="display:none;" />
  38. <text>已退款金额:</text><input class="input" name="refundPrice" disabled :value="refundPrice" />
  39. </view>
  40. <view class="select-input">
  41. <input class="input" style="display:none;" />
  42. <text>订单状态:</text><input class="input" name="status" disabled :value="status==1?('已支付'):(status==2?'退款中':'已退款')" />
  43. </view>
  44. <view v-if="order.status!=3" class="select-input">
  45. <input class="input" style="display:none;" />
  46. <text>退款金额:</text>
  47. <input class="input2" @focus="setStyle()" @blur="setStyle2()" v-model="refundAmount" />
  48. </view>
  49. <p id="p2" class="p2" :style="{display:showOrNo}">请慎重对待!</p>
  50. <view v-if="order.status!=3" class="select-input">
  51. <input class="input" style="display:none;" />
  52. <text>PS:退款金额可修改</text>
  53. </view>
  54. <view v-if="order.payPlatform == 3" class="select-input">
  55. <input class="input" style="display:none;" />
  56. <text>退款原因:</text>
  57. <input v-if="order.status!=3" class="input2" v-model="refundReason" />
  58. <input v-if="order.status==3" class="input" name="refundReason" disabled :value="refundReason"/>
  59. </view>
  60. <view v-if="order.status!=3" class="btn-area">
  61. <button type="primary" formType="submit" >退款</button>
  62. </view>
  63. </form>
  64. </view>
  65. </template>
  66. <script>
  67. export default {
  68. data(){
  69. return{
  70. show: true,
  71. order:null,
  72. sn:null,
  73. clientId:null,
  74. productName:null,
  75. price:null,
  76. payDate:null,
  77. refundDate:null,
  78. status:null,
  79. altMainBalance:0,
  80. refundAmount:0,
  81. refundPrice:0,
  82. showOrNo: null,
  83. note:null,
  84. production:0,
  85. refundReason:null,
  86. }
  87. },
  88. onLoad: function(option) {
  89. const order = JSON.parse(decodeURIComponent(option.order));
  90. this.order = order;
  91. if(order.type==1){
  92. this.production = order.agencyProportion;
  93. }
  94. if(order.type==2){
  95. this.production = order.merchantProportion;
  96. }
  97. if(order.type==3){
  98. this.production = order.personageProportion;
  99. }
  100. if(order.payPlatform == 3) {
  101. this.show = false;
  102. }
  103. this.sn = order.sn;
  104. this.clientId = order.clientId;
  105. this.productName = order.productName;
  106. this.price = order.price;
  107. this.payDate = order.payDate;
  108. this.refundDate = order.refundDate;
  109. this.status = order.status;
  110. this.note = order.note;
  111. this.refundPrice = order.refundAmount;
  112. this.refundAmount = order.price;
  113. this.refundReason = order.refundReason;
  114. },
  115. onShow() {
  116. this.mch();
  117. // console.log("订单详情")
  118. },
  119. methods: {
  120. orderSubmit(e) {
  121. var price = this.price;
  122. var production = this.production;
  123. var altMainBalance = this.altMainBalance;
  124. var refusePrice = price*production/100;
  125. console.log("refusePrice="+refusePrice)
  126. if(altMainBalance<refusePrice.toFixed(2)){
  127. uni.showToast({
  128. title: '余额不足',
  129. duration: 2000
  130. });
  131. return;
  132. }
  133. uni.showModal({
  134. title: '退款',
  135. content: '确定执行退款操作?',
  136. success: (res) => {
  137. if (res.confirm) {
  138. var order = this.order;
  139. var refundAmount = this.refundAmount;
  140. var refundReason = this.refundReason;
  141. var token = uni.getStorageSync("token");
  142. if(order.payPlatform != null && order.payPlatform == '3') {
  143. if(refundReason == null || refundAmount == "") {
  144. uni.showToast({
  145. title: '请输入退款原因',
  146. duration: 3000,
  147. icon: 'error'
  148. });
  149. return;
  150. }
  151. //如果为直接对接微信支付
  152. uni.request({
  153. url: this.serverurl + '/tWeixinPay/refund',
  154. data: {
  155. "sn": order.sn,
  156. "refusePrice":refundAmount,
  157. "refundReason": refundReason
  158. },
  159. header: {
  160. 'token': token
  161. },
  162. method: "GET",
  163. success: (res) => {
  164. var message = res.data.message;
  165. if(res.data.code){
  166. this.status = 2;
  167. }
  168. uni.showToast({
  169. title: message,
  170. duration: 3000
  171. });
  172. },
  173. });
  174. }else{
  175. uni.request({
  176. url: this.serverurl + '/TOrder/refund',
  177. data: {
  178. "sn": order.sn,
  179. "id": order.id,
  180. "refundAmount":refundAmount
  181. },
  182. header: {
  183. 'token': token
  184. },
  185. method: "POST",
  186. success: (res) => {
  187. var message = res.data.message;
  188. if(res.data.code){
  189. this.status = 2;
  190. }
  191. uni.showToast({
  192. title: message,
  193. duration: 3000
  194. });
  195. },
  196. });
  197. }
  198. } else if (res.cancel) {
  199. // console.log('用户点击取消');
  200. }
  201. }
  202. });
  203. },
  204. mch(){
  205. var token = uni.getStorageSync("token");
  206. var globalUser = uni.getStorageSync("globalUser");
  207. uni.request({
  208. url: this.serverurl + '/TJoinpayMch/getMch',
  209. data: {
  210. "adminId": globalUser.id,
  211. "bizCode":this.order.id
  212. },
  213. header: {
  214. 'token': token
  215. },
  216. method: "POST",
  217. success: (res) => {
  218. var date = res.data.data;
  219. this.altMainBalance = date.altMainBalance;
  220. },
  221. });
  222. },
  223. setStyle() {
  224. this.showOrNo = "block";
  225. },
  226. setStyle2() {
  227. this.showOrNo = "none";
  228. }
  229. }
  230. }
  231. </script>
  232. <style lang="scss">
  233. .home-getOrder {
  234. padding-top: 50upx;
  235. }
  236. .select-input {
  237. display: flex;
  238. flex-direction: row;
  239. justify-content: flex-start;
  240. font-size: 16px;
  241. border-bottom: 1px solid;
  242. margin: 20upx 30upx 30upx 30upx;
  243. // box-shadow: 0upx 0upx 20upx #D3D3D3;
  244. text {
  245. margin-left: 30upx;
  246. }
  247. input {
  248. padding-left: 20upx;
  249. background-color: #FFFFFF;
  250. width: 400upx;
  251. height: 50upx;
  252. // box-shadow: 0upx 0upx 20upx #D3D3D3;
  253. // border-radius: 5upx;
  254. }
  255. }
  256. .form {
  257. width: calc(100% - 100upx);
  258. padding: 50upx;
  259. // .section{
  260. // margin:50upx 0;
  261. // }
  262. .btn-area {
  263. margin-top: 50upx;
  264. padding: 50upx;
  265. button {
  266. background-color: #007AFF;
  267. }
  268. }
  269. }
  270. .input2{
  271. box-shadow: 0upx 0upx 20upx #D3D3D3;
  272. border-radius: 5upx;
  273. }
  274. .p2 {
  275. color: #DD524D;
  276. display: none;
  277. width: 300upx;
  278. height: 50upx;
  279. border: 1px;
  280. margin-left: auto;
  281. margin-right: auto;
  282. padding-left: 30upx;
  283. }
  284. </style>