refund.vue 5.7 KB

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