洛阳学员端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

321 lines
8.5 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
  1. <template>
  2. <view class="form">
  3. <view class="card">
  4. <view class="row" @click="showReason=true">
  5. <view class="lab">退款原因</view>
  6. <mySelect placeholder="请选择" :value="FormData.reasonName" style="flex: 1;"></mySelect>
  7. <view class="icon">
  8. <u-icon name="arrow-right"></u-icon>
  9. </view>
  10. </view>
  11. <!-- <view class="tpsBlue">此操作容易造成您已有学时丢失请谨慎</view> -->
  12. <view class="row">
  13. <view class="lab">退款金额</view>
  14. <view class="val">
  15. <u--input placeholder="请输入" border="none" clearable type="number" maxlength="11" v-model="FormData.amount" @blur="changePrice"></u--input>
  16. </view>
  17. </view>
  18. <!-- <view class="tpsHui">退款金额不可超过¥ {{$u.utils.priceTo(info.totalAmount)}}</view> -->
  19. </view>
  20. <view class="card">
  21. <view class="h1"><text class="active">收款信息</text></view>
  22. <view class="row">
  23. <view class="lab">持卡人</view>
  24. <view class="val">
  25. <u--input placeholder="请输入" border="none" clearable v-model="FormData.stuName"></u--input>
  26. </view>
  27. </view>
  28. <view class="row">
  29. <view class="lab">手机号</view>
  30. <view class="val">
  31. <view class="flex-b">
  32. <view class="inputBox">
  33. <u--input placeholder="请输入" border="none" type="number" maxlength="11" v-model="FormData.mobile"></u--input>
  34. </view>
  35. <view class="code" @click='goSms' :class="{active: isPhone&&!codeOn}">{{codeText}}</view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="row">
  40. <view class="lab" >验证码</view>
  41. <view class="val">
  42. <u--input placeholder="请输入" border="none" type="number" maxlength="11" v-model="FormData.code"></u--input>
  43. </view>
  44. </view>
  45. <view class="row">
  46. <view class="lab">卡号</view>
  47. <view class="val">
  48. <view class="flex-b">
  49. <view class="inputBox">
  50. <u--input placeholder="请输入" border="none" clearable v-model="FormData.idCard"></u--input>
  51. </view>
  52. <view class="scan" @click="scanningBanksClick">
  53. <image src="@/static/images/userCenter/btn_yinhangkax.png" mode=""></image>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="row">
  59. <view class="lab">开户行</view>
  60. <view class="val">
  61. <u--input placeholder="请输入" border="none" clearable v-model="FormData.bankName"></u--input>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="footerBtn">
  66. <view class="btnBg" @click="applyOnlineFundFn">提交</view>
  67. </view>
  68. <u-picker :show="showReason" :columns="reasonArr" keyName="label" @confirm="confirmReason" @cancel="showReason=false"></u-picker>
  69. </view>
  70. </template>
  71. <script>
  72. import { getdictDataList, applyOnlineFund, getLoginCode, scanningBanks } from '@/config/api.js'
  73. import { H5_API, WX_API,httpPrefix } from '@/config/site.config.js';
  74. import { chooseImages } from '@/config/utils.js'
  75. const _url = H5_API + WX_API + httpPrefix + 'app/apply-order/scanningBanks.do';
  76. export default {
  77. props: ['info', 'orderId'],
  78. data() {
  79. return {
  80. FormData: {
  81. reasonType: '',
  82. reasonName: '',
  83. mobile: '',
  84. amount: '',
  85. stuName: ''
  86. },
  87. FormDataToast: {
  88. reasonName: '请选择退款原因',
  89. amount: '请输入退款金额',
  90. stuName: '请输入持卡人',
  91. mobile: '请输入手机号',
  92. code: '请输入验证码',
  93. idCard: '请输入卡号',
  94. bankName: '请输入开启行'
  95. },
  96. showReason: false ,
  97. codeOn: false,
  98. reasonArr: [],
  99. codeText: '发送验证码',
  100. }
  101. },
  102. computed: {
  103. isPhone() {
  104. return uni.$u.test.mobile(this.FormData.mobile)
  105. }
  106. },
  107. created() {
  108. this.getdictDataListFn()
  109. console.log('_url')
  110. console.log(_url)
  111. },
  112. methods: {
  113. // 申请退款
  114. applyOnlineFundFn() {
  115. let _this = this
  116. uni.showModal({
  117. title: '确定要提交申请退款吗?',
  118. content: '提交申请后,待教练和驾校审核通过即可收到退款~',
  119. success: async ()=> {
  120. _this.onsubmit()
  121. }
  122. })
  123. },
  124. // 提交表单
  125. async onsubmit() {
  126. for(let key in this.FormDataToast) {
  127. if(!this.FormData[key]) {
  128. return this.$u.toast(this.FormDataToast[key])
  129. }
  130. }
  131. if(!this.isBankCardNumber(this.FormData.idCard)) return this.$u.toast('请输入正确的银行卡号')
  132. let obj = Object.assign({},this.FormData)
  133. obj.idCard = obj.idCard.replace(/\s/g, '');
  134. obj.studentId = this.studentId
  135. obj.orderId = this.orderId
  136. obj.feeType = this.info.orderType
  137. const res = await applyOnlineFund(obj)
  138. if(res.code==0) {
  139. this.$u.toast('申请退款成功')
  140. this.FormData = {
  141. reasonType: '',
  142. reasonName: '',
  143. mobile: '',
  144. amount: '',
  145. stuName: '',
  146. bankName: '',
  147. idCard: '',
  148. code: ''
  149. }
  150. setTimeout(()=>{
  151. this.$goPage('/pages/mineEntry/myOrder/detail/detail?orderId='+this.orderId+'&refundId='+res.data)
  152. },1500)
  153. }
  154. // console.log(res)
  155. },
  156. changePrice() {
  157. let maxPrice = this.$u.utils.priceTo(this.info.totalAmount)
  158. if(this.FormData.amount*1>maxPrice) {
  159. this.FormData.amount = ''
  160. return this.$u.toast('金额不得超过¥'+maxPrice)
  161. }
  162. },
  163. async getdictDataListFn() {
  164. const {data: res} = await getdictDataList()
  165. this.reasonArr = [ res ]
  166. // console.log(res)
  167. },
  168. confirmReason(val) {
  169. let item = val.value[0]
  170. this.FormData.reasonName = item.label
  171. this.FormData.reasonType = item.value
  172. this.showReason = false
  173. console.log(item)
  174. },
  175. // 基本的校验银行卡规则
  176. isBankCardNumber(cardNumber) {
  177. // 去除空格
  178. cardNumber = cardNumber.replace(/\s/g, '');
  179. // 银行卡号一般为 12-19 位数字
  180. const regex = /^[0-9]{12,19}$/;
  181. return regex.test(cardNumber);
  182. },
  183. // 发送短信验证码
  184. async goSms() {
  185. if (!this.FormData.mobile) return this.$u.toast('请输入手机号');
  186. if (!this.isPhone) return this.$u.toast('手机号格式有误');
  187. if (this.codeOn) return
  188. this.codeOn = true;
  189. let _this = this
  190. getLoginCode({
  191. // codeType: 1,
  192. mobile: this.FormData.mobile,
  193. scene: 1,
  194. }).then(()=>{
  195. // 获取验证码
  196. var time = 60;
  197. var timer = setInterval(() => {
  198. time--;
  199. _this.codeText = time + "秒后重新发送"
  200. if (time == 0) {
  201. clearInterval(timer);
  202. _this.codeText = "获取验证码";
  203. _this.codeOn = false;
  204. }
  205. }, 1000);
  206. }).catch(()=>{
  207. _this.codeOn = false;
  208. })
  209. },
  210. async scanningBanksClick() {
  211. // let filePath = await chooseImages(2)
  212. let _this = this
  213. let timer = new Date() * 1
  214. let token = 'Bearer '+ this.$store.state.user.vuex_loginInfo.accessToken
  215. uni.chooseImage({
  216. count: 1, //允许选择的数量
  217. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  218. sourceType: ['album', 'camera'], //从相册选择
  219. success: res => {
  220. // 上传图片到服务器
  221. console.log(res.tempFilePaths[0])
  222. uni.uploadFile({
  223. url: _url,//接口
  224. filePath: res.tempFilePaths[0],//要上传的图片的本地路径
  225. name: 'file',
  226. formData: {
  227. path: 'complain/'+ uni.$u.date(timer, 'yyyy-mm-dd')+'/'+timer + '-'+ 'scanningBanks',
  228. type: 1,
  229. fileSuffix: "png"
  230. },
  231. header: {
  232. Authorization: token,
  233. 'tenant-id': '1704459882232553474'
  234. },
  235. success(res) {
  236. console.log('上传成功')
  237. let res2 = JSON.parse(res.data)
  238. if(res2.code==0) {
  239. }
  240. // _this.imgArr.push(res2.data)
  241. console.log(res2)
  242. uni.hideLoading();
  243. },
  244. complete: (comp)=> {console.log(comp)}
  245. })
  246. }
  247. })
  248. }
  249. }
  250. }
  251. </script>
  252. <style lang="scss" scoped>
  253. .h1 {
  254. margin: 20rpx 0;
  255. }
  256. .card {
  257. padding: 4rpx 20rpx 28rpx 20rpx;
  258. margin-bottom: 24rpx;
  259. .row {
  260. display: flex;
  261. align-items: center;
  262. justify-content: space-between;
  263. height: 80rpx;
  264. line-height: 80rpx;
  265. .lab {
  266. font-size: 28rpx;
  267. color: #333;
  268. font-weight: 500;
  269. width: 152rpx;
  270. }
  271. .val {
  272. flex: 1;
  273. &.tpsBlue {
  274. font-size: 24rpx;
  275. }
  276. .flex-b {
  277. .scan {
  278. width: 44rpx;
  279. height: 44rpx;
  280. }
  281. .code {
  282. flex-shrink: 0;
  283. color: #ADADAD;
  284. &.active {
  285. color: $themC;
  286. }
  287. }
  288. }
  289. }
  290. .icon {
  291. u-icon {
  292. }
  293. }
  294. }
  295. .tpsBlue {
  296. color: $themC;
  297. margin-bottom: 10rpx;
  298. padding-left: 152rpx;
  299. font-size: 24rpx;
  300. }
  301. .tpsHui {
  302. font-size: 24rpx;
  303. color: #ADADAD;
  304. padding: 0rpx 0 16rpx 0;
  305. }
  306. }
  307. </style>