refund.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <view class="pages">
  3. <view class="" :style="{height: navHeight+'px' }"></view>
  4. <view class="navbar-box">
  5. <u-navbar title="申请退款" :safeAreaInsetTop="true" @leftClick="leftClick" :titleStyle="{color:'#fff'}" leftIconColor="#fff" bgColor="#EF1818"></u-navbar>
  6. </view>
  7. <view class="page-wrap">
  8. <view class="box base-info">
  9. <view class="title u-flex u-row-between">
  10. <text>申请退款金额</text>
  11. <text>¥ {{refundAmount}}</text>
  12. </view>
  13. <view class="con">
  14. (预计3个工作日内退回)
  15. </view>
  16. </view>
  17. <view class="box reason">
  18. <view class="title">退款原因(必填)</view>
  19. <view class="select-reason u-flex u-row-between" @click="reasonshow=true">
  20. <text>{{refundReason||'请选择原因'}}</text>
  21. <u-icon name="arrow-down" color="#E5E5E5" size="36rpx"></u-icon>
  22. </view>
  23. <u-picker :show="reasonshow" :columns="reasonList" @confirm="confirmReason" @cancel="reasonshow=false"></u-picker>
  24. </view>
  25. </view>
  26. <view class="btn-wrap">
  27. <view class="inner">
  28. <view class="btn" @click="submit">确认退款</view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import { systemInfo } from "@/mixin.js";
  35. export default {
  36. mixins: [systemInfo], // 使用mixin
  37. data() {
  38. return {
  39. staticUrl:this.$commonConfig.staticUrl,
  40. orderId:'',
  41. refundAmount:'',
  42. viewerList:[],
  43. refundReason:'',
  44. reasonshow:false,
  45. reasonList:[
  46. [
  47. '选错场次',
  48. '计划有变',
  49. '其他'
  50. ]
  51. ],
  52. params:{
  53. },
  54. templateIdList:[],//微信小程序订阅消息
  55. }
  56. },
  57. onShow() {
  58. },
  59. onLoad(page) {
  60. console.log('page',page);
  61. this.orderId = page.id;
  62. this.refundAmount = page.refundAmount;
  63. this.viewerList = JSON.parse(page.viewerList);
  64. this.getSystemInfo();
  65. this.getTemplateIdList();//获取模板列表
  66. },
  67. methods: {
  68. leftClick(e){
  69. let pages = getCurrentPages();
  70. if(pages.length==1){
  71. // console.log('1111');
  72. uni.$u.route('/pages/index/index')
  73. }else{
  74. // console.log('2222222');
  75. uni.navigateBack()
  76. };
  77. },
  78. getTemplateIdList(){
  79. this.$u.api.templateIdList({templateLabel:'order_refund'}).then(res=>{
  80. console.log('res',res.data);
  81. this.templateIdList = res.data.list.map(item=>{
  82. return item.templateId
  83. });
  84. // if(this.templateIdList.length>0){
  85. // this.templateEven();
  86. // }
  87. }).catch(err=>{
  88. console.log('getTemplateIdList',err);
  89. })
  90. },
  91. confirmReason(e){
  92. console.log('confirmReason',e.value[0]);
  93. this.refundReason = e.value[0];
  94. this.reasonshow = false;
  95. },
  96. submit(){
  97. if(!this.refundReason){
  98. uni.$u.toast('请选择原因')
  99. return
  100. }
  101. // this.templateEven();
  102. // #ifdef MP
  103. this.setTemplate();
  104. // #endif
  105. // #ifdef H5
  106. this.handleSubmit();
  107. // #endif
  108. },
  109. handleSubmit(){
  110. let params = {
  111. orderId:this.orderId,
  112. refundReason:this.refundReason,
  113. refundAmount:this.refundAmount,
  114. viewerList:this.viewerList
  115. }
  116. this.$u.api.refundSubmit(params).then(res=>{
  117. uni.$u.toast(res.msg)
  118. // uni.navigateBack()
  119. setTimeout(()=>{
  120. uni.$u.route('/center/order');
  121. },1500)
  122. console.log('res',res.data);
  123. }).catch(err=>{
  124. console.log('refundSubmit',err);
  125. })
  126. },
  127. // 订阅消息
  128. templateEven(){
  129. let that = this
  130. wx.showModal({
  131. title: '温馨提示',
  132. content: '为更好的促进与您的交流,服务号需要实时向您发送消息',
  133. confirmText:"同意",
  134. cancelText:"拒绝",
  135. success: function (res) {
  136. if (res.confirm) {
  137. //调用订阅消息
  138. console.log('用户点击确定');
  139. //调用订阅
  140. that.setTemplate();
  141. } else if (res.cancel) {
  142. console.log('用户点击取消');
  143. ///显示第二个弹说明一下
  144. wx.showModal({
  145. title: '温馨提示',
  146. content: '拒绝后您将无法获取实时的消息',
  147. confirmText:"知道了",
  148. showCancel:false,
  149. success: function (res) {
  150. that.handleSubmit();
  151. ///点击知道了的后续操作
  152. ///如跳转首页面
  153. }
  154. });
  155. }
  156. }
  157. });
  158. },
  159. // 设置小程序订阅消息
  160. setTemplate() {
  161. let that = this;
  162. // console.log('templateIdList',this.templateIdList);
  163. wx.requestSubscribeMessage({
  164. tmplIds: this.templateIdList,
  165. success (res) {
  166. // that.handleSubmit();
  167. console.log("success:",res);
  168. },
  169. fail (res) {
  170. console.log("fail:",res);
  171. },
  172. complete (res) {
  173. that.handleSubmit();
  174. console.log("complete:",res);
  175. }
  176. })
  177. },
  178. }
  179. }
  180. </script>
  181. <style>
  182. page{background-color: #F7F7F9;}
  183. </style>
  184. <style lang="scss" scoped>
  185. .page-wrap{
  186. padding: 32rpx 16rpx;
  187. }
  188. .box{
  189. margin-bottom: 24rpx;
  190. background: #FFFFFF;
  191. box-shadow: 0rpx 0rpx 20rpx 2rpx rgba(221,221,221,0.5);
  192. border-radius: 20rpx;
  193. padding: 36rpx 24rpx;
  194. .title{
  195. font-size: 28rpx;
  196. font-weight: 500;
  197. color: #2D2D2D;
  198. margin-bottom: 38rpx;
  199. }
  200. }
  201. .base-info{
  202. .con{
  203. font-size: 24rpx;
  204. font-weight: 400;
  205. color: #7F7F7F;
  206. text-align: right;
  207. }
  208. }
  209. .reason{
  210. .select-reason{
  211. height: 64rpx;
  212. line-height: 64rpx;
  213. border-radius: 8rpx;
  214. border: 2rpx solid #E5E5E5;
  215. padding: 0 24rpx;
  216. font-size: 24rpx;
  217. font-weight: 400;
  218. color: #363636;
  219. }
  220. }
  221. .btn-wrap{
  222. height: 92rpx;
  223. .inner{
  224. position: fixed;
  225. left: 0;
  226. right: 0;
  227. bottom: 66rpx;
  228. }
  229. .btn{
  230. height: 92rpx;
  231. line-height: 92rpx;
  232. width:80%;
  233. margin: 0 auto;
  234. background: linear-gradient(90deg, #FF7878 0%, #ED0000 100%);
  235. border-radius: 46rpx;
  236. font-size: 28rpx;
  237. font-weight: 400;
  238. color: #FFFFFF;
  239. text-align: center;
  240. }
  241. }
  242. </style>