学员端小程序
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

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