editMobile.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view class="page">
  3. <view class="list_info">
  4. <view class="name">旧手机号码:</view>
  5. <view class="item">
  6. <input type="text" class="input" placeholder="请输入旧手机号码" maxlength="11"/>
  7. </view>
  8. <view class="name">新手机号码:</view>
  9. <view class="item">
  10. <input type="text" class="input" placeholder="请输入新手机号码" maxlength="11"/>
  11. </view>
  12. <view class="name">验证码:</view>
  13. <view class="item">
  14. <input type="text" class="input" placeholder="请输入验证码" maxlength="6"/>
  15. <view class="btn">获取验证码</view>
  16. </view>
  17. <view class="blankHeight"></view>
  18. </view>
  19. <view class="btn_submit">提交修改</view>
  20. <!-- 提示框 -->
  21. <DialogBox ref="DialogBox"></DialogBox>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. components: {},
  27. data() {
  28. return {
  29. title: '',
  30. sel: 1,
  31. myinfo: {
  32. nickname: '王思思',
  33. join_name: '注册日期:2024年5月',
  34. num_1: 0,
  35. num_2: 0,
  36. num_3: 0,
  37. num_4: 0,
  38. is_login: 'no',
  39. num_history: 0,
  40. num_collection: 0
  41. },
  42. }
  43. },
  44. onLoad() {
  45. setTimeout(function() {
  46. uni.setNavigationBarColor({
  47. frontColor: '#ffffff',
  48. backgroundColor: '#00000000',
  49. animation: {
  50. duration: 400,
  51. timingFunc: 'easeIn'
  52. }
  53. })
  54. }, 200);
  55. },
  56. onShow() {
  57. this.loadData();
  58. },
  59. methods: {
  60. onBack() {},
  61. chkSel() {
  62. if (this.sel == 1) {
  63. this.sel = 0;
  64. } else {
  65. this.sel = 1;
  66. }
  67. },
  68. loadData() {
  69. console.log("this.globalData", getApp().globalData);
  70. let obj2 = {
  71. is_first: 0
  72. }
  73. const postData = Object.assign({}, getApp().globalData.postHeader, obj2);
  74. console.log(postData);
  75. uni.request({
  76. url: this.$apiHost + '/Gushi/getmyinfo', //仅为示例,并非真实接口地址。
  77. data: postData,
  78. method: 'POST',
  79. header: {
  80. 'content-type': 'application/json', //自定义请求头信息
  81. 'Access-Control-Allow-Origin': '*'
  82. },
  83. success: (res) => {
  84. console.log('data:', res.data);
  85. this.myinfo = res.data;
  86. }
  87. });
  88. },
  89. EditNickname() {
  90. let that = this;
  91. this.$refs['DialogBox'].confirm({
  92. title: '更改昵称',
  93. placeholder: '请输入修改的昵称',
  94. value: that.myinfo.nickname,
  95. DialogType: 'input',
  96. animation: 0
  97. }).then((res) => {
  98. if (res.value.length < 1) {
  99. uni.showToast({
  100. title: "请输入有效的昵称",
  101. icon: 'none'
  102. });
  103. return;
  104. }
  105. that.myinfo.nickname = res.value;
  106. let obj2 = {
  107. nickname: res.value
  108. }
  109. const postData = Object.assign({}, getApp().globalData.postHeader, obj2);
  110. uni.request({
  111. url: that.$apiHost + '/Gushi/editinfo', //检测是否已绑定
  112. data: postData,
  113. method: 'POST',
  114. header: {
  115. 'content-type': 'application/json', //自定义请求头信息
  116. 'Access-Control-Allow-Origin': '*'
  117. },
  118. success: (res) => {
  119. uni.showToast({
  120. title: res.data.str,
  121. icon: 'none'
  122. });
  123. }
  124. });
  125. })
  126. },
  127. }
  128. }
  129. </script>
  130. <style scoped lang="scss">
  131. @import 'normal.scss';
  132. </style>