rechargeSubmit.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <view>
  3. <ujp-navbar title="绑定充电卡" :isBack="isBack">
  4. </ujp-navbar>
  5. <view class="recharge" v-show="!queryInfo">
  6. <view class="recharge-text">
  7. <view class="recharge-title">绑定卡号</view>
  8. <view class="recharge-value">
  9. <u-input v-model="cardNo" :custom-style="customStyle" :placeholder-style="placeholderStyle"
  10. :height="height" placeholder="请填写绑定卡号"></u-input>
  11. </view>
  12. </view>
  13. <view class="recharge-text">
  14. <view class="recharge-title">用户姓名</view>
  15. <view class="recharge-value">
  16. <u-input v-model="name" :custom-style="customStyle" :placeholder-style="placeholderStyle"
  17. :height="height" placeholder="请填写用户姓名"></u-input>
  18. </view>
  19. </view>
  20. <view class="recharge-text">
  21. <view class="recharge-title">手机号码</view>
  22. <view class="recharge-value">
  23. <u-input v-model="phone" :custom-style="customStyle" :placeholder-style="placeholderStyle"
  24. :height="height" placeholder="请填写绑定手机号"></u-input>
  25. </view>
  26. </view>
  27. <view class="recharge-text">
  28. <view class="recharge-title">绑定状态</view>
  29. <view class="recharge-value FF7B00 ">
  30. 未绑定
  31. </view>
  32. </view>
  33. <view class="foot-btn">
  34. <u-button type="primary" @click="submit" shape="square">确定绑定</u-button>
  35. </view>
  36. </view>
  37. <view class="recharge" v-show="queryInfo">
  38. <view class="recharge-text">
  39. <view class="recharge-title">绑定卡号</view>
  40. <view class="recharge-value">
  41. {{cardNo}}
  42. </view>
  43. </view>
  44. <view class="recharge-text">
  45. <view class="recharge-title">用户姓名</view>
  46. <view class="recharge-value">
  47. {{name}}
  48. </view>
  49. </view>
  50. <view class="recharge-text">
  51. <view class="recharge-title">手机号码</view>
  52. <view class="recharge-value">
  53. {{phone}}
  54. </view>
  55. </view>
  56. <view class="recharge-text">
  57. <view class="recharge-title">绑定状态</view>
  58. <view class="recharge-value color3a7cf6 ">
  59. 已绑定
  60. </view>
  61. </view>
  62. <view class="foot-btn">
  63. <u-button type="success" @click="gotoUrl('pages/user/rechargeByPhone?phone='+phone)" shape="square">前往充值</u-button>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. import {
  70. checkPhone
  71. } from '@/utils'
  72. import * as API from '@/apis/otherRecharge.js'
  73. export default {
  74. data() {
  75. return {
  76. isReady: true,
  77. height: 82,
  78. customStyle: {
  79. 'font-size': '42rpx',
  80. 'line-height': '42rpx',
  81. },
  82. placeholderStyle: {
  83. 'font-size': '42rpx',
  84. 'line-height': '42rpx',
  85. 'color': ' rgba(204, 204, 204, 1)',
  86. },
  87. cardNo:"",
  88. name:"",
  89. phone:"",
  90. queryCard:{},
  91. queryInfo:false,
  92. }
  93. },
  94. onLoad(op) {
  95. },
  96. onReady() {
  97. },
  98. methods: {
  99. submitApi() {
  100. uni.showLoading({
  101. title: "加载中",
  102. mask: true,
  103. })
  104. API.bindCard({
  105. cardNo: this.cardNo,
  106. phone: this.phone,
  107. name: this.name
  108. }).then((response) => {
  109. var data = response.data
  110. uni.hideLoading()
  111. this.queryInfo=true
  112. }).catch(error => {
  113. uni.showToast({
  114. title: error
  115. })
  116. })
  117. },
  118. submit() {
  119. if (!this.cardNo) {
  120. uni.showToast({
  121. title: "请填写绑定卡号",
  122. })
  123. return;
  124. }
  125. if (!this.name) {
  126. uni.showToast({
  127. title: "请填写用户姓名",
  128. })
  129. return;
  130. }
  131. if (!this.phone) {
  132. uni.showToast({
  133. title: "请填写绑定手机号",
  134. })
  135. return;
  136. }
  137. var checkPhoneResult = checkPhone(this.phone);
  138. if (checkPhoneResult !== true) {
  139. uni.showToast({
  140. title: checkPhoneResult,
  141. })
  142. return;
  143. }
  144. uni.showLoading({
  145. title: "加载中",
  146. mask: true,
  147. })
  148. API.findByCard({
  149. cardNo: this.cardNo,
  150. }).then((response) => {
  151. var data = response.data
  152. uni.hideLoading()
  153. if(data.regUser){
  154. uni.showModal({
  155. title:"提示",
  156. content:"当前卡号已被其他用户绑定",
  157. showCancel:false,
  158. })
  159. }
  160. this.submitApi()
  161. }).catch(error => {
  162. uni.hideLoading()
  163. uni.showModal({
  164. title:"提示",
  165. content:error,
  166. showCancel:false,
  167. })
  168. })
  169. },
  170. },
  171. onShow() {
  172. if (this.isReady) {
  173. }
  174. }
  175. }
  176. </script>
  177. <style>
  178. page {
  179. background-color: #f7f7f7;
  180. }
  181. </style>
  182. <style lang="scss" scoped>
  183. .FF7B00 {
  184. color: #FF7B00;
  185. }
  186. .color3a7cf6{
  187. color: #58ba73;
  188. }
  189. .foot-btn{
  190. margin-top: 80rpx;
  191. }
  192. .recharge {
  193. padding:0 30rpx 30rpx 30rpx;
  194. //background-color: #1677FF;
  195. background-color: #fff;
  196. margin-bottom: 20rpx;
  197. .recharge-text {
  198. font-size: 36rpx;
  199. padding:12rpx;
  200. width: 100%;
  201. display: flex;
  202. align-items: center;
  203. border-bottom: 1px solid #eeeeee;
  204. .recharge-title {
  205. width: 30%;
  206. color: rgb(96, 98, 102);
  207. }
  208. }
  209. }
  210. </style>