userMsgMenager.vue 4.6 KB

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