set.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view class="content">
  3. <view class="row1">
  4. <text class="tit">{{$t('set.a1')}}</text>
  5. <view
  6. class="background-img"
  7. @click="upload"
  8. ><image
  9. class="background-img"
  10. v-model="avatar"
  11. :src="avatar"
  12. mode="aspectFill"></image
  13. ></view>
  14. </view>
  15. <view class="row">
  16. <text class="tit">{{$t('set.a2')}}</text>
  17. <input
  18. class="input"
  19. type="button"
  20. v-model="name"
  21. placeholder-class="placeholder" />
  22. </view>
  23. <view class="row">
  24. <text class="tit">{{$t('set.a3')}}</text>
  25. <input
  26. class="input"
  27. disabled
  28. type="text"
  29. v-model="phone"
  30. placeholder-class="placeholder" />
  31. </view>
  32. <button
  33. class="add-btn"
  34. @click="confirm"
  35. >{{$t('set.a4')}}</button
  36. >
  37. </view>
  38. </template>
  39. <script>
  40. import { mapState, mapMutations } from "vuex";
  41. import { userEdit, logout } from "@/api/set.js";
  42. import { upload } from "@/api/order.js";
  43. export default {
  44. data() {
  45. return {
  46. name: "", // 昵称
  47. phone: "",
  48. avatar: "",
  49. countDown: 1,
  50. };
  51. },
  52. computed: {
  53. ...mapState("user", ["userInfo"]),
  54. startDate() {
  55. console.log("start");
  56. },
  57. endDate() {
  58. console.log("end");
  59. },
  60. },
  61. onLoad() {
  62. uni.setNavigationBarTitle({
  63. title: this.$t("tab.a7"),
  64. });
  65. },
  66. onShow(option) {
  67. console.log("111", this.userInfo);
  68. this.name = this.userInfo.nickname + "";
  69. this.avatar = this.userInfo.avatar || "";
  70. this.phone = this.userInfo.phone || "";
  71. },
  72. methods: {
  73. ...mapMutations("user", ["logout"]),
  74. // 上传头像
  75. upload() {
  76. console.log("111111");
  77. upload({
  78. filename: "",
  79. }).then(data => {
  80. this.avatar = data[0].url;
  81. console.log(this.avatar, "tup");
  82. setTimeout(() => {
  83. uni.hideLoading();
  84. }, 500);
  85. });
  86. },
  87. confirm() {
  88. userEdit({
  89. nickname: this.name,
  90. avatar: this.avatar,
  91. // password: this.password,
  92. // captcha: this.captcha,
  93. // account: this.account,
  94. })
  95. .then(e => {
  96. this.$api.msg("修改成功");
  97. // 清空输入框
  98. (this.password = ""),
  99. setTimeout(() => {
  100. uni.switchTab({
  101. url: "/pages/user/user",
  102. });
  103. }, 1000);
  104. console.log(e);
  105. })
  106. .catch(e => {
  107. console.log(e);
  108. });
  109. },
  110. loginout() {
  111. uni.navigateTo({
  112. url: "/pages/switch/switch",
  113. });
  114. },
  115. },
  116. };
  117. </script>
  118. <style lang="scss">
  119. page {
  120. background-color: #fff;
  121. }
  122. .content {
  123. background-color: #fff;
  124. }
  125. .row1 {
  126. display: flex;
  127. align-items: center;
  128. justify-content: space-between;
  129. position: relative;
  130. padding: 0 30upx;
  131. height: 110upx;
  132. background: #fff;
  133. .tit {
  134. flex-shrink: 0;
  135. width: 120upx;
  136. font-size: $font-lg;
  137. }
  138. .background-img {
  139. width: 80rpx;
  140. height: 80rpx;
  141. border-radius: 50%;
  142. background: #f2f2f2;
  143. }
  144. }
  145. .row {
  146. display: flex;
  147. align-items: center;
  148. justify-content: space-between;
  149. position: relative;
  150. padding: 0 30upx;
  151. height: 110upx;
  152. background: #fff;
  153. .tit {
  154. flex-shrink: 0;
  155. font-size: $font-lg;
  156. color: $font-color-dark;
  157. }
  158. .tit1 {
  159. flex-shrink: 0;
  160. width: 150upx;
  161. font-size: $font-lg;
  162. color: $font-color-dark;
  163. }
  164. .input {
  165. text-align: right;
  166. flex: 1;
  167. font-size: $font-base;
  168. color: $color-gray;
  169. }
  170. .iconlocation {
  171. font-size: 36upx;
  172. color: $font-color-light;
  173. }
  174. }
  175. .add-btn {
  176. display: flex;
  177. align-items: center;
  178. justify-content: center;
  179. width: 560upx;
  180. height: 80upx;
  181. margin: 60upx auto;
  182. font-size: $font-lg;
  183. color: #fff;
  184. background: $base-color;
  185. border-radius: 40upx;
  186. }
  187. .loginout {
  188. display: flex;
  189. align-items: center;
  190. justify-content: center;
  191. width: 560upx;
  192. height: 80upx;
  193. margin: 60upx auto;
  194. font-size: $font-lg;
  195. color: #fff;
  196. }
  197. </style>