userinfoSet.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <view>
  3. <customNav :shownav="true" :title="$t('index.usermsg')" titledetl=""></customNav>
  4. <view class="yzmctV">
  5. <yhdslCropper ref="yhdslCropper" :quality="1" mode="scale" @uploadImg="uploadImg" :scale="scale"></yhdslCropper>
  6. <myImage class="imagV" :mysrc="userIcon" :isIcon="true" mymode="heightFix" v-on:Emyimageclick='imageUpdata' ></myImage>
  7. </view>
  8. <view class="yzmlist bottomline">
  9. <text class="tittext">{{$t('user.nicheng')}}:</text>
  10. <input class="noinputV" type="text" :placeholder="$t('user.qingshuryhnc')" :value="nikename" @input="phoneinput">
  11. </view>
  12. <view class="yzmctV">
  13. <radio-group @change="radioChange">
  14. <radio value="0" :checked="sex==0" />
  15. {{$t('index.xiansheng')}}
  16. <radio value="1" :checked="sex==1"/>
  17. {{$t('index.nvshi')}}
  18. <radio value="2" :checked="sex==2"/>
  19. {{$t('index.weizhi')}}
  20. </radio-group>
  21. </view>
  22. <view class="yzmctV">
  23. <text class="querenBt" @click="updata">{{$t('index.tijiao')}}</text>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import api from "@/pages/api/api.js"
  29. import yhdslCropper from '@/components/yhdsl-cropper/yhdsl-cropper.vue';
  30. export default {
  31. components: {
  32. yhdslCropper
  33. },
  34. data() {
  35. return {
  36. token:'',
  37. nikename:'',
  38. email:'',
  39. sex:1,
  40. userIcon:'',
  41. userInfo:[],
  42. scale:1
  43. }
  44. },
  45. onLoad() {
  46. this.userInfo = uni.getStorageSync("userInfo");
  47. this.nikename=this.userInfo.nickName;
  48. this.email = this.userInfo.email;
  49. this.sex = this.userInfo.sex;
  50. this.userIcon = this.userInfo.avatar;
  51. console.log(this.userIcon);
  52. },
  53. methods: {
  54. radioChange(e){
  55. console.log(e.detail.value)
  56. this.sex=e.detail.value;
  57. },
  58. phoneinput(event){
  59. this.nikename = event.target.value;
  60. },
  61. smsCodeinput(event){
  62. this.email = event.target.value;
  63. },
  64. imageUpdata(){
  65. this.$refs.yhdslCropper.chooseImage();
  66. },
  67. uploadImg(e) {
  68. console.log('------------uploadImg:',e)
  69. this.spImage = e;
  70. var that = this;
  71. uni.uploadFile({
  72. url: this.$baseUrl.getUploadUrl(), //上传图片api
  73. filePath: e,
  74. name: 'file',
  75. header:{
  76. //"Authorization": userinfo.token
  77. },
  78. success: (res) => {
  79. console.log(res)
  80. let group = JSON.parse(res.data);
  81. that.userIcon=group.data;
  82. uni.showToast({
  83. title:that.$t('mend.shangccg'),
  84. icon:"success"
  85. })
  86. },
  87. fail(errer) {
  88. console.log(errer)
  89. }
  90. });
  91. },
  92. updata(){
  93. var pattern = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(.[a-zA-Z0-9_-]+)+$/;
  94. if (pattern.test(this.email)) {
  95.   ;
  96. } else {
  97.   console.log("错误的邮箱地址!");
  98. if(this.email==''||null==this.email||undefined==this.email){
  99. }
  100. else{
  101. uni.showToast({
  102. title:'Nhầm địa chỉ email!',
  103. icon:"none"
  104. })
  105. return;
  106. }
  107. }
  108. this.updataUserMsg();
  109. },
  110. updataUserMsg(){
  111. api('updataUserMsg',{
  112. "nickName":this.nikename,
  113. "email":this.email,
  114. "sex": this.sex,
  115. "avatar": this.userIcon,
  116. "status": 0
  117. },res=>{
  118. console.log(res.data)
  119. uni.navigateBack({
  120. delta:1,//返回层数,2则上上页
  121. })
  122. },failc=>{
  123. //console.log('getadvertis----',failc)
  124. })
  125. },
  126. }
  127. }
  128. </script>
  129. <style>
  130. .imagV{
  131. margin-top: 30rpx;
  132. padding: 8rpx;
  133. width: 120rpx;
  134. height: 120rpx;
  135. border: 2rpx solid darkgray;
  136. }
  137. .yzmctV{
  138. display: flex;
  139. flex-direction: row;
  140. align-items: center;
  141. justify-content: center;
  142. margin-top: 40rpx;
  143. }
  144. .yzmlist{
  145. display: flex;
  146. flex-direction: row;
  147. align-items: center;
  148. justify-content: flex-start;
  149. width: 100%;
  150. margin-top: 40rpx;
  151. padding: 20rpx;
  152. }
  153. .bottomline{
  154. border: solid lightgray;
  155. border-width: 0px 0px 2rpx 0px;
  156. }
  157. .tittext{
  158. font-size: 26rpx;
  159. width: 20%;
  160. text-align: right;
  161. }
  162. .noinputV{
  163. width: 70%;
  164. margin-left: 2%;
  165. height: 60rpx;
  166. line-height: 60rpx;
  167. border-radius: 20rpx;
  168. border: 2rpx solid lightgray;
  169. }
  170. .querenBt{
  171. margin-top: 30rpx;
  172. width: 80%;
  173. height: 60rpx;
  174. line-height: 60rpx;
  175. padding: 10rpx;
  176. border-radius: 20rpx;
  177. border: solid #40AE36;
  178. border-width: 0px 0px 6rpx 0px;
  179. text-align: center;
  180. justify-content: center;
  181. background-color: #40AE36;
  182. color: white;
  183. box-shadow: 0rpx 0rpx 10rpx 0rpx #40AE36;
  184. }
  185. </style>