refund.vue 5.2 KB

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