me - 副本.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <view>
  3. <view class="header">
  4. <view class="bg">
  5. <view class="box">
  6. <view class="box-hd" @click="login">
  7. <view v-if="islogin">
  8. <view class="avator">
  9. <img :src="userinfo.avatar">
  10. </view>
  11. <view class="phone-number">ID:{{userinfo.id}} 昵称:{{userinfo.nickname || '未设置昵称'}}</view>
  12. </view>
  13. <view v-else>
  14. <view class="avator">
  15. <img :src="avatarUrl">
  16. </view>
  17. <view class="phone-number" style="color: red;">请先点我登录</view>
  18. </view>
  19. </view>
  20. <view class="box-bd" @click="myNotice">
  21. <view class="item">
  22. <u-icon class="icon" name="volume-fill" size="25" color="#757575"></u-icon>
  23. <view class="text">我的通知</view>
  24. </view>
  25. <view class="item">
  26. <u-icon class="icon" name="star-fill" size="25" color="#757575"></u-icon>
  27. <view class="text">我的收藏</view>
  28. </view>
  29. <view class="item">
  30. <u-icon class="icon" name="server-fill" size="25" color="#757575"></u-icon>
  31. <view class="text">我的客服</view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="list-content">
  38. <view class="list">
  39. <view class="li">
  40. <u-icon class="icon" name="coupon-fill" size="25" color="#757575"></u-icon>
  41. <view class="text">我的名片</view>
  42. <u-icon class="icon" name="arrow-right" size="20" color="#757575"></u-icon>
  43. </view>
  44. <view class="li " @click="changeSkin">
  45. <u-icon class="icon" name="grid-fill" size="25" color="#757575"></u-icon>
  46. <view class="text">主题切换</view>
  47. <u-icon class="icon" name="arrow-right" size="20" color="#757575"></u-icon>
  48. </view>
  49. <view class="li ">
  50. <u-icon class="icon" name="question-circle-fill" size="25" color="#757575"></u-icon>
  51. <view class="text">帮助中心</view>
  52. <u-icon class="icon" name="arrow-right" size="20" color="#757575"></u-icon>
  53. </view>
  54. <view class="li ">
  55. <u-icon class="icon" name="info-circle-fill" size="25" color="#757575"></u-icon>
  56. <view class="text">关于我们</view>
  57. <u-icon class="icon" name="arrow-right" size="20" color="#757575"></u-icon>
  58. </view>
  59. <view class="li ">
  60. <u-icon class="icon" name="email-fill" size="25" color="#757575"></u-icon>
  61. <view class="text">意见反馈</view>
  62. <u-icon class="icon" name="arrow-right" size="20" color="#757575"></u-icon>
  63. </view>
  64. <view class="li noborder">
  65. <u-icon class="icon" name="setting-fill" size="25" color="#757575"></u-icon>
  66. <view class="text">系统设置</view>
  67. <u-icon class="icon" name="arrow-right" size="20" color="#757575"></u-icon>
  68. </view>
  69. <view class="li noborder" @click="loginOut">
  70. <u-icon class="icon" name="setting-fill" size="25" color="#757575"></u-icon>
  71. <view class="text">注销登录</view>
  72. <u-icon class="icon" name="arrow-right" size="20" color="#757575"></u-icon>
  73. </view>
  74. </view>
  75. </view>
  76. <view class="copyright">
  77. <text>AbuCoder版权所有</text>
  78. </view>
  79. <!-- 底部导航 -->
  80. <Tabbar :current-page="4"/>
  81. </view>
  82. </template>
  83. <script>
  84. import Tabbar from "@/components/Tabbar/index.vue";
  85. import {
  86. setUserInfo,
  87. getUserInfo,
  88. setToken,
  89. getToken,
  90. removeUserInfo,
  91. removeToken
  92. } from '@/utils/auth';
  93. export default {
  94. components: {
  95. Tabbar
  96. },
  97. data() {
  98. return {
  99. avatarUrl: 'https://portrait.gitee.com/uploads/avatars/user/354/1062657_rahman_1649233036.png!avatar60',
  100. userinfo: {},
  101. islogin:false,
  102. }
  103. },
  104. onShow() {
  105. console.log(getUserInfo())
  106. if(getUserInfo()!=undefined){
  107. this.islogin = true
  108. }
  109. this.userinfo = getUserInfo() || {};
  110. },
  111. methods: {
  112. login() {
  113. let that = this
  114. uni.login({
  115. provider: 'weixin',
  116. success: function(loginRes) {
  117. let form = {};
  118. form.code = loginRes.code; //用户code 注:用户的code每次登录都是随机的,所以不需要进行存储
  119. uni.showLoading({
  120. title: "登录中....",
  121. mask: true
  122. })
  123. that.request('wxlogin', form, 'POST').then(wxloginres => {
  124. console.log("wxloginres: ", wxloginres)
  125. if (wxloginres.code==200) {
  126. uni.hideLoading()
  127. setTimeout(function() {
  128. uni.hideLoading();
  129. }, 2000);
  130. setToken(wxloginres.data.openid)
  131. setUserInfo(wxloginres.data); //模拟存储用户信息
  132. //成功后进入头像与昵称修改页面
  133. uni.navigateTo({
  134. url: '/pages/me/userinfo'
  135. })
  136. } else {
  137. uni.showToast({
  138. icon: "none",
  139. title: "登录失败,请稍后试试!",
  140. duration: 2000
  141. })
  142. }
  143. })
  144. },
  145. fail(err) {
  146. console.log(err)
  147. }
  148. });
  149. },
  150. myNotice() {
  151. uni.navigateTo({
  152. url: './mynotice/mynotice'
  153. })
  154. },
  155. loginOut() {
  156. uni.showModal({
  157. title: '注销登录提示',
  158. content: '确定要注销登录吗?',
  159. cancelText: "取消", // 取消按钮的文字
  160. confirmText: "确认", // 确认按钮的文字
  161. confirmColor: '#f55850',
  162. success: (res) => {
  163. if (res.confirm) {
  164. console.log('comfirm') //点击确定之后执行的代码
  165. uni.$u.toast("注销登录成功,欢迎再来")
  166. removeUserInfo()
  167. removeToken()
  168. this.islogin=false
  169. } else {
  170. console.log('cancel') //点击取消之后执行的代码
  171. }
  172. }
  173. })
  174. }
  175. }
  176. }
  177. </script>
  178. <style lang="scss">
  179. page {
  180. background-color: #f1f1f1;
  181. font-size: 28rpx;
  182. }
  183. .header {
  184. background: #fff;
  185. height: 660rpx;
  186. padding-bottom: 110rpx;
  187. .bg {
  188. width: 100%;
  189. height: 490rpx;
  190. padding-top: 310rpx;
  191. background: linear-gradient(to bottom, rgb(1, 94, 234), rgb(0, 192, 250), rgb(255, 255, 255));
  192. }
  193. }
  194. .box {
  195. width: 650rpx;
  196. height: 300rpx;
  197. border-radius: 20rpx;
  198. margin: 0 auto;
  199. background: #fff;
  200. box-shadow: 0 5rpx 20rpx 0rpx rgba(0, 0, 150, .2);
  201. .box-hd {
  202. display: flex;
  203. flex-wrap: wrap;
  204. flex-direction: row;
  205. justify-content: center;
  206. margin-top: 15rpx;
  207. .avator {
  208. width: 160rpx;
  209. height: 160rpx;
  210. background: #fff;
  211. border: 5rpx solid #f1f1f1;
  212. border-radius: 50%;
  213. margin: 0 auto;
  214. margin-top: -80rpx;
  215. overflow: hidden;
  216. img {
  217. width: 100%;
  218. height: 100%;
  219. }
  220. }
  221. .phone-number {
  222. width: 100%;
  223. text-align: center;
  224. margin: 20rpx auto;
  225. }
  226. }
  227. .box-bd {
  228. display: flex;
  229. flex-wrap: nowrap;
  230. flex-direction: row;
  231. justify-content: center;
  232. .item {
  233. flex: 1 1 auto;
  234. display: flex;
  235. flex-wrap: wrap;
  236. flex-direction: row;
  237. justify-content: center;
  238. border-right: 1px solid #f1f1f1;
  239. margin: 15rpx 0;
  240. &:last-child {
  241. border: none;
  242. }
  243. .icon {
  244. width: 60rpx;
  245. height: 60rpx;
  246. img {
  247. width: 100%;
  248. height: 100%;
  249. }
  250. }
  251. .text {
  252. width: 100%;
  253. text-align: center;
  254. margin-top: 10rpx;
  255. }
  256. }
  257. }
  258. }
  259. .list-content {
  260. background: #fff;
  261. }
  262. .list {
  263. width: 100%;
  264. border-bottom: 15rpx solid #f1f1f1;
  265. background: #fff;
  266. &:last-child {
  267. border: none;
  268. }
  269. .li {
  270. width: 92%;
  271. height: 100rpx;
  272. padding: 0px 4%;
  273. border-bottom: 1px solid #f3f3f3;
  274. display: flex;
  275. align-items: center;
  276. margin: 0rpx auto;
  277. &.noborder {
  278. border-bottom: 0
  279. }
  280. .icon {
  281. flex-shrink: 0;
  282. width: 50rpx;
  283. height: 50rpx;
  284. image {
  285. width: 50rpx;
  286. height: 50rpx;
  287. }
  288. }
  289. .text {
  290. padding-left: 20rpx;
  291. width: 100%;
  292. color: #666;
  293. }
  294. .to {
  295. flex-shrink: 0;
  296. width: 40rpx;
  297. height: 40rpx;
  298. }
  299. }
  300. }
  301. .copyright {
  302. margin: 20rpx auto;
  303. width: 80%;
  304. height: 60rpx;
  305. display: flex;
  306. justify-content: center;
  307. align-items: center;
  308. color: #9E9E9E;
  309. font-size: 26rpx;
  310. }
  311. </style>