refund.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. <template>
  2. <view class="app-content">
  3. <view style="padding:30upx 30upx 140upx 30upx;">
  4. <view style="border:1upx solid #CCCCCC;border-radius: 10upx;margin:0upx 5upx 10upx 5upx;padding:10upx 0 10upx 5upx;">
  5. <view style="color:#3385FF;margin-bottom:10upx;font-size:29upx;">没拿货,拿货了退还了,<text style="font-weight:bold;">选退货并退款</text></view>
  6. <block v-if="orderInfo.ghsShopId && (orderInfo.ghsShopId == 26094 || orderInfo.ghsShopId == 25159)">
  7. <view style="color:#3385FF;margin-bottom:10upx;font-size:29upx;">货拿了,坏几支,损耗超10%,<text style="font-weight:bold;">选只退款</text></view>
  8. <view style="color:red;font-weight:bold;font-size:28upx;margin-top:15upx;">售后范围:10%以内损耗属正常运输损耗,不售后。超过10%的,可以售后。请在收货后12小时内申请售后。</view>
  9. </block>
  10. <block v-else>
  11. <view style="color:#3385FF;margin-bottom:10upx;font-size:29upx;">货拿了,坏几支,损耗超20%,<text style="font-weight:bold;">选只退款</text></view>
  12. <view style="color:red;font-weight:bold;font-size:28upx;margin-top:15upx;">售后范围:20%以内损耗属正常运输损耗,不售后。超过20%的,可以售后。请在收货后12小时内申请售后。</view>
  13. </block>
  14. </view>
  15. <view class="flex refund-item">
  16. <view class="refund-label">退款方式:</view>
  17. <view class="flex list">
  18. <view class="flex" @tap="refundType=1" >
  19. <view class="flex-center radioBtn" :class="refundType==1?'active':''">
  20. </view>退货并退款</view>
  21. <view style="margin-left:50upx" class="flex" @tap="refundType=2">
  22. <view class="flex-center radioBtn" :class="refundType==1?'':'active'">
  23. </view>只退款</view>
  24. </view>
  25. </view>
  26. <view class="refund-item-list" v-if="refundType==1">
  27. <view class="refund-label"><text></text>选择商品:</view>
  28. <view>
  29. <view class="list" v-for="(res,i) in product" :key="i">
  30. <view class="flex list-title" >
  31. <text class="product-name">{{res.name}}</text>
  32. <text class="product-num">{{ `${parseFloat(res.xhNum)}` }}{{res.xhUnitName}}</text>
  33. <text class="product-price">{{`${parseFloat(res.xhUnitPrice)}`}}元/{{res.xhUnitName}}</text>
  34. </view>
  35. <view class="flex list-val" style="font-size:26upx;font-weight:bold;">
  36. <input type="number" placeholder="填退货数" v-model="res.refundCount" placeholder-style="color:#CCCCCC" />
  37. <text style="margin-left:10upx;">{{res.xhUnitName}}</text>
  38. <text style="color:green;margin-left:20upx;">可退{{Number(res.xhNum)-Number(res.refundNum)}}{{res.xhUnitName}}</text>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="flex refund-item">
  44. <view class="refund-label">订单金额:</view>
  45. <view class="list">
  46. ¥{{parseFloat(orderInfo.orderPrice)||0}}
  47. <text style="margin-left:25upx;font-size:25upx;color:green;" v-if="Number(orderInfo.tkPrice)>0">已退¥{{orderInfo.tkPrice ? parseFloat(orderInfo.tkPrice) : 0}}</text>
  48. </view>
  49. </view>
  50. <view class="flex refund-item">
  51. <view class="refund-label">可退金额:</view>
  52. <view class="list">¥{{couldRefundPrice}}</view>
  53. </view>
  54. <view class="flex refund-item">
  55. <view class="refund-label">预计退款:</view>
  56. <view class="list">¥{{refundPrice}}</view>
  57. </view>
  58. <view class="flex refund-item">
  59. <view class="refund-label"><text></text>实际退款:</view>
  60. <input type="digit" v-model="refundMoney" @focus="refundMoney=''">
  61. </view>
  62. <!-- #ifdef MP-WEIXIN -->
  63. <view class="flex refund-item">
  64. <view class="refund-label">审核通知:</view>
  65. <view class="list">
  66. <button class="admin-button-com middle default" @click="noticeMe()" v-if="needNotice == 0">点击开启通知</button>
  67. <button class="admin-button-com middle blue" v-else>已经开启通知</button>
  68. </view>
  69. </view>
  70. <!-- #endif -->
  71. <view class="refund-item">
  72. <view class="refund-label">备注说明:</view>
  73. <textarea v-model="remark" style="height:100upx;"></textarea>
  74. </view>
  75. <view>
  76. <form>
  77. <div class="module-com input-line-wrap">
  78. <div class="module-com input-line-wrap goods-wrap">
  79. <div class="module-tit" style="padding-left:0upx;">
  80. <span>售后图片:</span>
  81. <text @click="getRule()" style="font-weight:bold;text-decoration: underline;float:right;color:red;">图片拍照规范</text>
  82. </div>
  83. <div class="module-det">
  84. <htz-image-upload :max="9" :compress="true" v-model="refundImgData" :headers="headers"
  85. @uploadSuccess="imgUploadSuccess" :quality="60" @imgDelete="imgDeleteFn" :action="getLoginInfo.imgUploadApi">
  86. </htz-image-upload>
  87. <view style="color:red;font-weight:bold;">必须按拍照规范,提供图片,否则申请将被驳回</view>
  88. </div>
  89. </div>
  90. </div>
  91. </form>
  92. </view>
  93. </view>
  94. <view class="app-footer">
  95. <button class="admin-button-com big default" @click="cancelRefund()">取消</button>
  96. <button class="admin-button-com big blue" formType="submit" @click="confirmRefund">提交申请</button>
  97. </view>
  98. </view>
  99. </template>
  100. <script>
  101. import { mapGetters } from "vuex"
  102. import TuiListCell from "@/components/plugin/list-cell";
  103. import { getFullInfo } from "@/api/purchase";
  104. import { createRefund } from "@/api/cg-refund";
  105. //图片上传插件来源:https://ext.dcloud.net.cn/plugin?id=2922 已改造,不能再升级 shish 20211228
  106. import htzImageUpload from '@/components/htz-image-upload/htz-image-upload.vue'
  107. export default {
  108. name: "refund",
  109. components: {
  110. TuiListCell,
  111. htzImageUpload
  112. },
  113. data() {
  114. return {
  115. product:[],
  116. refundMoney:0,
  117. refundType:1,
  118. remark:'',
  119. orderInfo:{},
  120. couldRefundPrice:0,
  121. unClear:[],
  122. refundImgData:[],
  123. uploadRefundImg:[],
  124. headers:{token:''},
  125. needNotice:0
  126. };
  127. },
  128. onLoad() {
  129. const token = uni.getStorageSync('token')
  130. this.headers.token = token
  131. },
  132. computed:{
  133. ...mapGetters(["getLoginInfo","getDictionariesInfo"]),
  134. refundPrice(){
  135. let price = 0
  136. if(this.product){
  137. for (const item of this.product) {
  138. if(Number(item.refundCount)>0){
  139. let currentPrice = Number(item.refundCount)*Number(item.xhUnitPrice)
  140. currentPrice.toFixed(2)
  141. price = Number(price) + Number(currentPrice)
  142. price.toFixed(2)
  143. }
  144. }
  145. }
  146. price = parseFloat(price.toFixed(2))
  147. this.refundMoney = price
  148. return price
  149. }
  150. },
  151. watch:{
  152. },
  153. methods: {
  154. noticeMe(){
  155. // #ifdef MP-WEIXIN
  156. let that = this
  157. if(this.getDictionariesInfo && this.getDictionariesInfo.subscribeMessage && this.getDictionariesInfo.subscribeMessage == 1 && this.getDictionariesInfo.hdMiniMessage && this.getDictionariesInfo.hdMiniMessage.afterSale){
  158. uni.requestSubscribeMessage({
  159. tmplIds: [this.getDictionariesInfo.hdMiniMessage.afterSale.msgId],
  160. success(res) {
  161. if(res[that.getDictionariesInfo.hdMiniMessage.afterSale.msgId] && res[that.getDictionariesInfo.hdMiniMessage.afterSale.msgId] == 'accept'){
  162. that.needNotice = 1
  163. }
  164. },
  165. fail(err) {
  166. console.log(err)
  167. },
  168. complete() {}
  169. })
  170. }
  171. // #endif
  172. },
  173. getRule(){
  174. this.$util.pageTo({url:'/pagesPurchase/afterSale'})
  175. },
  176. imgUploadSuccess(res) {
  177. var _res = JSON.parse(res.data)
  178. if(_res.code == 1){
  179. this.refundImgData.push(_res.data.smallUrl)
  180. this.uploadRefundImg.push(_res.data.shortUrl)
  181. }
  182. },
  183. cancelRefund(){
  184. uni.navigateBack({delta: 1});
  185. },
  186. confirmRefund(){
  187. let hasError = false
  188. let product = []
  189. let that = this
  190. this.product.forEach(ele=>{
  191. let currentRefundCont = ele.refundCount ? Number(ele.refundCount) :0
  192. let currentNum = ele.xhNum ? Number(ele.xhNum) : 0
  193. let hasRefundNum = ele.refundNum ? Number(ele.refundNum) : 0
  194. let couldRefundNum = Number(currentNum) - Number(hasRefundNum)
  195. if(Number(currentRefundCont) > Number(couldRefundNum)){
  196. uni.showToast({title:ele.name+' 超过可退数量',icon:'none'})
  197. hasError = true;
  198. return false
  199. }
  200. if(Number(ele.refundCount)>0){
  201. product.push({
  202. "productId":ele.productId,
  203. "num":ele.refundCount,
  204. "unitType":ele.unitType,
  205. unitName:ele.xhUnitName,
  206. unitType:ele.xhUnitType,
  207. unitPrice:ele.xhUnitPrice
  208. })
  209. }
  210. })
  211. if(hasError){
  212. return
  213. }
  214. if(this.$util.isEmpty(product)&&this.refundType==1){
  215. uni.showToast({title:'请选择商品',icon:'none'})
  216. return;
  217. }
  218. let imgData = JSON.stringify(this.uploadRefundImg)
  219. let refundParams = {
  220. id:this.option.id,
  221. product:JSON.stringify(product),
  222. price:this.refundMoney,
  223. remark:this.remark,
  224. refundType:this.refundType,
  225. getOriginalItem:1,
  226. imgList:imgData
  227. };
  228. that.$util.confirmModal({content:'确认提交?'},() => {
  229. uni.showLoading({title: "提交中",mask:true})
  230. createRefund(refundParams).then(res => {
  231. if(res.code == 1){
  232. that.$util.pageTo({url: '/pagesPurchase/refundResult?id='+res.data.id,type:2})
  233. }
  234. })
  235. })
  236. },
  237. async init() {
  238. //getOriginalItem 取原有的花材结构(小菊的花材结构有变化)
  239. const res = await getFullInfo({ id: this.option.id,getOriginalItem:1 })
  240. this.orderInfo = res.data
  241. this.couldRefundPrice = Number(res.data.orderPrice) - Number(res.data.tkPrice)
  242. this.couldRefundPrice = this.couldRefundPrice.toFixed(2)
  243. this.couldRefundPrice = parseFloat(this.couldRefundPrice)
  244. this.product = res.data.product.map(ele=>{
  245. return {...ele,refundCount:null}
  246. })
  247. }
  248. }
  249. };
  250. </script>
  251. <style lang="scss" scoped>
  252. .module-com {
  253. margin-bottom: 20upx;
  254. background-color: #fff;
  255. color: $fontColor2;
  256. .module-tit {
  257. padding: 20upx 30upx;
  258. font-size: 28upx;
  259. }
  260. .module-det {
  261. padding: 0 30upx;
  262. }
  263. }
  264. .app-content{
  265. height: calc(100vh - 30upx * 2);
  266. background: #FFFFFF;
  267. font-size: 30upx;
  268. .radioBtn{
  269. width: 30upx;
  270. height: 30upx;
  271. margin-right: 10upx;
  272. border: 1upx solid #ddd;
  273. border-radius: 50%;
  274. &.active{
  275. position: relative;
  276. border: 1upx solid #3385ff;
  277. &:after{
  278. content: '';
  279. position: absolute;
  280. width: 18upx;
  281. height: 18upx;
  282. background: #3385ff;
  283. border-radius: 50%;
  284. }
  285. }
  286. }
  287. .refund-item-list{
  288. display: flex;
  289. padding-bottom: 30upx;
  290. padding-top: 30upx;
  291. border-top: 1upx solid #e6e4e4;
  292. border-bottom: 1upx solid #e6e4e4;
  293. .refund-label{
  294. width: 200upx;
  295. color:#666666;
  296. font-size:26upx;
  297. text{color: red;}
  298. }
  299. .list{
  300. margin-bottom:18upx;
  301. border-bottom:1upx solid #CCCCCC;
  302. padding-bottom:14upx;
  303. .list-title{
  304. height: 60upx;
  305. padding-bottom: 20upx;
  306. font-size:26upx;
  307. font-weight:bold;
  308. .product-name{
  309. overflow: hidden;
  310. text-overflow:ellipsis;
  311. white-space: nowrap;
  312. width:190upx;
  313. }
  314. .product-price{
  315. overflow: hidden;
  316. text-overflow:ellipsis;
  317. white-space: nowrap;
  318. width:130upx;
  319. margin-left:10upx;
  320. }
  321. .product-num{
  322. width:90upx;
  323. overflow: hidden;
  324. text-overflow:ellipsis;
  325. white-space: nowrap;
  326. margin-left:10upx;
  327. }
  328. }
  329. .list-val{
  330. input{
  331. width: 200upx;
  332. border: 1upx solid #ddd;
  333. text-align: center;
  334. font-weight: normal;
  335. }
  336. }
  337. }
  338. }
  339. .refund-item{
  340. display: flex;
  341. padding: 18upx 0;
  342. .refund-label{
  343. width: 200upx;
  344. color:#666666;
  345. font-size:26upx;
  346. text{
  347. color: red;
  348. }
  349. }
  350. input{
  351. border: 1upx solid #ddd;
  352. }
  353. textarea{
  354. width: calc(100% - 210upx);
  355. height:150upx;
  356. border: 1upx solid #ddd;
  357. }
  358. }
  359. .btn-box{
  360. .btn{
  361. width: 220upx;
  362. height: 90upx;
  363. border: 1upx solid #666666;
  364. border-radius: 10upx;
  365. color:#666666;
  366. &.active{
  367. background: #3385ff;
  368. color: #fff;
  369. border: 1upx solid #3385ff;
  370. }
  371. }
  372. }
  373. }
  374. .app-footer {
  375. justify-content: space-evenly;
  376. z-index: 9999;
  377. .admin-button-com {
  378. width: 46%;
  379. }
  380. }
  381. </style>