addOwnerInformation.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <view>
  3. <ujp-navbar :title="id!=0?'编辑':'新增'">
  4. <view slot="right" @click="infodelete()"
  5. v-if="id!=0"
  6. style="margin-right: 20px;">
  7. <span class="delete" >删除</span>
  8. </view>
  9. </ujp-navbar>
  10. <u-keyboard ref="uKeyboard"
  11. @change="valChange" @backspace="backspace"
  12. mode="car" v-model="show"></u-keyboard>
  13. <view class="ower-infos">
  14. <view class="infos-item">
  15. <view class="title">
  16. 手机号码<text class="asterisk">*</text>
  17. </view>
  18. <view class="content">
  19. <u-input v-model="obj.phone" placeholder="请填写手机号码" />
  20. </view>
  21. </view>
  22. <view class="infos-item">
  23. <view class="title">
  24. 用户姓名
  25. </view>
  26. <view class="content">
  27. <u-input v-model="obj.userName" placeholder="请填写车主姓名" />
  28. </view>
  29. </view>
  30. <view class="infos-item border-none">
  31. <view class="title">
  32. 车牌号码
  33. </view>
  34. <view class="content" @click="show=true">
  35. {{obj.carNum?obj.carNum:'请填写车牌号码'}}
  36. </view>
  37. </view>
  38. </view>
  39. <u-button type="primary" @click="submit()">保存</u-button>
  40. </view>
  41. </template>
  42. <script>
  43. import * as API from '@/apis/finance.js'
  44. import {
  45. checkPhone
  46. } from '@/utils'
  47. export default {
  48. data() {
  49. return {
  50. show:false,
  51. value:'',
  52. uuid:'',
  53. id:"",
  54. platform:"",
  55. obj:{
  56. platform:"",
  57. userName:"",
  58. phone:"",
  59. carNum:"",
  60. vipUserId:"",
  61. }
  62. }
  63. },
  64. onReady() {
  65. if(this.id!=0){
  66. this.getInfo()
  67. }
  68. },
  69. onLoad(op) {
  70. this.platform=op.p
  71. this.id=op.id
  72. this.uuid=op.uuid;
  73. },
  74. methods: {
  75. // 按键被点击(点击退格键不会触发此事件)
  76. valChange(val) {
  77. // 将每次按键的值拼接到value变量中,注意+=写法
  78. this.value += val;
  79. console.log(this.value);
  80. this.obj.carNum=this.value
  81. },
  82. // 退格键被点击
  83. backspace() {
  84. // 删除value的最后一个字符
  85. if(this.value.length) this.value = this.value.substr(0, this.value.length - 1);
  86. console.log(this.value);
  87. this.obj.carNum=this.value
  88. },
  89. infodelete(){
  90. uni.showLoading({
  91. title: "加载中",
  92. mask: true,
  93. })
  94. this.obj.platform=this.platform
  95. API.vipUserDelete(this.obj).then((res) => {
  96. uni.hideLoading()
  97. this.carhelp.set("addOwnerInformation",{
  98. uuid:this.uuid,
  99. selectObj:this.obj
  100. })
  101. uni.showModal({
  102. showCancel:false,
  103. title: '提示',
  104. content: '操作成功',
  105. success: function (res) {
  106. uni.navigateBack({
  107. })
  108. }
  109. });
  110. }).catch(error => {
  111. uni.showToast({
  112. title: error
  113. })
  114. })
  115. },
  116. submit(){
  117. if(!this.obj.phone){
  118. uni.showToast({
  119. title: "请填写手机号码"
  120. })
  121. return false
  122. }
  123. var checkPhoneResult = checkPhone(this.obj.phone);
  124. if (checkPhoneResult !== true) {
  125. uni.showToast({
  126. title: checkPhoneResult,
  127. })
  128. return;
  129. }
  130. uni.showLoading({
  131. title: "加载中",
  132. mask: true,
  133. })
  134. this.obj.platform=this.platform
  135. API.vipUserSave(this.obj).then((res) => {
  136. uni.hideLoading()
  137. this.carhelp.set("addOwnerInformation",{
  138. uuid:this.uuid,
  139. selectObj:this.obj
  140. })
  141. uni.showModal({
  142. showCancel:false,
  143. title: '提示',
  144. content: '操作成功',
  145. success: function (res) {
  146. uni.navigateBack({
  147. })
  148. }
  149. });
  150. }).catch(error => {
  151. uni.showToast({
  152. title: error
  153. })
  154. })
  155. },
  156. getInfo(){
  157. uni.showLoading({
  158. title: "加载中",
  159. mask: true,
  160. })
  161. API.vipUserDetails({
  162. vipUserId:this.id,
  163. }).then((res) => {
  164. this.obj=res.data.vipUser;
  165. this.obj.vipUserId=this.id
  166. uni.hideLoading()
  167. }).catch(error => {
  168. uni.showToast({
  169. title: error
  170. })
  171. })
  172. }
  173. }
  174. }
  175. </script>
  176. <style lang="scss" scoped>
  177. page{
  178. background-color: #f3f4f7;
  179. }
  180. .ower-infos{
  181. background-color: #fff;
  182. padding-left: 16px;
  183. .border-none{
  184. border: none !important;
  185. }
  186. .infos-item{
  187. padding: 14px 0;
  188. display: flex;
  189. border-bottom: 1px solid #BABABA ;
  190. .title{
  191. width: 30%;
  192. font-size: 16px;
  193. color: #7d7d7d;
  194. .asterisk{
  195. color: #EE3138;
  196. }
  197. }
  198. .content{
  199. color: rgba(172, 172, 172, 100);
  200. font-size: 16px;
  201. }
  202. }
  203. }
  204. .u-btn{
  205. background-color: rgba(0, 90, 217, 100);
  206. margin: 16px;
  207. height: 44px;
  208. line-height: 44px;
  209. font-size: 18px
  210. }
  211. .delete{
  212. color: rgba(238, 49, 56, 100);
  213. font-size: 16px;
  214. }
  215. </style>