info.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <view>
  3. <view class="main">
  4. <view class="form">
  5. <view class="form_group">
  6. <view class="lable">手机号</view>
  7. <input type="text" v-model="item.phone" placeholder="请输入手机号" />
  8. </view>
  9. <view class="form_group">
  10. <view class="lable">支付宝</view>
  11. <input type="text" v-model="item.alipay" placeholder="请输入支付宝账号" />
  12. </view>
  13. </view>
  14. <button class="btn" @click="save()">确定</button>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. data() {
  21. return {
  22. item: {}
  23. };
  24. },
  25. onLoad() {
  26. this.getData();
  27. },
  28. methods: {
  29. getData() {
  30. this.http.request({
  31. url: '/app/user/info',
  32. data: this.item,
  33. success: (res) => {
  34. this.item = res.data.data;
  35. }
  36. });
  37. },
  38. save() {
  39. let rule = [
  40. { name: 'phone', checkType: 'phone', errorMsg: '请请输入手机号' },
  41. { name: 'alipay', checkType: 'notnull', errorMsg: '请输入支付宝账号' }
  42. ];
  43. if (!this.verify.check(this.item, rule)) {
  44. uni.showModal({ content: this.verify.error, showCancel: false });
  45. return false;
  46. }
  47. this.http.request({
  48. url: '/app/user/edit',
  49. data: this.item,
  50. method: 'POST',
  51. success: (res) => {
  52. uni.showModal({
  53. title: '提示',
  54. content: '编辑成功。',
  55. showCancel: false,
  56. success: (res) => {
  57. uni.navigateBack();
  58. }
  59. });
  60. }
  61. });
  62. }
  63. }
  64. };
  65. </script>
  66. <style lang="scss">
  67. .btn {
  68. margin-top: 30px;
  69. }
  70. </style>