set.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <view class="set">
  3. <view class="set-main">
  4. <view class="set-item flex">
  5. <view class="set-font">头像</view>
  6. <view class="set-image flexs" @click="uploadHead">
  7. <image :src="info.avatar" mode="aspectFill" class="head"></image>
  8. <image src="/static/image/publice/jinruer@2x.png" mode=""></image>
  9. </view>
  10. </view>
  11. <view class="set-item flex">
  12. <view class="set-font">昵称</view>
  13. <view class="set-input"><input type="text" @input="changeName" :value="info.nickname" /></view>
  14. </view>
  15. <view class="set-item flex">
  16. <view class="set-font">邀请码</view>
  17. <view class="set-input"><input type="text" disabled="" :value="sharecode" /></view>
  18. </view>
  19. </view>
  20. <button class="btn" hover-class="hover-view" @click="quitLogin">退出登录</button>
  21. <!-- #ifdef APP-PLUS -->
  22. <button class="btn1" hover-class="hover-view" @click="quitLogin1">注销账户</button>
  23. <!-- #endif -->
  24. <uni-popup ref="popup" type="center">
  25. <view class="psw-wrapper">
  26. <view class="psw-title">请输入自己的账户</view>
  27. <input type="text" v-model="password" class="psw-ipt" />
  28. <view class="psw-btn">
  29. <text @click.stop="qx">取消</text>
  30. <text class="psw-qd" @click.stop="pswQd">确定</text>
  31. </view>
  32. </view>
  33. </uni-popup>
  34. </view>
  35. </template>
  36. <script>
  37. import $DB from '../../http/debounce.js';
  38. import uniPopup from '../../components/uni-popup/uni-popup.vue';
  39. export default {
  40. components: {
  41. uniPopup
  42. },
  43. data() {
  44. return {
  45. sharecode: '',
  46. password: '',
  47. info: {} //
  48. };
  49. },
  50. methods: {
  51. //退出登录
  52. quitLogin() {
  53. uni.showModal({
  54. content: '是否退出登录?',
  55. success: res => {
  56. if (res.confirm) {
  57. uni.removeStorageSync('token');
  58. // #ifdef MP-WEIXIN
  59. uni.redirectTo({ url: '/pages/login/wxLogin' });
  60. // #endif
  61. // #ifndef MP-WEIXIN
  62. uni.redirectTo({ url: '/pages/login/login' });
  63. // #endif
  64. }
  65. }
  66. });
  67. },
  68. quitLogin1() {
  69. this.$refs.popup.open();
  70. },
  71. qx() {
  72. this.password = '';
  73. this.$refs.popup.close();
  74. },
  75. pswQd() {
  76. // if (this.password != this.info.nickname) {
  77. // this.$refs.popup.close();
  78. // this.password = '';
  79. // uni.showToast({
  80. // title: '请输入自己的账户',
  81. // duration: 1500,
  82. // mask: false,
  83. // icon: 'none'
  84. // });
  85. // return;
  86. // }
  87. this.$refs.popup.close();
  88. this.password = '';
  89. uni.showToast({
  90. title: '申请注销成功,请耐心等待审核',
  91. duration: 1500,
  92. mask: false,
  93. icon: 'none'
  94. });
  95. },
  96. //修改名字
  97. changeName: $DB(function(e) {
  98. if (!e.detail.value) return;
  99. this.$api.changeInfo({ nickname: e.detail.value }).then(res => {
  100. if (res.code === 1) {
  101. }
  102. });
  103. }),
  104. //修改头像
  105. uploadHead() {
  106. uni.chooseImage({
  107. count: 1, //默认9
  108. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  109. sourceType: ['album', 'camera'], //从相册选择
  110. success: res => {
  111. this.$api.upload_image({ path: res.tempFilePaths[0] }).then(res => {
  112. this.$api.changeInfo({ avatar_url: 'https://www.chaomangdao.com' + res.url }).then(res => {
  113. if (res.code === 1) {
  114. uni.showToast({ title: res.msg });
  115. this.getSet();
  116. }
  117. });
  118. });
  119. }
  120. });
  121. },
  122. //获取设置信息
  123. getSet() {
  124. this.$api.getSettingInfo().then(res => {
  125. if (res.code === 1) {
  126. this.info = res.data;
  127. }
  128. });
  129. this.$api
  130. .userinfo()
  131. .then(res => {
  132. if (res.code === 1) {
  133. this.sharecode = res.data.sharecode;
  134. }
  135. })
  136. .catch(res => {
  137. console.log(res);
  138. });
  139. }
  140. },
  141. onShow() {
  142. this.getSet();
  143. }
  144. };
  145. </script>
  146. <style lang="scss">
  147. .set {
  148. min-height: calc(100vh - 44px);
  149. position: relative;
  150. }
  151. .set-item {
  152. padding: 30rpx;
  153. background: #ffffff;
  154. margin-top: 2rpx;
  155. &:first-child {
  156. padding: 15rpx 30rpx;
  157. }
  158. .set-font {
  159. font-size: 28rpx;
  160. }
  161. .set-image {
  162. image {
  163. width: 22rpx;
  164. height: 22rpx;
  165. }
  166. .head {
  167. width: 70rpx;
  168. height: 70rpx;
  169. flex-shrink: 0;
  170. margin-right: 20rpx;
  171. border-radius: 50%;
  172. }
  173. }
  174. .set-input {
  175. color: #999999;
  176. font-size: 26rpx;
  177. input {
  178. font-size: 26rpx;
  179. text-align: right;
  180. }
  181. }
  182. }
  183. .btn {
  184. color: #333333;
  185. height: 98rpx;
  186. bottom: 42rpx;
  187. left: 50%;
  188. width: 690rpx;
  189. position: absolute;
  190. transform: translateX(-50%);
  191. font-size: 30rpx;
  192. background: #ffffff;
  193. box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(102, 102, 102, 0.2);
  194. border-radius: 10rpx;
  195. }
  196. .btn1 {
  197. color: #333333;
  198. height: 98rpx;
  199. bottom: 142rpx;
  200. left: 50%;
  201. width: 690rpx;
  202. position: absolute;
  203. transform: translateX(-50%);
  204. font-size: 30rpx;
  205. background: #ffffff;
  206. box-shadow: 0rpx 0rpx 16rpx 0rpx rgba(102, 102, 102, 0.2);
  207. border-radius: 10rpx;
  208. }
  209. .psw-wrapper {
  210. width: 548rpx;
  211. height: 344rpx;
  212. background-color: #ffffff;
  213. .psw-title {
  214. width: 100%;
  215. font-size: 35rpx;
  216. padding: 43rpx 0 49rpx;
  217. text-align: center;
  218. font-weight: 800;
  219. }
  220. .psw-ipt {
  221. display: block;
  222. background-color: #dce3ed;
  223. height: 90rpx;
  224. width: 464rpx;
  225. padding-left: 30rpx;
  226. margin: 0 auto;
  227. font-size: 80rpx;
  228. }
  229. .psw-btn text {
  230. display: inline-block;
  231. text-align: center;
  232. width: 50%;
  233. padding-top: 29rpx;
  234. font-size: 35rpx;
  235. }
  236. .psw-qd {
  237. color: #32c6ff;
  238. }
  239. }
  240. </style>