refund.vue 5.4 KB

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