index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view class="register">
  3. <view class="content">
  4. <!-- 头部logo -->
  5. <view class="header" style="border-radius:0%;">
  6. <image :src="fetch.avatar" @click="avatarSet(0)" style="border-radius:0%;"></image>
  7. <avatar @upload="avatarUpload" ref="avatar"></avatar>
  8. </view>
  9. <!-- 主体 -->
  10. <view class="main">
  11. <wInput
  12. v-model="fetch.name"
  13. type="text"
  14. placeholder="昵称"
  15. ></wInput>
  16. <wInput
  17. v-model="fetch.info"
  18. type="text"
  19. placeholder="介绍"
  20. ></wInput>
  21. </view>
  22. <wButton
  23. class="wbutton"
  24. text="修改资料"
  25. :rotate="isRotate"
  26. @click.native="update()"
  27. ></wButton>
  28. <!-- 其他登录 -->
  29. <view class="other_login cuIcon">
  30. <view class="login_icon">
  31. <view class="cuIcon-weixin" @tap="bind_weixin"></view>
  32. </view>
  33. </view>
  34. <!-- 底部信息 -->
  35. <view class="footer">
  36. <navigator url="forget" open-type="navigate" @click="index">返回首页</navigator>
  37. <text>|</text>
  38. <navigator url="register" open-type="navigate" @click="tixian">余额提现</navigator>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import wInput from '@/lib/watch-login/watch-input.vue' //input
  45. import wButton from '@/lib/watch-login/watch-button.vue' //button
  46. import avatar from "@/lib/yq-avatar/yq-avatar.vue";
  47. export default {
  48. data() {
  49. return {
  50. fetch : {
  51. name : '',
  52. avatar : '',
  53. sex : 3,
  54. },
  55. isRotate: false, //是否加载旋转
  56. openAvatar : false
  57. }
  58. },
  59. components:{
  60. wInput,
  61. wButton,
  62. avatar
  63. },
  64. // 重新加载
  65. onPullDownRefresh: function() {
  66. this.getData();
  67. },
  68. onLoad() {
  69. this.Dever.checkLogin();
  70. this.getData();
  71. },
  72. methods: {
  73. getData : function() {
  74. this.Dever.get(this, 'app/user/?l=api.getBaseUser');
  75. },
  76. bind_weixin : function() {
  77. var self = this;
  78. this.Dever.confirm('即将开始微信授权,授权后您的微信信息将覆盖现有个人信息,但不会影响您已设置好的某个合小记中的个人信息。', function() {
  79. if (self.Dever.source == 'h5') {
  80. var host = self.Dever.api_host + 'package/oauth/?l=request.auth&account=1&system=1&system_source=' + self.Dever.source_id + '&signature=' + self.Dever.getToken();
  81. self.Dever.location(host, 'go');
  82. } else if (self.Dever.source == 'wx_applet') {
  83. uni.authorize({
  84. scope: 'scope.userInfo',
  85. success() {
  86. uni.login({
  87. provider: 'weixin',
  88. success: function (loginRes) {
  89. console.log(loginRes.authResult);
  90. // 获取用户信息
  91. uni.getUserInfo({
  92. provider: 'weixin',
  93. lang : 'zh_CN',
  94. success: function (infoRes) {
  95. console.log('用户昵称为:' + infoRes.userInfo.nickName);
  96. }
  97. });
  98. }
  99. });
  100. }
  101. })
  102. } else {
  103. self.Dever.alert('暂时不支持app登录');
  104. }
  105. });
  106. },
  107. index : function() {
  108. this.Dever.location('index/index');
  109. },
  110. tixian : function() {
  111. this.Dever.alert('敬请期待');
  112. },
  113. update : function() {
  114. if(this.isRotate){
  115. //判断是否加载中,避免重复点击请求
  116. return false;
  117. }
  118. if (!this.fetch.name) {
  119. this.Dever.alert('昵称不能为空');
  120. return false;
  121. }
  122. this.isRotate = true;
  123. var self = this;
  124. this.Dever.post('package/passport/?l=app.update', {noloading:1, username: this.fetch.name, info: this.fetch.info, gender: this.fetch.sex}, function(t) {
  125. self.isRotate = false;
  126. self.Dever.alert('已保存资料,仅影响未修改过信息的合小记');
  127. }, function(t) {
  128. self.Dever.alert(t.msg);
  129. self.isRotate = false;
  130. });
  131. },
  132. avatarUpload : function(e) {
  133. var self = this;
  134. this.openAvatar = false;
  135. this.Dever.uploadFile(e.path, 'avatar', 1, function(type, file) {
  136. self.fetch.avatar = file;
  137. self.Dever.post('package/passport/?l=app.update', {avatar:file, noloading:1});
  138. });
  139. },
  140. avatarSet : function(index) {
  141. this.openAvatar = true;
  142. this.$refs.avatar.fChooseImg(index,{
  143. selWidth: "300rpx", selHeight: "300rpx",
  144. expWidth: '260rpx', expHeight: '260rpx',
  145. avatarSrc : this.fetch.avatar,
  146. bgImage : this.fetch.avatar,
  147. noTab : true,
  148. });
  149. }
  150. }
  151. }
  152. </script>
  153. <style>
  154. @import url("@/lib/watch-login/css/icon.css");
  155. @import url("@/lib/watch-login/css/main.css");
  156. .other_agree {
  157. display: flex;
  158. flex-direction: row;
  159. justify-content: center;
  160. align-items: center;
  161. margin-top: 50rpx;
  162. text-align: center;
  163. }
  164. .other_login {
  165. margin-top: 80rpx;
  166. }
  167. </style>