account.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <view class="content">
  3. <u-cell-group>
  4. <u-cell size="large" title="手机号" :value="user.mobile" isLink></u-cell>
  5. <u-cell size="large" title="微信号" :value="user.wx_name || '未绑定'" isLink @click="tobindwx"></u-cell>
  6. <u-cell size="large" title="登录密码" value="修改密码" isLink @click="topwd"></u-cell>
  7. </u-cell-group>
  8. </view>
  9. </template>
  10. <script>
  11. import $api from '@/static/js/api.js'
  12. export default {
  13. data() {
  14. return {
  15. user: {}
  16. }
  17. },
  18. onLoad() {
  19. this.getuser()
  20. },
  21. methods: {
  22. topwd() {
  23. uni.navigateTo({
  24. url: '/pageC/edit-pwd'
  25. })
  26. },
  27. tobindwx() {
  28. var that = this
  29. uni.login({
  30. "provider": "weixin",
  31. "onlyAuthorize": true, // 微信登录仅请求授权认证
  32. success: function(event){
  33. const {code} = event
  34. //客户端成功获取授权临时票据(code),向业务服务器发起登录请求。
  35. $api.req({
  36. url: 'user/bind-wechat',
  37. method: 'post',
  38. data: {
  39. code: event.code
  40. }
  41. }, function(res) {
  42. if(res.code == 10000) {
  43. $api.info('绑定成功')
  44. }
  45. })
  46. },
  47. fail: function (err) {
  48. // 登录授权失败
  49. // err.code是错误码
  50. }
  51. })
  52. },
  53. getuser() {
  54. var that = this
  55. $api.req({
  56. url: 'user/info',
  57. method:'get',
  58. } ,function(res) {
  59. if(res.code == 10000) {
  60. that.user = res.data
  61. }
  62. })
  63. }
  64. }
  65. }
  66. </script>
  67. <style lang="scss">
  68. .content {
  69. background: #FFFFFF;
  70. }
  71. </style>