refund.vue 5.4 KB

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