userinfo.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <view class="content">
  3. <view class="row1">
  4. <text class="tit">头像</text>
  5. <!-- #ifdef APP -->
  6. <view class="background-img" @click="openAuth">
  7. <image class="background-img" v-model="userInfo.avatar" :src="userInfo.avatar" mode="aspectFill">
  8. </image>
  9. </view>
  10. <!-- #endif -->
  11. <!-- #ifndef APP -->
  12. <view class="background-img" @click="imgsub(3)">
  13. <image class="background-img" v-model="userInfo.avatar" :src="userInfo.avatar" mode="aspectFill">
  14. </image>
  15. </view>
  16. <!-- #endif -->
  17. </view>
  18. <view class="row">
  19. <text class="tit">昵称</text>
  20. <input class="input" type="text" v-model="userInfo.nickname" placeholder-class="placeholder" />
  21. </view>
  22. <view class="row">
  23. <text class="tit">ID</text>
  24. <input class="input" type="text" disabled="true" v-model="userInfo.uid" placeholder-class="placeholder" />
  25. </view>
  26. <!-- <view class="row" v-if="userInfo.tjr">
  27. <text class="tit">推荐人</text>
  28. <input class="input" type="text" disabled="true" v-model="userInfo.tjr" placeholder-class="placeholder" />
  29. </view> -->
  30. <view class="add-btn tj" @click="confirm">提交</view>
  31. <!-- #ifndef APP -->
  32. <view class="add-btn" @click="cancel">退出</view>
  33. <!-- #endif -->
  34. <!-- #ifdef APP -->
  35. <yk-authpup ref="WRITE_EXTERNAL_STORAGE" type="top" @changeAuth="changeAuth"
  36. permissionID="WRITE_EXTERNAL_STORAGE"></yk-authpup>
  37. <yk-authpup ref="CAMERA" type="top" @changeAuth="changeAuths" permissionID="CAMERA"></yk-authpup>
  38. <!-- #endif -->
  39. </view>
  40. </template>
  41. <script>
  42. import ykAuthpup from "@/components/yk-authpup/yk-authpup";
  43. import {
  44. mapState,
  45. mapMutations
  46. } from 'vuex';
  47. import {
  48. upload
  49. } from '@/api/order.js';
  50. import {
  51. userEdit,
  52. logout
  53. } from '@/api/set.js';
  54. export default {
  55. components: {
  56. ykAuthpup
  57. },
  58. data() {
  59. return {
  60. show: false,
  61. password: '',
  62. }
  63. },
  64. onLoad() {
  65. console.log(this.userInfo)
  66. },
  67. computed: {
  68. ...mapState('user', ['userInfo'])
  69. },
  70. methods: {
  71. ...mapMutations('user', ['logout']),
  72. openAuth() {
  73. let that = this
  74. uni.showActionSheet({
  75. itemList: ['拍摄', '从相册选择'],
  76. success: function(res) {
  77. // console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
  78. if (res.tapIndex == 1) {
  79. that.$refs['WRITE_EXTERNAL_STORAGE'].open()
  80. } else {
  81. that.$refs['CAMERA'].open()
  82. }
  83. },
  84. fail: function(res) {
  85. console.log(res.errMsg);
  86. }
  87. });
  88. },
  89. changeAuth() {
  90. console.log('zheli');
  91. this.imgsub(1)
  92. },
  93. changeAuths() {
  94. console.log('nali');
  95. this.imgsub(0)
  96. },
  97. imgsub(index) {
  98. console.log('上传头像')
  99. upload({
  100. filename: '',
  101. stype: index
  102. }).then(data => {
  103. console.log("data", data);
  104. this.userInfo.avatar = data[0].url;
  105. })
  106. },
  107. confirm() {
  108. userEdit({
  109. avatar: this.userInfo.avatar,
  110. nickname: this.userInfo.nickname
  111. })
  112. .then(e => {
  113. this.$api.msg('修改成功');
  114. setTimeout(() => {
  115. uni.switchTab({
  116. url: '/pages/user/user'
  117. });
  118. }, 1000);
  119. console.log(e);
  120. })
  121. .catch(e => {
  122. console.log(e);
  123. });
  124. },
  125. toLogout() {
  126. let obj = this;
  127. uni.showModal({
  128. content: '确定要退出登录么',
  129. success: (e) => {
  130. if (e.confirm) {
  131. logout({}).then((e) => {
  132. uni.navigateBack();
  133. }).catch((e) => {
  134. console.log(e);
  135. })
  136. obj.logout();
  137. }
  138. }
  139. });
  140. },
  141. cancel() {
  142. // this.$refs.popup.open();
  143. let obj = this;
  144. uni.showModal({
  145. content: '确定要退出登录么',
  146. success: e => {
  147. if (e.confirm) {
  148. logout({}).then(e => {
  149. obj.logout();
  150. uni.switchTab({
  151. url: '/pages/index/index'
  152. })
  153. })
  154. .catch(e => {
  155. console.log(e);
  156. });
  157. }
  158. }
  159. });
  160. },
  161. qx() {
  162. this.password = '';
  163. this.$refs.popup.close();
  164. },
  165. pswQd() {
  166. if (this.password != this.userInfo.phone) {
  167. this.$refs.popup.close();
  168. this.password = '';
  169. this.$api.msg("请输入自己的账户")
  170. return
  171. }
  172. this.$refs.popup.close();
  173. this.password = '';
  174. this.$api.msg("申请注销成功,请耐心等待审核")
  175. }
  176. }
  177. }
  178. </script>
  179. <style lang="scss">
  180. .row1 {
  181. display: flex;
  182. align-items: center;
  183. justify-content: space-between;
  184. position: relative;
  185. padding: 0 30upx;
  186. height: 110upx;
  187. background: #fff;
  188. margin-bottom: 20upx;
  189. .tit {
  190. flex-shrink: 0;
  191. width: 120upx;
  192. font-size: $font-lg;
  193. color: $font-color-dark;
  194. }
  195. .background-img {
  196. width: 80rpx;
  197. height: 80rpx;
  198. border-radius: 50%;
  199. background: #f2f2f2;
  200. }
  201. }
  202. .row {
  203. display: flex;
  204. align-items: center;
  205. padding: 0 30upx;
  206. height: 110upx;
  207. background: #fff;
  208. .tit {
  209. flex-shrink: 0;
  210. width: 120upx;
  211. font-size: $font-lg;
  212. color: $font-color-dark;
  213. }
  214. .input {
  215. flex: 1;
  216. text-align: right;
  217. font-size: $font-base;
  218. color: $color-gray;
  219. }
  220. }
  221. .add-btn {
  222. display: flex;
  223. align-items: center;
  224. justify-content: center;
  225. margin: 40rpx auto 30rpx;
  226. width: 560rpx;
  227. height: 80rpx;
  228. background: #fff;
  229. border-radius: 40px;
  230. color: $base-color;
  231. border: 1px solid $base-color;
  232. }
  233. .tj {
  234. margin-top: 160rpx;
  235. background: $base-color;
  236. color: #fff;
  237. }
  238. .out {
  239. display: flex;
  240. align-items: center;
  241. justify-content: center;
  242. margin: 0 auto 30rpx;
  243. width: 560rpx;
  244. height: 80rpx;
  245. border: 1px solid #DC262B;
  246. background: #FFFFFF;
  247. border-radius: 40px;
  248. color: #DC262B;
  249. }
  250. .psw-wrapper {
  251. width: 548rpx;
  252. height: 344rpx;
  253. background-color: #ffffff;
  254. .psw-title {
  255. width: 100%;
  256. font-size: 35rpx;
  257. padding: 43rpx 0 49rpx;
  258. text-align: center;
  259. font-weight: 800;
  260. }
  261. .psw-ipt {
  262. display: block;
  263. background-color: #dce3ed;
  264. height: 90rpx;
  265. width: 464rpx;
  266. padding-left: 30rpx;
  267. margin: 0 auto;
  268. font-size: 80rpx;
  269. }
  270. .psw-btn text {
  271. display: inline-block;
  272. text-align: center;
  273. width: 50%;
  274. padding-top: 29rpx;
  275. font-size: 35rpx;
  276. }
  277. .psw-qd {
  278. color: #32C6FF;
  279. }
  280. }
  281. </style>