nickname.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <style>
  2. page{background: #ffffff;}
  3. .m-app{width:100vw}
  4. button.sub-btn{width:100%;height:40px;line-height: 40px; background:#db292b;border-radius:20px;font-size:15px;font-weight:500;color:#ffffff;margin-top: 30px;}
  5. .form-body{width:calc(100% - 24px);background: #ffffff;padding: 0px 12px;}
  6. .form-title{width:100%;text-align: left;font-size: 14px;color:#333333;height:38px;line-height: 38px;}
  7. .form-content{width:100%}
  8. input.form-input{height:38px;width:100%;text-align: left;color:#db292b;border-bottom: 1px solid #db292b;font-size: 14px;}
  9. .form-msg{font-size: 12px;text-align: left;width:100%;height:30px;line-height: 30px;color:#303033}
  10. </style>
  11. <template>
  12. <view class="m-app">
  13. <form report-submit="true" @submit="formSubmit">
  14. <view class='form-body'>
  15. <view class="form-title">
  16. 用户昵称:
  17. </view>
  18. <view class="form-content">
  19. <input class="form-input" type="text" name="val" :value="val"/>
  20. </view>
  21. <view class="form-msg">限4-16个字符,一个汉字为两个字符</view>
  22. <button class="nt sub-btn" formType="submit">确认保存</button>
  23. </view>
  24. </form>
  25. </view>
  26. </template>
  27. <script>
  28. import {mapState,mapMutations} from 'vuex'
  29. export default {
  30. computed: mapState(['user']),
  31. data() {
  32. return {
  33. val:""
  34. }
  35. },
  36. onLoad(options) {
  37. this.val = options.val || "";
  38. },
  39. methods: {
  40. formSubmit:function(e){
  41. var that = this , formData = e.detail.value;
  42. if(!this.utils.isDefine(formData.val)){
  43. this.utils.Tip("输入正确的用户昵称");
  44. return;
  45. }
  46. formData.code = "nickname";
  47. this.utils.loadIng("提交中..")
  48. this
  49. .request
  50. .post("userInfoSave",formData)
  51. .then(res=>{
  52. uni.hideLoading();
  53. if(res.code == 200) {
  54. this.utils.Tip(res.msg);
  55. setTimeout(function(){ uni.navigateBack();},1000);
  56. }else{
  57. that.utils.Tip(res.msg);
  58. }
  59. }).catch(function(){
  60. uni.hideLoading();
  61. that.utils.Tip("网络错误,请稍后尝试");
  62. });
  63. }
  64. },
  65. }
  66. </script>