refund.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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/orderdetails', {
  121. type:'redirectTo',
  122. id: this.orderId
  123. });
  124. // uni.$u.route('/center/order');
  125. },1500)
  126. console.log('res',res.data);
  127. }).catch(err=>{
  128. console.log('refundSubmit',err);
  129. })
  130. },
  131. // 订阅消息
  132. templateEven(){
  133. let that = this
  134. wx.showModal({
  135. title: '温馨提示',
  136. content: '为更好的促进与您的交流,服务号需要实时向您发送消息',
  137. confirmText:"同意",
  138. cancelText:"拒绝",
  139. success: function (res) {
  140. if (res.confirm) {
  141. //调用订阅消息
  142. console.log('用户点击确定');
  143. //调用订阅
  144. that.setTemplate();
  145. } else if (res.cancel) {
  146. console.log('用户点击取消');
  147. ///显示第二个弹说明一下
  148. wx.showModal({
  149. title: '温馨提示',
  150. content: '拒绝后您将无法获取实时的消息',
  151. confirmText:"知道了",
  152. showCancel:false,
  153. success: function (res) {
  154. that.handleSubmit();
  155. ///点击知道了的后续操作
  156. ///如跳转首页面
  157. }
  158. });
  159. }
  160. }
  161. });
  162. },
  163. // 设置小程序订阅消息
  164. setTemplate() {
  165. let that = this;
  166. // console.log('templateIdList',this.templateIdList);
  167. wx.requestSubscribeMessage({
  168. tmplIds: this.templateIdList,
  169. success (res) {
  170. // that.handleSubmit();
  171. console.log("success:",res);
  172. },
  173. fail (res) {
  174. console.log("fail:",res);
  175. },
  176. complete (res) {
  177. that.handleSubmit();
  178. console.log("complete:",res);
  179. }
  180. })
  181. },
  182. }
  183. }
  184. </script>
  185. <style>
  186. page{background-color: #F7F7F9;}
  187. </style>
  188. <style lang="scss" scoped>
  189. .page-wrap{
  190. padding: 32rpx 16rpx;
  191. }
  192. .box{
  193. margin-bottom: 24rpx;
  194. background: #FFFFFF;
  195. box-shadow: 0rpx 0rpx 20rpx 2rpx rgba(221,221,221,0.5);
  196. border-radius: 20rpx;
  197. padding: 36rpx 24rpx;
  198. .title{
  199. font-size: 28rpx;
  200. font-weight: 500;
  201. color: #2D2D2D;
  202. margin-bottom: 38rpx;
  203. }
  204. }
  205. .base-info{
  206. .con{
  207. font-size: 24rpx;
  208. font-weight: 400;
  209. color: #7F7F7F;
  210. text-align: right;
  211. }
  212. }
  213. .reason{
  214. .select-reason{
  215. height: 64rpx;
  216. line-height: 64rpx;
  217. border-radius: 8rpx;
  218. border: 2rpx solid #E5E5E5;
  219. padding: 0 24rpx;
  220. font-size: 24rpx;
  221. font-weight: 400;
  222. color: #363636;
  223. }
  224. }
  225. .btn-wrap{
  226. height: 92rpx;
  227. .inner{
  228. position: fixed;
  229. left: 0;
  230. right: 0;
  231. bottom: 66rpx;
  232. }
  233. .btn{
  234. height: 92rpx;
  235. line-height: 92rpx;
  236. width:80%;
  237. margin: 0 auto;
  238. background: linear-gradient(90deg, #FF7878 0%, #ED0000 100%);
  239. border-radius: 46rpx;
  240. font-size: 28rpx;
  241. font-weight: 400;
  242. color: #FFFFFF;
  243. text-align: center;
  244. }
  245. }
  246. </style>